@@ -68,6 +68,10 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                        
@@ -57,7 +57,7 @@ discard block  | 
                                                    ||
| 57 | 57 | return ($dec);  | 
                                                        
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
| 60 | - /*  | 
                                                        |
| 60 | + /*  | 
                                                        |
| 61 | 61 | $ais_map64 = array(  | 
                                                        
| 62 | 62 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48  | 
                                                        
| 63 | 63 | ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C',  | 
                                                        
@@ -97,13 +97,13 @@ discard block  | 
                                                    ||
| 97 | 97 | // ' ' --- '?', // 0x20 - 0x3F  | 
                                                        
| 98 | 98 | // '@' --- '_', // 0x40 - 0x5F  | 
                                                        
| 99 | 99 | $ais_chars = array(  | 
                                                        
| 100 | - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',  | 
                                                        |
| 101 | - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',  | 
                                                        |
| 102 | - 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',  | 
                                                        |
| 103 | - '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',  | 
                                                        |
| 104 | -		    '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', | 
                                                        |
| 105 | - '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',  | 
                                                        |
| 106 | - '<', '=', '>', '?'  | 
                                                        |
| 100 | + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',  | 
                                                        |
| 101 | + 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',  | 
                                                        |
| 102 | + 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',  | 
                                                        |
| 103 | + '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',  | 
                                                        |
| 104 | +			'(', ')', '*', '+', ',', '-', '.', '/', '0', '1', | 
                                                        |
| 105 | + '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',  | 
                                                        |
| 106 | + '<', '=', '>', '?'  | 
                                                        |
| 107 | 107 | );  | 
                                                        
| 108 | 108 | $rv = '';  | 
                                                        
| 109 | 109 |  		if ($_size % 6 == 0) { | 
                                                        
@@ -269,8 +269,8 @@ discard block  | 
                                                    ||
| 269 | 269 | }  | 
                                                        
| 270 | 270 |  				if ($num_seq > 1) { // for multipart messages | 
                                                        
| 271 | 271 | if ($cmsg_sid != $msg_sid // different msg_sid  | 
                                                        
| 272 | - || $msg_sid == -1 // invalid initial msg_sid  | 
                                                        |
| 273 | - || ($seq - $pseq) != 1 // not insequence  | 
                                                        |
| 272 | + || $msg_sid == -1 // invalid initial msg_sid  | 
                                                        |
| 273 | + || ($seq - $pseq) != 1 // not insequence  | 
                                                        |
| 274 | 274 |  					) {  // invalid for multipart message | 
                                                        
| 275 | 275 | $msg_sid = -1;  | 
                                                        
| 276 | 276 | $cmsg_sid = -1;  | 
                                                        
@@ -283,7 +283,7 @@ discard block  | 
                                                    ||
| 283 | 283 | $itu = $itu.$pcs[5]; // get itu message  | 
                                                        
| 284 | 284 | $filler += (int)$pcs[6][0]; // get filler  | 
                                                        
| 285 | 285 | if ($num_seq == 1 // valid single message  | 
                                                        
| 286 | - || $num_seq == $pseq // valid multi-part message  | 
                                                        |
| 286 | + || $num_seq == $pseq // valid multi-part message  | 
                                                        |
| 287 | 287 |  				) { | 
                                                        
| 288 | 288 |  					if ($num_seq != 1) { // test | 
                                                        
| 289 | 289 | //echo $rawdata;  | 
                                                        
@@ -366,13 +366,13 @@ discard block  | 
                                                    ||
| 366 | 366 | else $pad = '';  | 
                                                        
| 367 | 367 | $rv = '';  | 
                                                        
| 368 | 368 | $ais_chars = array(  | 
                                                        
| 369 | - '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,  | 
                                                        |
| 370 | - 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,  | 
                                                        |
| 371 | - 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,  | 
                                                        |
| 372 | - '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,  | 
                                                        |
| 373 | -		    '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, | 
                                                        |
| 374 | - '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,  | 
                                                        |
| 375 | - '<'=>60, '='=>61, '>'=>62, '?'=>63  | 
                                                        |
| 369 | + '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,  | 
                                                        |
| 370 | + 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,  | 
                                                        |
| 371 | + 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,  | 
                                                        |
| 372 | + '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,  | 
                                                        |
| 373 | +			'('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, | 
                                                        |
| 374 | + '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,  | 
                                                        |
| 375 | + '<'=>60, '='=>61, '>'=>62, '?'=>63  | 
                                                        |
| 376 | 376 | );  | 
                                                        
| 377 | 377 | $_a = str_split($name);  | 
                                                        
| 378 | 378 |  		if ($_a) foreach ($_a as $_1) { | 
                                                        
@@ -29,31 +29,31 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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;  | 
                                                        
@@ -35,7 +35,9 @@ discard block  | 
                                                    ||
| 35 | 35 | $temp += 1;  | 
                                                        
| 36 | 36 | $flat = (float)($temp / (60.0 * 10000.0));  | 
                                                        
| 37 | 37 | $flat *= -1.0;  | 
                                                        
| 38 | - } else $flat = (float)($temp / (60.0 * 10000.0));  | 
                                                        |
| 38 | +		} else { | 
                                                        |
| 39 | + $flat = (float)($temp / (60.0 * 10000.0));  | 
                                                        |
| 40 | + }  | 
                                                        |
| 39 | 41 | return $flat; // float  | 
                                                        
| 40 | 42 | }  | 
                                                        
| 41 | 43 | |
@@ -47,7 +49,9 @@ discard block  | 
                                                    ||
| 47 | 49 | $temp += 1;  | 
                                                        
| 48 | 50 | $flon = (float)($temp / (60.0 * 10000.0));  | 
                                                        
| 49 | 51 | $flon *= -1.0;  | 
                                                        
| 50 | - } else $flon = (float)($temp / (60.0 * 10000.0));  | 
                                                        |
| 52 | +		} else { | 
                                                        |
| 53 | + $flon = (float)($temp / (60.0 * 10000.0));  | 
                                                        |
| 54 | + }  | 
                                                        |
| 51 | 55 | return $flon;  | 
                                                        
| 52 | 56 | }  | 
                                                        
| 53 | 57 | |
@@ -70,10 +74,8 @@ discard block  | 
                                                    ||
| 70 | 74 | */  | 
                                                        
| 71 | 75 |  	private function asciidec_2_8bit($ascii) { | 
                                                        
| 72 | 76 | //only process in the following range: 48-87, 96-119  | 
                                                        
| 73 | -		if ($ascii < 48) { } | 
                                                        |
| 74 | -		else { | 
                                                        |
| 75 | -			if($ascii>119) { } | 
                                                        |
| 76 | -			else { | 
                                                        |
| 77 | +		if ($ascii < 48) { } else { | 
                                                        |
| 78 | +			if($ascii>119) { } else { | 
                                                        |
| 77 | 79 | if ($ascii>87 && $ascii<96) ;  | 
                                                        
| 78 | 80 |  				else { | 
                                                        
| 79 | 81 | $ascii=$ascii+40;  | 
                                                        
@@ -236,19 +238,34 @@ discard block  | 
                                                    ||
| 236 | 238 | // assume 1st ! is valid  | 
                                                        
| 237 | 239 | // find * ensure that it is at correct position  | 
                                                        
| 238 | 240 | $end = strrpos ( $rawdata , '*' );  | 
                                                        
| 239 | - if ($end === FALSE) return -1; // check for NULLS!!!  | 
                                                        |
| 241 | +		if ($end === FALSE) { | 
                                                        |
| 242 | + return -1;  | 
                                                        |
| 243 | + }  | 
                                                        |
| 244 | + // check for NULLS!!!  | 
                                                        |
| 240 | 245 | $cs = substr( $rawdata, $end + 1 );  | 
                                                        
| 241 | - if ( strlen($cs) != 2 ) return -1; // correct cs length  | 
                                                        |
| 246 | +		if ( strlen($cs) != 2 ) { | 
                                                        |
| 247 | + return -1;  | 
                                                        |
| 248 | + }  | 
                                                        |
| 249 | + // correct cs length  | 
                                                        |
| 242 | 250 | $dcs = (int)hexdec( $cs );  | 
                                                        
| 243 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum  | 
                                                        |
| 251 | +		for ( $alias=1; $alias<$end; $alias++) { | 
                                                        |
| 252 | + $chksum ^= ord( $rawdata[$alias] );  | 
                                                        |
| 253 | + }  | 
                                                        |
| 254 | + // perform XOR for NMEA checksum  | 
                                                        |
| 244 | 255 |  		if ( $chksum == $dcs ) { // NMEA checksum pass | 
                                                        
| 245 | 256 |  			$pcs = explode(',', $rawdata); | 
                                                        
| 246 | 257 | // !AI??? identifier  | 
                                                        
| 247 | 258 | $num_seq = (int)$pcs[1]; // number of sequences  | 
                                                        
| 248 | 259 | $seq = (int)$pcs[2]; // get sequence  | 
                                                        
| 249 | 260 | // get msg sequence id  | 
                                                        
| 250 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1  | 
                                                        |
| 251 | - else $msg_sid = (int)$pcs[3]; // multipart message  | 
                                                        |
| 261 | +			if ($pcs[3] == '') { | 
                                                        |
| 262 | + $msg_sid = -1;  | 
                                                        |
| 263 | + }  | 
                                                        |
| 264 | + // non-multipart message, set to -1  | 
                                                        |
| 265 | +			else { | 
                                                        |
| 266 | + $msg_sid = (int)$pcs[3];  | 
                                                        |
| 267 | + }  | 
                                                        |
| 268 | + // multipart message  | 
                                                        |
| 252 | 269 | $ais_ch = $pcs[4]; // get AIS channel  | 
                                                        
| 253 | 270 | // message sequence checking  | 
                                                        
| 254 | 271 |  			if ($num_seq < 1 || $num_seq > 9) { | 
                                                        
@@ -309,10 +326,18 @@ discard block  | 
                                                    ||
| 309 | 326 | //DEBUG echo "[$start $end $tst]\n";  | 
                                                        
| 310 | 327 | $result = $this->process_ais_raw( $tst, "" );  | 
                                                        
| 311 | 328 | $last_pos = $end + 1;  | 
                                                        
| 312 | - } else break;  | 
                                                        |
| 329 | +			} else { | 
                                                        |
| 330 | + break;  | 
                                                        |
| 331 | + }  | 
                                                        |
| 332 | + }  | 
                                                        |
| 333 | +		if ($last_pos > 0) { | 
                                                        |
| 334 | + $cbuf = substr($cbuf, $last_pos);  | 
                                                        |
| 313 | 335 | }  | 
                                                        
| 314 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...  | 
                                                        |
| 315 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...  | 
                                                        |
| 336 | + // move...  | 
                                                        |
| 337 | +		if (strlen($cbuf) > 1024) { | 
                                                        |
| 338 | + $cbuf = "";  | 
                                                        |
| 339 | + }  | 
                                                        |
| 340 | + // prevent overflow simple mode...  | 
                                                        |
| 316 | 341 | return $result;  | 
                                                        
| 317 | 342 | }  | 
                                                        
| 318 | 343 | |
@@ -332,7 +357,9 @@ discard block  | 
                                                    ||
| 332 | 357 |  		if ($lat<0.0) { | 
                                                        
| 333 | 358 | $lat = -$lat;  | 
                                                        
| 334 | 359 | $neg=true;  | 
                                                        
| 335 | - } else $neg=false;  | 
                                                        |
| 360 | +		} else { | 
                                                        |
| 361 | + $neg=false;  | 
                                                        |
| 362 | + }  | 
                                                        |
| 336 | 363 | $latd = 0x00000000;  | 
                                                        
| 337 | 364 | $latd = intval ($lat * 600000.0);  | 
                                                        
| 338 | 365 |  		if ($neg==true) { | 
                                                        
@@ -348,7 +375,9 @@ discard block  | 
                                                    ||
| 348 | 375 |  		if ($lon<0.0) { | 
                                                        
| 349 | 376 | $lon = -$lon;  | 
                                                        
| 350 | 377 | $neg=true;  | 
                                                        
| 351 | - } else $neg=false;  | 
                                                        |
| 378 | +		} else { | 
                                                        |
| 379 | + $neg=false;  | 
                                                        |
| 380 | + }  | 
                                                        |
| 352 | 381 | $lond = 0x00000000;  | 
                                                        
| 353 | 382 | $lond = intval ($lon * 600000.0);  | 
                                                        
| 354 | 383 |  		if ($neg==true) { | 
                                                        
@@ -361,9 +390,14 @@ discard block  | 
                                                    ||
| 361 | 390 | |
| 362 | 391 |  	private function char2bin($name, $max_len) { | 
                                                        
| 363 | 392 | $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); | 
                                                        |
| 366 | - else $pad = '';  | 
                                                        |
| 393 | +		if ($len > $max_len) { | 
                                                        |
| 394 | + $name = substr($name,0,$max_len);  | 
                                                        |
| 395 | + }  | 
                                                        |
| 396 | +		if ($len < $max_len) { | 
                                                        |
| 397 | +			$pad = str_repeat('0', ($max_len - $len) * 6); | 
                                                        |
| 398 | +		} else { | 
                                                        |
| 399 | + $pad = '';  | 
                                                        |
| 400 | + }  | 
                                                        |
| 367 | 401 | $rv = '';  | 
                                                        
| 368 | 402 | $ais_chars = array(  | 
                                                        
| 369 | 403 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,  | 
                                                        
@@ -375,9 +409,12 @@ discard block  | 
                                                    ||
| 375 | 409 | '<'=>60, '='=>61, '>'=>62, '?'=>63  | 
                                                        
| 376 | 410 | );  | 
                                                        
| 377 | 411 | $_a = str_split($name);  | 
                                                        
| 378 | -		if ($_a) foreach ($_a as $_1) { | 
                                                        |
| 412 | +		if ($_a) { | 
                                                        |
| 413 | +			foreach ($_a as $_1) { | 
                                                        |
| 379 | 414 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];  | 
                                                        
| 380 | - else $dec = 0;  | 
                                                        |
| 415 | +		} else { | 
                                                        |
| 416 | + $dec = 0;  | 
                                                        |
| 417 | + }  | 
                                                        |
| 381 | 418 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);  | 
                                                        
| 382 | 419 | $rv .= $bin;  | 
                                                        
| 383 | 420 | //echo "$_1 $dec ($bin)<br/>";  | 
                                                        
@@ -389,7 +426,9 @@ discard block  | 
                                                    ||
| 389 | 426 | $len_bit = strlen($_enc);  | 
                                                        
| 390 | 427 | $rem6 = $len_bit % 6;  | 
                                                        
| 391 | 428 | $pad6_len = 0;  | 
                                                        
| 392 | - if ($rem6) $pad6_len = 6 - $rem6;  | 
                                                        |
| 429 | +		if ($rem6) { | 
                                                        |
| 430 | + $pad6_len = 6 - $rem6;  | 
                                                        |
| 431 | + }  | 
                                                        |
| 393 | 432 | //echo $pad6_len.'<br>';  | 
                                                        
| 394 | 433 |  		$_enc .= str_repeat("0", $pad6_len); // pad the text... | 
                                                        
| 395 | 434 | $len_enc = strlen($_enc) / 6;  | 
                                                        
@@ -398,8 +437,11 @@ discard block  | 
                                                    ||
| 398 | 437 |  		for ($i=0; $i<$len_enc; $i++) { | 
                                                        
| 399 | 438 | $offset = $i * 6;  | 
                                                        
| 400 | 439 | $dec = bindec(substr($_enc,$offset,6));  | 
                                                        
| 401 | - if ($dec < 40) $dec += 48;  | 
                                                        |
| 402 | - else $dec += 56;  | 
                                                        |
| 440 | +			if ($dec < 40) { | 
                                                        |
| 441 | + $dec += 48;  | 
                                                        |
| 442 | +			} else { | 
                                                        |
| 443 | + $dec += 56;  | 
                                                        |
| 444 | + }  | 
                                                        |
| 403 | 445 | //echo chr($dec)." $dec<br/>";  | 
                                                        
| 404 | 446 | $itu .= chr($dec);  | 
                                                        
| 405 | 447 | }  | 
                                                        
@@ -412,25 +454,41 @@ discard block  | 
                                                    ||
| 412 | 454 | }  | 
                                                        
| 413 | 455 |  		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); | 
                                                        
| 414 | 456 | $lsb = $chksum & 0x0F;  | 
                                                        
| 415 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];  | 
                                                        |
| 416 | - else $lsbc = '0';  | 
                                                        |
| 457 | +		if ($lsb >=0 && $lsb <= 15 ) { | 
                                                        |
| 458 | + $lsbc = $hex_arr[$lsb];  | 
                                                        |
| 459 | +		} else { | 
                                                        |
| 460 | + $lsbc = '0';  | 
                                                        |
| 461 | + }  | 
                                                        |
| 417 | 462 | $msb = (($chksum & 0xF0) >> 4) & 0x0F;  | 
                                                        
| 418 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];  | 
                                                        |
| 419 | - else $msbc = '0';  | 
                                                        |
| 463 | +		if ($msb >=0 && $msb <= 15 ) { | 
                                                        |
| 464 | + $msbc = $hex_arr[$msb];  | 
                                                        |
| 465 | +		} else { | 
                                                        |
| 466 | + $msbc = '0';  | 
                                                        |
| 467 | + }  | 
                                                        |
| 420 | 468 |  		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; | 
                                                        
| 421 | 469 | return $itu;  | 
                                                        
| 422 | 470 | }  | 
                                                        
| 423 | 471 | |
| 424 | 472 |  	public function parse($buffer) { | 
                                                        
| 425 | 473 | $data = $this->process_ais_buf($buffer);  | 
                                                        
| 426 | - if (!is_object($data)) return array();  | 
                                                        |
| 427 | - if ($data->lon != 0) $result['longitude'] = $data->lon;  | 
                                                        |
| 428 | - if ($data->lat != 0) $result['latitude'] = $data->lat;  | 
                                                        |
| 474 | +		if (!is_object($data)) { | 
                                                        |
| 475 | + return array();  | 
                                                        |
| 476 | + }  | 
                                                        |
| 477 | +		if ($data->lon != 0) { | 
                                                        |
| 478 | + $result['longitude'] = $data->lon;  | 
                                                        |
| 479 | + }  | 
                                                        |
| 480 | +		if ($data->lat != 0) { | 
                                                        |
| 481 | + $result['latitude'] = $data->lat;  | 
                                                        |
| 482 | + }  | 
                                                        |
| 429 | 483 | $result['ident'] = trim($data->name);  | 
                                                        
| 430 | 484 | $result['timestamp'] = $data->ts;  | 
                                                        
| 431 | 485 | $result['mmsi'] = $data->mmsi;  | 
                                                        
| 432 | - if ($data->sog != -1.0) $result['speed'] = $data->sog;  | 
                                                        |
| 433 | - if ($data->cog != 0) $result['heading'] = $data->cog;  | 
                                                        |
| 486 | +		if ($data->sog != -1.0) { | 
                                                        |
| 487 | + $result['speed'] = $data->sog;  | 
                                                        |
| 488 | + }  | 
                                                        |
| 489 | +		if ($data->cog != 0) { | 
                                                        |
| 490 | + $result['heading'] = $data->cog;  | 
                                                        |
| 491 | + }  | 
                                                        |
| 434 | 492 | /*  | 
                                                        
| 435 | 493 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg  | 
                                                        
| 436 | 494 | $ro->id = bindec(substr($_aisdata,0,6));  | 
                                                        
@@ -444,15 +502,27 @@ discard block  | 
                                                    ||
| 444 | 502 | $start = strpos($buffer,"VDM");  | 
                                                        
| 445 | 503 | $tst = substr($buffer, $start - 3);  | 
                                                        
| 446 | 504 | $data = $this->process_ais_raw( $tst, "" );  | 
                                                        
| 447 | - if (!is_object($data)) return array();  | 
                                                        |
| 448 | - if ($data->lon != 0) $result['longitude'] = $data->lon;  | 
                                                        |
| 449 | - if ($data->lat != 0) $result['latitude'] = $data->lat;  | 
                                                        |
| 505 | +		if (!is_object($data)) { | 
                                                        |
| 506 | + return array();  | 
                                                        |
| 507 | + }  | 
                                                        |
| 508 | +		if ($data->lon != 0) { | 
                                                        |
| 509 | + $result['longitude'] = $data->lon;  | 
                                                        |
| 510 | + }  | 
                                                        |
| 511 | +		if ($data->lat != 0) { | 
                                                        |
| 512 | + $result['latitude'] = $data->lat;  | 
                                                        |
| 513 | + }  | 
                                                        |
| 450 | 514 |  		$result['ident'] = trim(str_replace('@','',$data->name)); | 
                                                        
| 451 | 515 | $result['timestamp'] = $data->ts;  | 
                                                        
| 452 | 516 | $result['mmsi'] = $data->mmsi;  | 
                                                        
| 453 | - if ($data->sog != -1.0) $result['speed'] = $data->sog;  | 
                                                        |
| 454 | - if ($data->cog != 0) $result['heading'] = $data->cog;  | 
                                                        |
| 455 | - if ($data->status != '') $result['status'] = $data->status;  | 
                                                        |
| 517 | +		if ($data->sog != -1.0) { | 
                                                        |
| 518 | + $result['speed'] = $data->sog;  | 
                                                        |
| 519 | + }  | 
                                                        |
| 520 | +		if ($data->cog != 0) { | 
                                                        |
| 521 | + $result['heading'] = $data->cog;  | 
                                                        |
| 522 | + }  | 
                                                        |
| 523 | +		if ($data->status != '') { | 
                                                        |
| 524 | + $result['status'] = $data->status;  | 
                                                        |
| 525 | + }  | 
                                                        |
| 456 | 526 | $result['all'] = (array) $data;  | 
                                                        
| 457 | 527 | /*  | 
                                                        
| 458 | 528 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg  | 
                                                        
@@ -6,6 +6,9 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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;  | 
                                                        
@@ -7,18 +7,18 @@ discard block  | 
                                                    ||
| 7 | 7 | public $latest_schema = 37;  | 
                                                        
| 8 | 8 | |
| 9 | 9 |  	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { | 
                                                        
| 10 | - global $globalDBdriver;  | 
                                                        |
| 11 | -	    if ($dbc === null) { | 
                                                        |
| 10 | + global $globalDBdriver;  | 
                                                        |
| 11 | +		if ($dbc === null) { | 
                                                        |
| 12 | 12 |  		if ($this->db === null && $dbname === null) { | 
                                                        
| 13 | -		    if ($user === null && $pass === null) { | 
                                                        |
| 13 | +			if ($user === null && $pass === null) { | 
                                                        |
| 14 | 14 | $this->createDBConnection();  | 
                                                        
| 15 | -		    } else { | 
                                                        |
| 15 | +			} else { | 
                                                        |
| 16 | 16 | $this->createDBConnection(null,$user,$pass);  | 
                                                        
| 17 | - }  | 
                                                        |
| 17 | + }  | 
                                                        |
| 18 | 18 |  		} else { | 
                                                        
| 19 | - $this->createDBConnection($dbname);  | 
                                                        |
| 19 | + $this->createDBConnection($dbname);  | 
                                                        |
| 20 | 20 | }  | 
                                                        
| 21 | -	    } elseif ($dbname === null || $dbname === 'default') { | 
                                                        |
| 21 | +		} elseif ($dbname === null || $dbname === 'default') { | 
                                                        |
| 22 | 22 | $this->db = $dbc;  | 
                                                        
| 23 | 23 |  		if ($this->connectionExists() === false) { | 
                                                        
| 24 | 24 | /*  | 
                                                        
@@ -28,10 +28,10 @@ discard block  | 
                                                    ||
| 28 | 28 | */  | 
                                                        
| 29 | 29 | $this->createDBConnection();  | 
                                                        
| 30 | 30 | }  | 
                                                        
| 31 | -	    } else { | 
                                                        |
| 31 | +		} else { | 
                                                        |
| 32 | 32 | //$this->connectionExists();  | 
                                                        
| 33 | 33 | $this->dbs[$dbname] = $dbc;  | 
                                                        
| 34 | - }  | 
                                                        |
| 34 | + }  | 
                                                        |
| 35 | 35 | }  | 
                                                        
| 36 | 36 | |
| 37 | 37 |  	public function db() { | 
                                                        
@@ -47,11 +47,11 @@ discard block  | 
                                                    ||
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
| 49 | 49 | /**  | 
                                                        
| 50 | - * Creates the database connection  | 
                                                        |
| 51 | - *  | 
                                                        |
| 52 | - * @return Boolean of the database connection  | 
                                                        |
| 53 | - *  | 
                                                        |
| 54 | - */  | 
                                                        |
| 50 | + * Creates the database connection  | 
                                                        |
| 51 | + *  | 
                                                        |
| 52 | + * @return Boolean of the database connection  | 
                                                        |
| 53 | + *  | 
                                                        |
| 54 | + */  | 
                                                        |
| 55 | 55 | |
| 56 | 56 | public function createDBConnection($DBname = null, $user = null, $pass = null)  | 
                                                        
| 57 | 57 |  	{ | 
                                                        
@@ -148,7 +148,7 @@ discard block  | 
                                                    ||
| 148 | 148 | return false;  | 
                                                        
| 149 | 149 | }  | 
                                                        
| 150 | 150 |  		if($results->rowCount()>0) { | 
                                                        
| 151 | - return true;  | 
                                                        |
| 151 | + return true;  | 
                                                        |
| 152 | 152 | }  | 
                                                        
| 153 | 153 | else return false;  | 
                                                        
| 154 | 154 | }  | 
                                                        
@@ -165,14 +165,14 @@ discard block  | 
                                                    ||
| 165 | 165 | $sum = $sum->fetchColumn(0);  | 
                                                        
| 166 | 166 | } else $sum = 0;  | 
                                                        
| 167 | 167 |  			if (intval($sum) !== 2) { | 
                                                        
| 168 | - return false;  | 
                                                        |
| 168 | + return false;  | 
                                                        |
| 169 | 169 | }  | 
                                                        
| 170 | 170 | |
| 171 | 171 |  		} catch(PDOException $e) { | 
                                                        
| 172 | 172 |  			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { | 
                                                        
| 173 | - throw $e;  | 
                                                        |
| 174 | - }  | 
                                                        |
| 175 | - //echo 'error ! '.$e->getMessage();  | 
                                                        |
| 173 | + throw $e;  | 
                                                        |
| 174 | + }  | 
                                                        |
| 175 | + //echo 'error ! '.$e->getMessage();  | 
                                                        |
| 176 | 176 | return false;  | 
                                                        
| 177 | 177 | }  | 
                                                        
| 178 | 178 | return true;  | 
                                                        
@@ -276,8 +276,8 @@ discard block  | 
                                                    ||
| 276 | 276 | $version = 0;  | 
                                                        
| 277 | 277 |  		if ($this->tableExists('aircraft')) { | 
                                                        
| 278 | 278 |  			if (!$this->tableExists('config')) { | 
                                                        
| 279 | - $version = '1';  | 
                                                        |
| 280 | - return $version;  | 
                                                        |
| 279 | + $version = '1';  | 
                                                        |
| 280 | + return $version;  | 
                                                        |
| 281 | 281 |  			} else { | 
                                                        
| 282 | 282 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";  | 
                                                        
| 283 | 283 |  				try { | 
                                                        
@@ -298,8 +298,8 @@ discard block  | 
                                                    ||
| 298 | 298 | * @return Boolean if latest version or not  | 
                                                        
| 299 | 299 | */  | 
                                                        
| 300 | 300 |  	public function latest() { | 
                                                        
| 301 | - if ($this->check_schema_version() == $this->latest_schema) return true;  | 
                                                        |
| 302 | - else return false;  | 
                                                        |
| 301 | + if ($this->check_schema_version() == $this->latest_schema) return true;  | 
                                                        |
| 302 | + else return false;  | 
                                                        |
| 303 | 303 | }  | 
                                                        
| 304 | 304 | |
| 305 | 305 | }  | 
                                                        
@@ -1,19 +1,19 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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);  | 
                                                        
@@ -15,7 +15,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | */  | 
                                                        
@@ -13,10 +13,10 @@ discard block  | 
                                                    ||
| 13 | 13 | }  | 
                                                        
| 14 | 14 | |
| 15 | 15 | /**  | 
                                                        
| 16 | - * Get SQL query part for filter used  | 
                                                        |
| 17 | - * @param Array $filter the filter  | 
                                                        |
| 18 | - * @return Array the SQL part  | 
                                                        |
| 19 | - */  | 
                                                        |
| 16 | + * Get SQL query part for filter used  | 
                                                        |
| 17 | + * @param Array $filter the filter  | 
                                                        |
| 18 | + * @return Array the SQL part  | 
                                                        |
| 19 | + */  | 
                                                        |
| 20 | 20 | |
| 21 | 21 |  	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        
| 22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
@@ -80,14 +80,14 @@ discard block  | 
                                                    ||
| 80 | 80 | }  | 
                                                        
| 81 | 81 | |
| 82 | 82 | /**  | 
                                                        
| 83 | - * Executes the SQL statements to get the spotter information  | 
                                                        |
| 84 | - *  | 
                                                        |
| 85 | - * @param String $query the SQL query  | 
                                                        |
| 86 | - * @param Array $params parameter of the query  | 
                                                        |
| 87 | - * @param String $limitQuery the limit query  | 
                                                        |
| 88 | - * @return Array the spotter information  | 
                                                        |
| 89 | - *  | 
                                                        |
| 90 | - */  | 
                                                        |
| 83 | + * Executes the SQL statements to get the spotter information  | 
                                                        |
| 84 | + *  | 
                                                        |
| 85 | + * @param String $query the SQL query  | 
                                                        |
| 86 | + * @param Array $params parameter of the query  | 
                                                        |
| 87 | + * @param String $limitQuery the limit query  | 
                                                        |
| 88 | + * @return Array the spotter information  | 
                                                        |
| 89 | + *  | 
                                                        |
| 90 | + */  | 
                                                        |
| 91 | 91 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)  | 
                                                        
| 92 | 92 |  	{ | 
                                                        
| 93 | 93 |  		date_default_timezone_set('UTC'); | 
                                                        
@@ -199,11 +199,11 @@ discard block  | 
                                                    ||
| 199 | 199 | |
| 200 | 200 | |
| 201 | 201 | /**  | 
                                                        
| 202 | - * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 203 | - *  | 
                                                        |
| 204 | - * @return Array the spotter information  | 
                                                        |
| 205 | - *  | 
                                                        |
| 206 | - */  | 
                                                        |
| 202 | + * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 203 | + *  | 
                                                        |
| 204 | + * @return Array the spotter information  | 
                                                        |
| 205 | + *  | 
                                                        |
| 206 | + */  | 
                                                        |
| 207 | 207 | public function getLatestMarineData($limit = '', $sort = '', $filter = array())  | 
                                                        
| 208 | 208 |  	{ | 
                                                        
| 209 | 209 | global $global_query;  | 
                                                        
@@ -261,11 +261,11 @@ discard block  | 
                                                    ||
| 261 | 261 | }  | 
                                                        
| 262 | 262 | |
| 263 | 263 | /**  | 
                                                        
| 264 | - * Gets all the spotter information based on the callsign  | 
                                                        |
| 265 | - *  | 
                                                        |
| 266 | - * @return Array the spotter information  | 
                                                        |
| 267 | - *  | 
                                                        |
| 268 | - */  | 
                                                        |
| 264 | + * Gets all the spotter information based on the callsign  | 
                                                        |
| 265 | + *  | 
                                                        |
| 266 | + * @return Array the spotter information  | 
                                                        |
| 267 | + *  | 
                                                        |
| 268 | + */  | 
                                                        |
| 269 | 269 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())  | 
                                                        
| 270 | 270 |  	{ | 
                                                        
| 271 | 271 | global $global_query;  | 
                                                        
@@ -376,12 +376,12 @@ discard block  | 
                                                    ||
| 376 | 376 | |
| 377 | 377 | |
| 378 | 378 | /**  | 
                                                        
| 379 | - * Gets all source name  | 
                                                        |
| 380 | - *  | 
                                                        |
| 381 | - * @param String type format of source  | 
                                                        |
| 382 | - * @return Array list of source name  | 
                                                        |
| 383 | - *  | 
                                                        |
| 384 | - */  | 
                                                        |
| 379 | + * Gets all source name  | 
                                                        |
| 380 | + *  | 
                                                        |
| 381 | + * @param String type format of source  | 
                                                        |
| 382 | + * @return Array list of source name  | 
                                                        |
| 383 | + *  | 
                                                        |
| 384 | + */  | 
                                                        |
| 385 | 385 | public function getAllSourceName($type = '',$filters = array())  | 
                                                        
| 386 | 386 |  	{ | 
                                                        
| 387 | 387 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
@@ -411,11 +411,11 @@ discard block  | 
                                                    ||
| 411 | 411 | |
| 412 | 412 | |
| 413 | 413 | /**  | 
                                                        
| 414 | - * Gets a list of all idents/callsigns  | 
                                                        |
| 415 | - *  | 
                                                        |
| 416 | - * @return Array list of ident/callsign names  | 
                                                        |
| 417 | - *  | 
                                                        |
| 418 | - */  | 
                                                        |
| 414 | + * Gets a list of all idents/callsigns  | 
                                                        |
| 415 | + *  | 
                                                        |
| 416 | + * @return Array list of ident/callsign names  | 
                                                        |
| 417 | + *  | 
                                                        |
| 418 | + */  | 
                                                        |
| 419 | 419 | public function getAllIdents($filters = array())  | 
                                                        
| 420 | 420 |  	{ | 
                                                        
| 421 | 421 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
@@ -439,11 +439,11 @@ discard block  | 
                                                    ||
| 439 | 439 | }  | 
                                                        
| 440 | 440 | |
| 441 | 441 | /**  | 
                                                        
| 442 | - * Gets all info from a mmsi  | 
                                                        |
| 443 | - *  | 
                                                        |
| 444 | - * @return Array list of mmsi info  | 
                                                        |
| 445 | - *  | 
                                                        |
| 446 | - */  | 
                                                        |
| 442 | + * Gets all info from a mmsi  | 
                                                        |
| 443 | + *  | 
                                                        |
| 444 | + * @return Array list of mmsi info  | 
                                                        |
| 445 | + *  | 
                                                        |
| 446 | + */  | 
                                                        |
| 447 | 447 | public function getIdentity($mmsi)  | 
                                                        
| 448 | 448 |  	{ | 
                                                        
| 449 | 449 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        
@@ -500,18 +500,18 @@ discard block  | 
                                                    ||
| 500 | 500 | |
| 501 | 501 | |
| 502 | 502 | /**  | 
                                                        
| 503 | - * Update ident spotter data  | 
                                                        |
| 504 | - *  | 
                                                        |
| 505 | - * @param String $flightaware_id the ID from flightaware  | 
                                                        |
| 506 | - * @param String $ident the flight ident  | 
                                                        |
| 507 | - * @return String success or false  | 
                                                        |
| 508 | - *  | 
                                                        |
| 509 | - */  | 
                                                        |
| 503 | + * Update ident spotter data  | 
                                                        |
| 504 | + *  | 
                                                        |
| 505 | + * @param String $flightaware_id the ID from flightaware  | 
                                                        |
| 506 | + * @param String $ident the flight ident  | 
                                                        |
| 507 | + * @return String success or false  | 
                                                        |
| 508 | + *  | 
                                                        |
| 509 | + */  | 
                                                        |
| 510 | 510 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)  | 
                                                        
| 511 | 511 |  	{ | 
                                                        
| 512 | 512 | |
| 513 | 513 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';  | 
                                                        
| 514 | -                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); | 
                                                        |
| 514 | +				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); | 
                                                        |
| 515 | 515 | |
| 516 | 516 |  		try { | 
                                                        
| 517 | 517 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -524,18 +524,18 @@ discard block  | 
                                                    ||
| 524 | 524 | |
| 525 | 525 | }  | 
                                                        
| 526 | 526 | /**  | 
                                                        
| 527 | - * Update latest spotter data  | 
                                                        |
| 528 | - *  | 
                                                        |
| 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 | - *  | 
                                                        |
| 534 | - */  | 
                                                        |
| 527 | + * Update latest spotter data  | 
                                                        |
| 528 | + *  | 
                                                        |
| 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 | + *  | 
                                                        |
| 534 | + */  | 
                                                        |
| 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);  | 
                                                        
@@ -549,31 +549,31 @@ discard block  | 
                                                    ||
| 549 | 549 | }  | 
                                                        
| 550 | 550 | |
| 551 | 551 | /**  | 
                                                        
| 552 | - * Adds a new spotter data  | 
                                                        |
| 553 | - *  | 
                                                        |
| 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 | - */  | 
                                                        |
| 552 | + * Adds a new spotter data  | 
                                                        |
| 553 | + *  | 
                                                        |
| 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 | + */  | 
                                                        |
| 577 | 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;  | 
                                                        
@@ -657,16 +657,16 @@ discard block  | 
                                                    ||
| 657 | 657 | $type = filter_var($type,FILTER_SANITIZE_STRING);  | 
                                                        
| 658 | 658 | $status = filter_var($status,FILTER_SANITIZE_STRING);  | 
                                                        
| 659 | 659 | |
| 660 | -                if ($latitude == '' && $longitude == '') { | 
                                                        |
| 661 | - $latitude = 0;  | 
                                                        |
| 662 | - $longitude = 0;  | 
                                                        |
| 663 | - }  | 
                                                        |
| 664 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;  | 
                                                        |
| 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)  | 
                                                        |
| 660 | +				if ($latitude == '' && $longitude == '') { | 
                                                        |
| 661 | + $latitude = 0;  | 
                                                        |
| 662 | + $longitude = 0;  | 
                                                        |
| 663 | + }  | 
                                                        |
| 664 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;  | 
                                                        |
| 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)  | 
                                                        |
| 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 | |
@@ -674,7 +674,7 @@ discard block  | 
                                                    ||
| 674 | 674 | $sth->execute($query_values);  | 
                                                        
| 675 | 675 | $this->db = null;  | 
                                                        
| 676 | 676 |  		} catch (PDOException $e) { | 
                                                        
| 677 | - return "error : ".$e->getMessage();  | 
                                                        |
| 677 | + return "error : ".$e->getMessage();  | 
                                                        |
| 678 | 678 | }  | 
                                                        
| 679 | 679 | |
| 680 | 680 | return "success";  | 
                                                        
@@ -683,11 +683,11 @@ discard block  | 
                                                    ||
| 683 | 683 | |
| 684 | 684 | |
| 685 | 685 | /**  | 
                                                        
| 686 | - * Gets the aircraft ident within the last hour  | 
                                                        |
| 687 | - *  | 
                                                        |
| 688 | - * @return String the ident  | 
                                                        |
| 689 | - *  | 
                                                        |
| 690 | - */  | 
                                                        |
| 686 | + * Gets the aircraft ident within the last hour  | 
                                                        |
| 687 | + *  | 
                                                        |
| 688 | + * @return String the ident  | 
                                                        |
| 689 | + *  | 
                                                        |
| 690 | + */  | 
                                                        |
| 691 | 691 | public function getIdentFromLastHour($ident)  | 
                                                        
| 692 | 692 |  	{ | 
                                                        
| 693 | 693 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -703,11 +703,11 @@ discard block  | 
                                                    ||
| 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'";  | 
                                                        
| 705 | 705 |  			$query_data = array(':ident' => $ident); | 
                                                        
| 706 | - }  | 
                                                        |
| 706 | + }  | 
                                                        |
| 707 | 707 | |
| 708 | 708 | $sth = $this->db->prepare($query);  | 
                                                        
| 709 | 709 | $sth->execute($query_data);  | 
                                                        
| 710 | - $ident_result='';  | 
                                                        |
| 710 | + $ident_result='';  | 
                                                        |
| 711 | 711 | while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        
| 712 | 712 |  		{ | 
                                                        
| 713 | 713 | $ident_result = $row['ident'];  | 
                                                        
@@ -718,11 +718,11 @@ discard block  | 
                                                    ||
| 718 | 718 | |
| 719 | 719 | |
| 720 | 720 | /**  | 
                                                        
| 721 | - * Gets the aircraft data from the last 20 seconds  | 
                                                        |
| 722 | - *  | 
                                                        |
| 723 | - * @return Array the spotter data  | 
                                                        |
| 724 | - *  | 
                                                        |
| 725 | - */  | 
                                                        |
| 721 | + * Gets the aircraft data from the last 20 seconds  | 
                                                        |
| 722 | + *  | 
                                                        |
| 723 | + * @return Array the spotter data  | 
                                                        |
| 724 | + *  | 
                                                        |
| 725 | + */  | 
                                                        |
| 726 | 726 | public function getRealTimeData($q = '')  | 
                                                        
| 727 | 727 |  	{ | 
                                                        
| 728 | 728 | global $globalDBdriver;  | 
                                                        
@@ -760,11 +760,11 @@ discard block  | 
                                                    ||
| 760 | 760 | |
| 761 | 761 | |
| 762 | 762 | /**  | 
                                                        
| 763 | - * Gets all number of flight over countries  | 
                                                        |
| 764 | - *  | 
                                                        |
| 765 | - * @return Array the airline country list  | 
                                                        |
| 766 | - *  | 
                                                        |
| 767 | - */  | 
                                                        |
| 763 | + * Gets all number of flight over countries  | 
                                                        |
| 764 | + *  | 
                                                        |
| 765 | + * @return Array the airline country list  | 
                                                        |
| 766 | + *  | 
                                                        |
| 767 | + */  | 
                                                        |
| 768 | 768 | /*  | 
                                                        
| 769 | 769 | public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())  | 
                                                        
| 770 | 770 |  	{ | 
                                                        
@@ -815,11 +815,11 @@ discard block  | 
                                                    ||
| 815 | 815 | |
| 816 | 816 | |
| 817 | 817 | /**  | 
                                                        
| 818 | - * Gets all callsigns that have flown over  | 
                                                        |
| 819 | - *  | 
                                                        |
| 820 | - * @return Array the callsign list  | 
                                                        |
| 821 | - *  | 
                                                        |
| 822 | - */  | 
                                                        |
| 818 | + * Gets all callsigns that have flown over  | 
                                                        |
| 819 | + *  | 
                                                        |
| 820 | + * @return Array the callsign list  | 
                                                        |
| 821 | + *  | 
                                                        |
| 822 | + */  | 
                                                        |
| 823 | 823 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')  | 
                                                        
| 824 | 824 |  	{ | 
                                                        
| 825 | 825 | global $globalDBdriver;  | 
                                                        
@@ -886,11 +886,11 @@ discard block  | 
                                                    ||
| 886 | 886 | |
| 887 | 887 | |
| 888 | 888 | /**  | 
                                                        
| 889 | - * Counts all dates  | 
                                                        |
| 890 | - *  | 
                                                        |
| 891 | - * @return Array the date list  | 
                                                        |
| 892 | - *  | 
                                                        |
| 893 | - */  | 
                                                        |
| 889 | + * Counts all dates  | 
                                                        |
| 890 | + *  | 
                                                        |
| 891 | + * @return Array the date list  | 
                                                        |
| 892 | + *  | 
                                                        |
| 893 | + */  | 
                                                        |
| 894 | 894 | public function countAllDates($filters = array())  | 
                                                        
| 895 | 895 |  	{ | 
                                                        
| 896 | 896 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -936,11 +936,11 @@ discard block  | 
                                                    ||
| 936 | 936 | |
| 937 | 937 | |
| 938 | 938 | /**  | 
                                                        
| 939 | - * Counts all dates during the last 7 days  | 
                                                        |
| 940 | - *  | 
                                                        |
| 941 | - * @return Array the date list  | 
                                                        |
| 942 | - *  | 
                                                        |
| 943 | - */  | 
                                                        |
| 939 | + * Counts all dates during the last 7 days  | 
                                                        |
| 940 | + *  | 
                                                        |
| 941 | + * @return Array the date list  | 
                                                        |
| 942 | + *  | 
                                                        |
| 943 | + */  | 
                                                        |
| 944 | 944 | public function countAllDatesLast7Days($filters = array())  | 
                                                        
| 945 | 945 |  	{ | 
                                                        
| 946 | 946 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -962,7 +962,7 @@ discard block  | 
                                                    ||
| 962 | 962 | $query .= " GROUP BY date_name  | 
                                                        
| 963 | 963 | ORDER BY date_name ASC";  | 
                                                        
| 964 | 964 |  			$query_data = array(':offset' => $offset); | 
                                                        
| 965 | - }  | 
                                                        |
| 965 | + }  | 
                                                        |
| 966 | 966 | |
| 967 | 967 | $sth = $this->db->prepare($query);  | 
                                                        
| 968 | 968 | $sth->execute($query_data);  | 
                                                        
@@ -982,11 +982,11 @@ discard block  | 
                                                    ||
| 982 | 982 | }  | 
                                                        
| 983 | 983 | |
| 984 | 984 | /**  | 
                                                        
| 985 | - * Counts all dates during the last month  | 
                                                        |
| 986 | - *  | 
                                                        |
| 987 | - * @return Array the date list  | 
                                                        |
| 988 | - *  | 
                                                        |
| 989 | - */  | 
                                                        |
| 985 | + * Counts all dates during the last month  | 
                                                        |
| 986 | + *  | 
                                                        |
| 987 | + * @return Array the date list  | 
                                                        |
| 988 | + *  | 
                                                        |
| 989 | + */  | 
                                                        |
| 990 | 990 | public function countAllDatesLastMonth($filters = array())  | 
                                                        
| 991 | 991 |  	{ | 
                                                        
| 992 | 992 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1008,7 +1008,7 @@ discard block  | 
                                                    ||
| 1008 | 1008 | $query .= " GROUP BY date_name  | 
                                                        
| 1009 | 1009 | ORDER BY date_name ASC";  | 
                                                        
| 1010 | 1010 |  			$query_data = array(':offset' => $offset); | 
                                                        
| 1011 | - }  | 
                                                        |
| 1011 | + }  | 
                                                        |
| 1012 | 1012 | |
| 1013 | 1013 | $sth = $this->db->prepare($query);  | 
                                                        
| 1014 | 1014 | $sth->execute($query_data);  | 
                                                        
@@ -1030,11 +1030,11 @@ discard block  | 
                                                    ||
| 1030 | 1030 | |
| 1031 | 1031 | |
| 1032 | 1032 | /**  | 
                                                        
| 1033 | - * Counts all month  | 
                                                        |
| 1034 | - *  | 
                                                        |
| 1035 | - * @return Array the month list  | 
                                                        |
| 1036 | - *  | 
                                                        |
| 1037 | - */  | 
                                                        |
| 1033 | + * Counts all month  | 
                                                        |
| 1034 | + *  | 
                                                        |
| 1035 | + * @return Array the month list  | 
                                                        |
| 1036 | + *  | 
                                                        |
| 1037 | + */  | 
                                                        |
| 1038 | 1038 | public function countAllMonths($filters = array())  | 
                                                        
| 1039 | 1039 |  	{ | 
                                                        
| 1040 | 1040 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1079,11 +1079,11 @@ discard block  | 
                                                    ||
| 1079 | 1079 | |
| 1080 | 1080 | |
| 1081 | 1081 | /**  | 
                                                        
| 1082 | - * Counts all dates during the last year  | 
                                                        |
| 1083 | - *  | 
                                                        |
| 1084 | - * @return Array the date list  | 
                                                        |
| 1085 | - *  | 
                                                        |
| 1086 | - */  | 
                                                        |
| 1082 | + * Counts all dates during the last year  | 
                                                        |
| 1083 | + *  | 
                                                        |
| 1084 | + * @return Array the date list  | 
                                                        |
| 1085 | + *  | 
                                                        |
| 1086 | + */  | 
                                                        |
| 1087 | 1087 | public function countAllMonthsLastYear($filters)  | 
                                                        
| 1088 | 1088 |  	{ | 
                                                        
| 1089 | 1089 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1105,7 +1105,7 @@ discard block  | 
                                                    ||
| 1105 | 1105 | $query .= " GROUP BY year_name, month_name  | 
                                                        
| 1106 | 1106 | ORDER BY year_name, month_name ASC";  | 
                                                        
| 1107 | 1107 |  			$query_data = array(':offset' => $offset); | 
                                                        
| 1108 | - }  | 
                                                        |
| 1108 | + }  | 
                                                        |
| 1109 | 1109 | |
| 1110 | 1110 | $sth = $this->db->prepare($query);  | 
                                                        
| 1111 | 1111 | $sth->execute($query_data);  | 
                                                        
@@ -1128,11 +1128,11 @@ discard block  | 
                                                    ||
| 1128 | 1128 | |
| 1129 | 1129 | |
| 1130 | 1130 | /**  | 
                                                        
| 1131 | - * Counts all hours  | 
                                                        |
| 1132 | - *  | 
                                                        |
| 1133 | - * @return Array the hour list  | 
                                                        |
| 1134 | - *  | 
                                                        |
| 1135 | - */  | 
                                                        |
| 1131 | + * Counts all hours  | 
                                                        |
| 1132 | + *  | 
                                                        |
| 1133 | + * @return Array the hour list  | 
                                                        |
| 1134 | + *  | 
                                                        |
| 1135 | + */  | 
                                                        |
| 1136 | 1136 | public function countAllHours($orderby,$filters = array())  | 
                                                        
| 1137 | 1137 |  	{ | 
                                                        
| 1138 | 1138 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1195,11 +1195,11 @@ discard block  | 
                                                    ||
| 1195 | 1195 | |
| 1196 | 1196 | |
| 1197 | 1197 | /**  | 
                                                        
| 1198 | - * Counts all hours by date  | 
                                                        |
| 1199 | - *  | 
                                                        |
| 1200 | - * @return Array the hour list  | 
                                                        |
| 1201 | - *  | 
                                                        |
| 1202 | - */  | 
                                                        |
| 1198 | + * Counts all hours by date  | 
                                                        |
| 1199 | + *  | 
                                                        |
| 1200 | + * @return Array the hour list  | 
                                                        |
| 1201 | + *  | 
                                                        |
| 1202 | + */  | 
                                                        |
| 1203 | 1203 | public function countAllHoursByDate($date, $filters = array())  | 
                                                        
| 1204 | 1204 |  	{ | 
                                                        
| 1205 | 1205 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1243,11 +1243,11 @@ discard block  | 
                                                    ||
| 1243 | 1243 | |
| 1244 | 1244 | |
| 1245 | 1245 | /**  | 
                                                        
| 1246 | - * Counts all hours by a ident/callsign  | 
                                                        |
| 1247 | - *  | 
                                                        |
| 1248 | - * @return Array the hour list  | 
                                                        |
| 1249 | - *  | 
                                                        |
| 1250 | - */  | 
                                                        |
| 1246 | + * Counts all hours by a ident/callsign  | 
                                                        |
| 1247 | + *  | 
                                                        |
| 1248 | + * @return Array the hour list  | 
                                                        |
| 1249 | + *  | 
                                                        |
| 1250 | + */  | 
                                                        |
| 1251 | 1251 | public function countAllHoursByIdent($ident, $filters = array())  | 
                                                        
| 1252 | 1252 |  	{ | 
                                                        
| 1253 | 1253 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1292,11 +1292,11 @@ discard block  | 
                                                    ||
| 1292 | 1292 | |
| 1293 | 1293 | |
| 1294 | 1294 | /**  | 
                                                        
| 1295 | - * Counts all flights that have flown over  | 
                                                        |
| 1296 | - *  | 
                                                        |
| 1297 | - * @return Integer the number of flights  | 
                                                        |
| 1298 | - *  | 
                                                        |
| 1299 | - */  | 
                                                        |
| 1295 | + * Counts all flights that have flown over  | 
                                                        |
| 1296 | + *  | 
                                                        |
| 1297 | + * @return Integer the number of flights  | 
                                                        |
| 1298 | + *  | 
                                                        |
| 1299 | + */  | 
                                                        |
| 1300 | 1300 | public function countOverallTracked($filters = array(),$year = '',$month = '')  | 
                                                        
| 1301 | 1301 |  	{ | 
                                                        
| 1302 | 1302 | global $globalDBdriver;  | 
                                                        
@@ -1331,11 +1331,11 @@ discard block  | 
                                                    ||
| 1331 | 1331 | |
| 1332 | 1332 | |
| 1333 | 1333 | /**  | 
                                                        
| 1334 | - * Counts all hours of today  | 
                                                        |
| 1335 | - *  | 
                                                        |
| 1336 | - * @return Array the hour list  | 
                                                        |
| 1337 | - *  | 
                                                        |
| 1338 | - */  | 
                                                        |
| 1334 | + * Counts all hours of today  | 
                                                        |
| 1335 | + *  | 
                                                        |
| 1336 | + * @return Array the hour list  | 
                                                        |
| 1337 | + *  | 
                                                        |
| 1338 | + */  | 
                                                        |
| 1339 | 1339 | public function countAllHoursFromToday($filters = array())  | 
                                                        
| 1340 | 1340 |  	{ | 
                                                        
| 1341 | 1341 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1375,12 +1375,12 @@ discard block  | 
                                                    ||
| 1375 | 1375 | }  | 
                                                        
| 1376 | 1376 | |
| 1377 | 1377 | |
| 1378 | - /**  | 
                                                        |
| 1379 | - * Gets the Barrie Spotter ID based on the FlightAware ID  | 
                                                        |
| 1380 | - *  | 
                                                        |
| 1381 | - * @return Integer the Barrie Spotter ID  | 
                                                        |
| 1378 | + /**  | 
                                                        |
| 1379 | + * Gets the Barrie Spotter ID based on the FlightAware ID  | 
                                                        |
| 1380 | + *  | 
                                                        |
| 1381 | + * @return Integer the Barrie Spotter ID  | 
                                                        |
| 1382 | 1382 | q *  | 
                                                        
| 1383 | - */  | 
                                                        |
| 1383 | + */  | 
                                                        |
| 1384 | 1384 | public function getMarineIDBasedOnFamMarineID($fammarine_id)  | 
                                                        
| 1385 | 1385 |  	{ | 
                                                        
| 1386 | 1386 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);  | 
                                                        
@@ -1401,13 +1401,13 @@ discard block  | 
                                                    ||
| 1401 | 1401 | |
| 1402 | 1402 | |
| 1403 | 1403 | /**  | 
                                                        
| 1404 | - * Parses a date string  | 
                                                        |
| 1405 | - *  | 
                                                        |
| 1406 | - * @param String $dateString the date string  | 
                                                        |
| 1407 | - * @param String $timezone the timezone of a user  | 
                                                        |
| 1408 | - * @return Array the time information  | 
                                                        |
| 1409 | - *  | 
                                                        |
| 1410 | - */  | 
                                                        |
| 1404 | + * Parses a date string  | 
                                                        |
| 1405 | + *  | 
                                                        |
| 1406 | + * @param String $dateString the date string  | 
                                                        |
| 1407 | + * @param String $timezone the timezone of a user  | 
                                                        |
| 1408 | + * @return Array the time information  | 
                                                        |
| 1409 | + *  | 
                                                        |
| 1410 | + */  | 
                                                        |
| 1411 | 1411 | public function parseDateString($dateString, $timezone = '')  | 
                                                        
| 1412 | 1412 |  	{ | 
                                                        
| 1413 | 1413 | $time_array = array();  | 
                                                        
@@ -1440,12 +1440,12 @@ discard block  | 
                                                    ||
| 1440 | 1440 | }  | 
                                                        
| 1441 | 1441 | |
| 1442 | 1442 | /**  | 
                                                        
| 1443 | - * Parses the direction degrees to working  | 
                                                        |
| 1444 | - *  | 
                                                        |
| 1445 | - * @param Float $direction the direction in degrees  | 
                                                        |
| 1446 | - * @return Array the direction information  | 
                                                        |
| 1447 | - *  | 
                                                        |
| 1448 | - */  | 
                                                        |
| 1443 | + * Parses the direction degrees to working  | 
                                                        |
| 1444 | + *  | 
                                                        |
| 1445 | + * @param Float $direction the direction in degrees  | 
                                                        |
| 1446 | + * @return Array the direction information  | 
                                                        |
| 1447 | + *  | 
                                                        |
| 1448 | + */  | 
                                                        |
| 1449 | 1449 | public function parseDirection($direction = 0)  | 
                                                        
| 1450 | 1450 |  	{ | 
                                                        
| 1451 | 1451 | if ($direction == '') $direction = 0;  | 
                                                        
@@ -1524,12 +1524,12 @@ discard block  | 
                                                    ||
| 1524 | 1524 | |
| 1525 | 1525 | |
| 1526 | 1526 | /**  | 
                                                        
| 1527 | - * Gets Country from latitude/longitude  | 
                                                        |
| 1528 | - *  | 
                                                        |
| 1529 | - * @param Float $latitude latitute of the flight  | 
                                                        |
| 1530 | - * @param Float $longitude longitute of the flight  | 
                                                        |
| 1531 | - * @return String the countrie  | 
                                                        |
| 1532 | - */  | 
                                                        |
| 1527 | + * Gets Country from latitude/longitude  | 
                                                        |
| 1528 | + *  | 
                                                        |
| 1529 | + * @param Float $latitude latitute of the flight  | 
                                                        |
| 1530 | + * @param Float $longitude longitute of the flight  | 
                                                        |
| 1531 | + * @return String the countrie  | 
                                                        |
| 1532 | + */  | 
                                                        |
| 1533 | 1533 | public function getCountryFromLatitudeLongitude($latitude,$longitude)  | 
                                                        
| 1534 | 1534 |  	{ | 
                                                        
| 1535 | 1535 | global $globalDBdriver, $globalDebug;  | 
                                                        
@@ -1566,11 +1566,11 @@ discard block  | 
                                                    ||
| 1566 | 1566 | }  | 
                                                        
| 1567 | 1567 | |
| 1568 | 1568 | /**  | 
                                                        
| 1569 | - * Gets Country from iso2  | 
                                                        |
| 1570 | - *  | 
                                                        |
| 1571 | - * @param String $iso2 ISO2 country code  | 
                                                        |
| 1572 | - * @return String the countrie  | 
                                                        |
| 1573 | - */  | 
                                                        |
| 1569 | + * Gets Country from iso2  | 
                                                        |
| 1570 | + *  | 
                                                        |
| 1571 | + * @param String $iso2 ISO2 country code  | 
                                                        |
| 1572 | + * @return String the countrie  | 
                                                        |
| 1573 | + */  | 
                                                        |
| 1574 | 1574 | public function getCountryFromISO2($iso2)  | 
                                                        
| 1575 | 1575 |  	{ | 
                                                        
| 1576 | 1576 | global $globalDBdriver, $globalDebug;  | 
                                                        
@@ -1599,12 +1599,12 @@ discard block  | 
                                                    ||
| 1599 | 1599 | |
| 1600 | 1600 | |
| 1601 | 1601 | /**  | 
                                                        
| 1602 | - * Gets the short url from bit.ly  | 
                                                        |
| 1603 | - *  | 
                                                        |
| 1604 | - * @param String $url the full url  | 
                                                        |
| 1605 | - * @return String the bit.ly url  | 
                                                        |
| 1606 | - *  | 
                                                        |
| 1607 | - */  | 
                                                        |
| 1602 | + * Gets the short url from bit.ly  | 
                                                        |
| 1603 | + *  | 
                                                        |
| 1604 | + * @param String $url the full url  | 
                                                        |
| 1605 | + * @return String the bit.ly url  | 
                                                        |
| 1606 | + *  | 
                                                        |
| 1607 | + */  | 
                                                        |
| 1608 | 1608 | public function getBitlyURL($url)  | 
                                                        
| 1609 | 1609 |  	{ | 
                                                        
| 1610 | 1610 | global $globalBitlyAccessToken;  | 
                                                        
@@ -4,7 +4,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | |
@@ -31,7 +31,9 @@ discard block  | 
                                                    ||
| 31 | 31 |  		if (isset($filter[0]['source'])) { | 
                                                        
| 32 | 32 | $filters = array_merge($filters,$filter);  | 
                                                        
| 33 | 33 | }  | 
                                                        
| 34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 34 | +		if (is_array($globalFilter)) { | 
                                                        |
| 35 | + $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 36 | + }  | 
                                                        |
| 35 | 37 | $filter_query_join = '';  | 
                                                        
| 36 | 38 | $filter_query_where = '';  | 
                                                        
| 37 | 39 |  		foreach($filters as $flt) { | 
                                                        
@@ -70,8 +72,11 @@ discard block  | 
                                                    ||
| 70 | 72 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";  | 
                                                        
| 71 | 73 | }  | 
                                                        
| 72 | 74 | }  | 
                                                        
| 73 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';  | 
                                                        |
| 74 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';  | 
                                                        |
| 75 | +		if ($filter_query_where == '' && $where) { | 
                                                        |
| 76 | + $filter_query_where = ' WHERE';  | 
                                                        |
| 77 | +		} elseif ($filter_query_where != '' && $and) { | 
                                                        |
| 78 | + $filter_query_where .= ' AND';  | 
                                                        |
| 79 | + }  | 
                                                        |
| 75 | 80 |  		if ($filter_query_where != '') { | 
                                                        
| 76 | 81 |  			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                        
| 77 | 82 | }  | 
                                                        
@@ -125,25 +130,40 @@ discard block  | 
                                                    ||
| 125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_id'];  | 
                                                        
| 126 | 131 |  			} elseif (isset($row['spotter_archive_output_id'])) { | 
                                                        
| 127 | 132 | $temp_array['spotter_id'] = $row['spotter_archive_output_id'];  | 
                                                        
| 128 | - */}  | 
                                                        |
| 129 | -			elseif (isset($row['marineid'])) { | 
                                                        |
| 133 | +			*/} elseif (isset($row['marineid'])) { | 
                                                        |
| 130 | 134 | $temp_array['marineid'] = $row['marineid'];  | 
                                                        
| 131 | 135 |  			} else { | 
                                                        
| 132 | 136 | $temp_array['marineid'] = '';  | 
                                                        
| 133 | 137 | }  | 
                                                        
| 134 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];  | 
                                                        |
| 135 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];  | 
                                                        |
| 136 | - if (isset($row['type'])) $temp_array['type'] = $row['type'];  | 
                                                        |
| 138 | +			if (isset($row['fammarine_id'])) { | 
                                                        |
| 139 | + $temp_array['fammarine_id'] = $row['fammarine_id'];  | 
                                                        |
| 140 | + }  | 
                                                        |
| 141 | +			if (isset($row['mmsi'])) { | 
                                                        |
| 142 | + $temp_array['mmsi'] = $row['mmsi'];  | 
                                                        |
| 143 | + }  | 
                                                        |
| 144 | +			if (isset($row['type'])) { | 
                                                        |
| 145 | + $temp_array['type'] = $row['type'];  | 
                                                        |
| 146 | + }  | 
                                                        |
| 137 | 147 | $temp_array['ident'] = $row['ident'];  | 
                                                        
| 138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];  | 
                                                        |
| 139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];  | 
                                                        |
| 140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];  | 
                                                        |
| 148 | +			if (isset($row['latitude'])) { | 
                                                        |
| 149 | + $temp_array['latitude'] = $row['latitude'];  | 
                                                        |
| 150 | + }  | 
                                                        |
| 151 | +			if (isset($row['longitude'])) { | 
                                                        |
| 152 | + $temp_array['longitude'] = $row['longitude'];  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | +			if (isset($row['format_source'])) { | 
                                                        |
| 155 | + $temp_array['format_source'] = $row['format_source'];  | 
                                                        |
| 156 | + }  | 
                                                        |
| 141 | 157 |  			if (isset($row['heading'])) { | 
                                                        
| 142 | 158 | $temp_array['heading'] = $row['heading'];  | 
                                                        
| 143 | 159 | $heading_direction = $this->parseDirection($row['heading']);  | 
                                                        
| 144 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];  | 
                                                        |
| 160 | +				if (isset($heading_direction[0]['direction_fullname'])) { | 
                                                        |
| 161 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];  | 
                                                        |
| 162 | + }  | 
                                                        |
| 163 | + }  | 
                                                        |
| 164 | +			if (isset($row['ground_speed'])) { | 
                                                        |
| 165 | + $temp_array['ground_speed'] = $row['ground_speed'];  | 
                                                        |
| 145 | 166 | }  | 
                                                        
| 146 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];  | 
                                                        |
| 147 | 167 | |
| 148 | 168 |  			if (isset($row['date'])) { | 
                                                        
| 149 | 169 | $dateArray = $this->parseDateString($row['date']);  | 
                                                        
@@ -186,13 +206,21 @@ discard block  | 
                                                    ||
| 186 | 206 | }  | 
                                                        
| 187 | 207 | |
| 188 | 208 | $fromsource = NULL;  | 
                                                        
| 189 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];  | 
                                                        |
| 190 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];  | 
                                                        |
| 191 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];  | 
                                                        |
| 209 | +			if (isset($row['source_name']) && $row['source_name'] != '') { | 
                                                        |
| 210 | + $temp_array['source_name'] = $row['source_name'];  | 
                                                        |
| 211 | + }  | 
                                                        |
| 212 | +			if (isset($row['over_country']) && $row['over_country'] != '') { | 
                                                        |
| 213 | + $temp_array['over_country'] = $row['over_country'];  | 
                                                        |
| 214 | + }  | 
                                                        |
| 215 | +			if (isset($row['distance']) && $row['distance'] != '') { | 
                                                        |
| 216 | + $temp_array['distance'] = $row['distance'];  | 
                                                        |
| 217 | + }  | 
                                                        |
| 192 | 218 | $temp_array['query_number_rows'] = $num_rows;  | 
                                                        
| 193 | 219 | $spotter_array[] = $temp_array;  | 
                                                        
| 194 | 220 | }  | 
                                                        
| 195 | - if ($num_rows == 0) return array();  | 
                                                        |
| 221 | +		if ($num_rows == 0) { | 
                                                        |
| 222 | + return array();  | 
                                                        |
| 223 | + }  | 
                                                        |
| 196 | 224 | $spotter_array[0]['query_number_rows'] = $num_rows;  | 
                                                        
| 197 | 225 | return $spotter_array;  | 
                                                        
| 198 | 226 | }  | 
                                                        
@@ -223,8 +251,12 @@ discard block  | 
                                                    ||
| 223 | 251 |  			{ | 
                                                        
| 224 | 252 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 225 | 253 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 226 | - } else $limit_query = "";  | 
                                                        |
| 227 | - } else $limit_query = "";  | 
                                                        |
| 254 | +			} else { | 
                                                        |
| 255 | + $limit_query = "";  | 
                                                        |
| 256 | + }  | 
                                                        |
| 257 | +		} else { | 
                                                        |
| 258 | + $limit_query = "";  | 
                                                        |
| 259 | + }  | 
                                                        |
| 228 | 260 | |
| 229 | 261 | if ($sort != "")  | 
                                                        
| 230 | 262 |  		{ | 
                                                        
@@ -252,7 +284,9 @@ discard block  | 
                                                    ||
| 252 | 284 | global $global_query;  | 
                                                        
| 253 | 285 | |
| 254 | 286 |  		date_default_timezone_set('UTC'); | 
                                                        
| 255 | - if ($id == '') return array();  | 
                                                        |
| 287 | +		if ($id == '') { | 
                                                        |
| 288 | + return array();  | 
                                                        |
| 289 | + }  | 
                                                        |
| 256 | 290 | $additional_query = "marine_output.fammarine_id = :id";  | 
                                                        
| 257 | 291 |  		$query_values = array(':id' => $id); | 
                                                        
| 258 | 292 | $query = $global_query." WHERE ".$additional_query." ";  | 
                                                        
@@ -395,8 +429,11 @@ discard block  | 
                                                    ||
| 395 | 429 | $query .= " ORDER BY marine_output.source_name ASC";  | 
                                                        
| 396 | 430 | |
| 397 | 431 | $sth = $this->db->prepare($query);  | 
                                                        
| 398 | - if (!empty($query_values)) $sth->execute($query_values);  | 
                                                        |
| 399 | - else $sth->execute();  | 
                                                        |
| 432 | +		if (!empty($query_values)) { | 
                                                        |
| 433 | + $sth->execute($query_values);  | 
                                                        |
| 434 | +		} else { | 
                                                        |
| 435 | + $sth->execute();  | 
                                                        |
| 436 | + }  | 
                                                        |
| 400 | 437 | |
| 401 | 438 | $source_array = array();  | 
                                                        
| 402 | 439 | $temp_array = array();  | 
                                                        
@@ -451,8 +488,11 @@ discard block  | 
                                                    ||
| 451 | 488 | $sth = $this->db->prepare($query);  | 
                                                        
| 452 | 489 |  		$sth->execute(array(':mmsi' => $mmsi)); | 
                                                        
| 453 | 490 | $result = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 454 | - if (isset($result[0])) return $result[0];  | 
                                                        |
| 455 | - else return array();  | 
                                                        |
| 491 | +		if (isset($result[0])) { | 
                                                        |
| 492 | + return $result[0];  | 
                                                        |
| 493 | +		} else { | 
                                                        |
| 494 | + return array();  | 
                                                        |
| 495 | + }  | 
                                                        |
| 456 | 496 | }  | 
                                                        
| 457 | 497 | |
| 458 | 498 | /*  | 
                                                        
@@ -468,7 +508,9 @@ discard block  | 
                                                    ||
| 468 | 508 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 469 | 509 | $datetime = new DateTime();  | 
                                                        
| 470 | 510 |  			$offset = $datetime->format('P'); | 
                                                        
| 471 | - } else $offset = '+00:00';  | 
                                                        |
| 511 | +		} else { | 
                                                        |
| 512 | + $offset = '+00:00';  | 
                                                        |
| 513 | + }  | 
                                                        |
| 472 | 514 | |
| 473 | 515 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 474 | 516 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date  | 
                                                        
@@ -661,8 +703,12 @@ discard block  | 
                                                    ||
| 661 | 703 | $latitude = 0;  | 
                                                        
| 662 | 704 | $longitude = 0;  | 
                                                        
| 663 | 705 | }  | 
                                                        
| 664 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;  | 
                                                        |
| 665 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;  | 
                                                        |
| 706 | +                if ($heading == '' || $Common->isInteger($heading) === false) { | 
                                                        |
| 707 | + $heading = 0;  | 
                                                        |
| 708 | + }  | 
                                                        |
| 709 | +                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { | 
                                                        |
| 710 | + $groundspeed = 0;  | 
                                                        |
| 711 | + }  | 
                                                        |
| 666 | 712 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status)  | 
                                                        
| 667 | 713 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status)";  | 
                                                        
| 668 | 714 | |
@@ -827,12 +873,18 @@ discard block  | 
                                                    ||
| 827 | 873 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count  | 
                                                        
| 828 | 874 | FROM marine_output".$filter_query." marine_output.ident <> ''";  | 
                                                        
| 829 | 875 |  		 if ($olderthanmonths > 0) { | 
                                                        
| 830 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';  | 
                                                        |
| 831 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        |
| 876 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 877 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';  | 
                                                        |
| 878 | +			} else { | 
                                                        |
| 879 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        |
| 880 | + }  | 
                                                        |
| 832 | 881 | }  | 
                                                        
| 833 | 882 |  		if ($sincedate != '') { | 
                                                        
| 834 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";  | 
                                                        |
| 835 | -			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
                                                        |
| 883 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 884 | + $query .= " AND marine_output.date > '".$sincedate."'";  | 
                                                        |
| 885 | +			} else { | 
                                                        |
| 886 | +				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
                                                        |
| 887 | + }  | 
                                                        |
| 836 | 888 | }  | 
                                                        
| 837 | 889 | $query_values = array();  | 
                                                        
| 838 | 890 |  		if ($year != '') { | 
                                                        
@@ -863,7 +915,9 @@ discard block  | 
                                                    ||
| 863 | 915 | }  | 
                                                        
| 864 | 916 | }  | 
                                                        
| 865 | 917 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";  | 
                                                        
| 866 | - if ($limit) $query .= " LIMIT 10 OFFSET 0";  | 
                                                        |
| 918 | +		if ($limit) { | 
                                                        |
| 919 | + $query .= " LIMIT 10 OFFSET 0";  | 
                                                        |
| 920 | + }  | 
                                                        |
| 867 | 921 | |
| 868 | 922 | $sth = $this->db->prepare($query);  | 
                                                        
| 869 | 923 | $sth->execute($query_values);  | 
                                                        
@@ -898,7 +952,9 @@ discard block  | 
                                                    ||
| 898 | 952 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 899 | 953 | $datetime = new DateTime();  | 
                                                        
| 900 | 954 |  			$offset = $datetime->format('P'); | 
                                                        
| 901 | - } else $offset = '+00:00';  | 
                                                        |
| 955 | +		} else { | 
                                                        |
| 956 | + $offset = '+00:00';  | 
                                                        |
| 957 | + }  | 
                                                        |
| 902 | 958 | |
| 903 | 959 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 904 | 960 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count  | 
                                                        
@@ -948,7 +1004,9 @@ discard block  | 
                                                    ||
| 948 | 1004 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 949 | 1005 | $datetime = new DateTime();  | 
                                                        
| 950 | 1006 |  			$offset = $datetime->format('P'); | 
                                                        
| 951 | - } else $offset = '+00:00';  | 
                                                        |
| 1007 | +		} else { | 
                                                        |
| 1008 | + $offset = '+00:00';  | 
                                                        |
| 1009 | + }  | 
                                                        |
| 952 | 1010 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
| 953 | 1011 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 954 | 1012 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count  | 
                                                        
@@ -994,7 +1052,9 @@ discard block  | 
                                                    ||
| 994 | 1052 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 995 | 1053 | $datetime = new DateTime();  | 
                                                        
| 996 | 1054 |  			$offset = $datetime->format('P'); | 
                                                        
| 997 | - } else $offset = '+00:00';  | 
                                                        |
| 1055 | +		} else { | 
                                                        |
| 1056 | + $offset = '+00:00';  | 
                                                        |
| 1057 | + }  | 
                                                        |
| 998 | 1058 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
| 999 | 1059 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1000 | 1060 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count  | 
                                                        
@@ -1042,7 +1102,9 @@ discard block  | 
                                                    ||
| 1042 | 1102 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1043 | 1103 | $datetime = new DateTime();  | 
                                                        
| 1044 | 1104 |  			$offset = $datetime->format('P'); | 
                                                        
| 1045 | - } else $offset = '+00:00';  | 
                                                        |
| 1105 | +		} else { | 
                                                        |
| 1106 | + $offset = '+00:00';  | 
                                                        |
| 1107 | + }  | 
                                                        |
| 1046 | 1108 | |
| 1047 | 1109 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1048 | 1110 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count  | 
                                                        
@@ -1091,7 +1153,9 @@ discard block  | 
                                                    ||
| 1091 | 1153 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1092 | 1154 | $datetime = new DateTime();  | 
                                                        
| 1093 | 1155 |  			$offset = $datetime->format('P'); | 
                                                        
| 1094 | - } else $offset = '+00:00';  | 
                                                        |
| 1156 | +		} else { | 
                                                        |
| 1157 | + $offset = '+00:00';  | 
                                                        |
| 1158 | + }  | 
                                                        |
| 1095 | 1159 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
| 1096 | 1160 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1097 | 1161 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count  | 
                                                        
@@ -1140,7 +1204,9 @@ discard block  | 
                                                    ||
| 1140 | 1204 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1141 | 1205 | $datetime = new DateTime();  | 
                                                        
| 1142 | 1206 |  			$offset = $datetime->format('P'); | 
                                                        
| 1143 | - } else $offset = '+00:00';  | 
                                                        |
| 1207 | +		} else { | 
                                                        |
| 1208 | + $offset = '+00:00';  | 
                                                        |
| 1209 | + }  | 
                                                        |
| 1144 | 1210 | |
| 1145 | 1211 | $orderby_sql = '';  | 
                                                        
| 1146 | 1212 | if ($orderby == "hour")  | 
                                                        
@@ -1209,7 +1275,9 @@ discard block  | 
                                                    ||
| 1209 | 1275 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1210 | 1276 | $datetime = new DateTime($date);  | 
                                                        
| 1211 | 1277 |  			$offset = $datetime->format('P'); | 
                                                        
| 1212 | - } else $offset = '+00:00';  | 
                                                        |
| 1278 | +		} else { | 
                                                        |
| 1279 | + $offset = '+00:00';  | 
                                                        |
| 1280 | + }  | 
                                                        |
| 1213 | 1281 | |
| 1214 | 1282 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1215 | 1283 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count  | 
                                                        
@@ -1257,7 +1325,9 @@ discard block  | 
                                                    ||
| 1257 | 1325 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1258 | 1326 | $datetime = new DateTime();  | 
                                                        
| 1259 | 1327 |  			$offset = $datetime->format('P'); | 
                                                        
| 1260 | - } else $offset = '+00:00';  | 
                                                        |
| 1328 | +		} else { | 
                                                        |
| 1329 | + $offset = '+00:00';  | 
                                                        |
| 1330 | + }  | 
                                                        |
| 1261 | 1331 | |
| 1262 | 1332 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1263 | 1333 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count  | 
                                                        
@@ -1321,8 +1391,11 @@ discard block  | 
                                                    ||
| 1321 | 1391 |  				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                        
| 1322 | 1392 | }  | 
                                                        
| 1323 | 1393 | }  | 
                                                        
| 1324 | - if (empty($query_values)) $queryi .= $this->getFilter($filters);  | 
                                                        |
| 1325 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4);  | 
                                                        |
| 1394 | +		if (empty($query_values)) { | 
                                                        |
| 1395 | + $queryi .= $this->getFilter($filters);  | 
                                                        |
| 1396 | +		} else { | 
                                                        |
| 1397 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4);  | 
                                                        |
| 1398 | + }  | 
                                                        |
| 1326 | 1399 | |
| 1327 | 1400 | $sth = $this->db->prepare($queryi);  | 
                                                        
| 1328 | 1401 | $sth->execute($query_values);  | 
                                                        
@@ -1344,7 +1417,9 @@ discard block  | 
                                                    ||
| 1344 | 1417 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1345 | 1418 | $datetime = new DateTime();  | 
                                                        
| 1346 | 1419 |  			$offset = $datetime->format('P'); | 
                                                        
| 1347 | - } else $offset = '+00:00';  | 
                                                        |
| 1420 | +		} else { | 
                                                        |
| 1421 | + $offset = '+00:00';  | 
                                                        |
| 1422 | + }  | 
                                                        |
| 1348 | 1423 | |
| 1349 | 1424 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1350 | 1425 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count  | 
                                                        
@@ -1448,7 +1523,9 @@ discard block  | 
                                                    ||
| 1448 | 1523 | */  | 
                                                        
| 1449 | 1524 | public function parseDirection($direction = 0)  | 
                                                        
| 1450 | 1525 |  	{ | 
                                                        
| 1451 | - if ($direction == '') $direction = 0;  | 
                                                        |
| 1526 | +		if ($direction == '') { | 
                                                        |
| 1527 | + $direction = 0;  | 
                                                        |
| 1528 | + }  | 
                                                        |
| 1452 | 1529 | $direction_array = array();  | 
                                                        
| 1453 | 1530 | $temp_array = array();  | 
                                                        
| 1454 | 1531 | |
@@ -1537,7 +1614,9 @@ discard block  | 
                                                    ||
| 1537 | 1614 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 1538 | 1615 | |
| 1539 | 1616 | $Connection = new Connection($this->db);  | 
                                                        
| 1540 | -		if (!$Connection->tableExists('countries')) return ''; | 
                                                        |
| 1617 | +		if (!$Connection->tableExists('countries')) { | 
                                                        |
| 1618 | + return '';  | 
                                                        |
| 1619 | + }  | 
                                                        |
| 1541 | 1620 | |
| 1542 | 1621 |  		try { | 
                                                        
| 1543 | 1622 | /*  | 
                                                        
@@ -1557,9 +1636,13 @@ discard block  | 
                                                    ||
| 1557 | 1636 | $sth->closeCursor();  | 
                                                        
| 1558 | 1637 |  			if (count($row) > 0) { | 
                                                        
| 1559 | 1638 | return $row;  | 
                                                        
| 1560 | - } else return '';  | 
                                                        |
| 1639 | +			} else { | 
                                                        |
| 1640 | + return '';  | 
                                                        |
| 1641 | + }  | 
                                                        |
| 1561 | 1642 |  		} catch (PDOException $e) { | 
                                                        
| 1562 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";  | 
                                                        |
| 1643 | +			if (isset($globalDebug) && $globalDebug) { | 
                                                        |
| 1644 | + echo 'Error : '.$e->getMessage()."\n";  | 
                                                        |
| 1645 | + }  | 
                                                        |
| 1563 | 1646 | return '';  | 
                                                        
| 1564 | 1647 | }  | 
                                                        
| 1565 | 1648 | |
@@ -1577,7 +1660,9 @@ discard block  | 
                                                    ||
| 1577 | 1660 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);  | 
                                                        
| 1578 | 1661 | |
| 1579 | 1662 | $Connection = new Connection($this->db);  | 
                                                        
| 1580 | -		if (!$Connection->tableExists('countries')) return ''; | 
                                                        |
| 1663 | +		if (!$Connection->tableExists('countries')) { | 
                                                        |
| 1664 | + return '';  | 
                                                        |
| 1665 | + }  | 
                                                        |
| 1581 | 1666 | |
| 1582 | 1667 |  		try { | 
                                                        
| 1583 | 1668 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";  | 
                                                        
@@ -1589,9 +1674,13 @@ discard block  | 
                                                    ||
| 1589 | 1674 | $sth->closeCursor();  | 
                                                        
| 1590 | 1675 |  			if (count($row) > 0) { | 
                                                        
| 1591 | 1676 | return $row;  | 
                                                        
| 1592 | - } else return '';  | 
                                                        |
| 1677 | +			} else { | 
                                                        |
| 1678 | + return '';  | 
                                                        |
| 1679 | + }  | 
                                                        |
| 1593 | 1680 |  		} catch (PDOException $e) { | 
                                                        
| 1594 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";  | 
                                                        |
| 1681 | +			if (isset($globalDebug) && $globalDebug) { | 
                                                        |
| 1682 | + echo 'Error : '.$e->getMessage()."\n";  | 
                                                        |
| 1683 | + }  | 
                                                        |
| 1595 | 1684 | return '';  | 
                                                        
| 1596 | 1685 | }  | 
                                                        
| 1597 | 1686 | |
@@ -1609,7 +1698,9 @@ discard block  | 
                                                    ||
| 1609 | 1698 |  	{ | 
                                                        
| 1610 | 1699 | global $globalBitlyAccessToken;  | 
                                                        
| 1611 | 1700 | |
| 1612 | - if ($globalBitlyAccessToken == '') return $url;  | 
                                                        |
| 1701 | +		if ($globalBitlyAccessToken == '') { | 
                                                        |
| 1702 | + return $url;  | 
                                                        |
| 1703 | + }  | 
                                                        |
| 1613 | 1704 | |
| 1614 | 1705 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;  | 
                                                        
| 1615 | 1706 | |
@@ -14,7 +14,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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 = '')  | 
                                                        
@@ -12,10 +12,10 @@ discard block  | 
                                                    ||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /**  | 
                                                        
| 15 | - * Get SQL query part for filter used  | 
                                                        |
| 16 | - * @param Array $filter the filter  | 
                                                        |
| 17 | - * @return Array the SQL part  | 
                                                        |
| 18 | - */  | 
                                                        |
| 15 | + * Get SQL query part for filter used  | 
                                                        |
| 16 | + * @param Array $filter the filter  | 
                                                        |
| 17 | + * @return Array the SQL part  | 
                                                        |
| 18 | + */  | 
                                                        |
| 19 | 19 |  	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
| 21 | 21 | $filters = array();  | 
                                                        
@@ -86,11 +86,11 @@ discard block  | 
                                                    ||
| 86 | 86 | }  | 
                                                        
| 87 | 87 | |
| 88 | 88 | /**  | 
                                                        
| 89 | - * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 90 | - *  | 
                                                        |
| 91 | - * @return Array the spotter information  | 
                                                        |
| 92 | - *  | 
                                                        |
| 93 | - */  | 
                                                        |
| 89 | + * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 90 | + *  | 
                                                        |
| 91 | + * @return Array the spotter information  | 
                                                        |
| 92 | + *  | 
                                                        |
| 93 | + */  | 
                                                        |
| 94 | 94 | public function getLiveMarineData($limit = '', $sort = '', $filter = array())  | 
                                                        
| 95 | 95 |  	{ | 
                                                        
| 96 | 96 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -132,11 +132,11 @@ discard block  | 
                                                    ||
| 132 | 132 | }  | 
                                                        
| 133 | 133 | |
| 134 | 134 | /**  | 
                                                        
| 135 | - * Gets Minimal Live Spotter data  | 
                                                        |
| 136 | - *  | 
                                                        |
| 137 | - * @return Array the spotter information  | 
                                                        |
| 138 | - *  | 
                                                        |
| 139 | - */  | 
                                                        |
| 135 | + * Gets Minimal Live Spotter data  | 
                                                        |
| 136 | + *  | 
                                                        |
| 137 | + * @return Array the spotter information  | 
                                                        |
| 138 | + *  | 
                                                        |
| 139 | + */  | 
                                                        |
| 140 | 140 | public function getMinLiveMarineData($filter = array())  | 
                                                        
| 141 | 141 |  	{ | 
                                                        
| 142 | 142 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -166,11 +166,11 @@ discard block  | 
                                                    ||
| 166 | 166 | }  | 
                                                        
| 167 | 167 | |
| 168 | 168 | /**  | 
                                                        
| 169 | - * Gets Minimal Live Spotter data since xx seconds  | 
                                                        |
| 170 | - *  | 
                                                        |
| 171 | - * @return Array the spotter information  | 
                                                        |
| 172 | - *  | 
                                                        |
| 173 | - */  | 
                                                        |
| 169 | + * Gets Minimal Live Spotter data since xx seconds  | 
                                                        |
| 170 | + *  | 
                                                        |
| 171 | + * @return Array the spotter information  | 
                                                        |
| 172 | + *  | 
                                                        |
| 173 | + */  | 
                                                        |
| 174 | 174 | public function getMinLastLiveMarineData($filter = array())  | 
                                                        
| 175 | 175 |  	{ | 
                                                        
| 176 | 176 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -183,13 +183,13 @@ discard block  | 
                                                    ||
| 183 | 183 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'  | 
                                                        
| 185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date";  | 
                                                        
| 186 | -                } else { | 
                                                        |
| 186 | +				} else { | 
                                                        |
| 187 | 187 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'  | 
                                                        
| 189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date";  | 
                                                        
| 190 | 190 | }  | 
                                                        
| 191 | 191 | |
| 192 | -    		try { | 
                                                        |
| 192 | +			try { | 
                                                        |
| 193 | 193 | $sth = $this->db->prepare($query);  | 
                                                        
| 194 | 194 | $sth->execute();  | 
                                                        
| 195 | 195 |  		} catch(PDOException $e) { | 
                                                        
@@ -201,11 +201,11 @@ discard block  | 
                                                    ||
| 201 | 201 | }  | 
                                                        
| 202 | 202 | |
| 203 | 203 | /**  | 
                                                        
| 204 | - * Gets number of latest data entry  | 
                                                        |
| 205 | - *  | 
                                                        |
| 206 | - * @return String number of entry  | 
                                                        |
| 207 | - *  | 
                                                        |
| 208 | - */  | 
                                                        |
| 204 | + * Gets number of latest data entry  | 
                                                        |
| 205 | + *  | 
                                                        |
| 206 | + * @return String number of entry  | 
                                                        |
| 207 | + *  | 
                                                        |
| 208 | + */  | 
                                                        |
| 209 | 209 | public function getLiveMarineCount($filter = array())  | 
                                                        
| 210 | 210 |  	{ | 
                                                        
| 211 | 211 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -230,11 +230,11 @@ discard block  | 
                                                    ||
| 230 | 230 | }  | 
                                                        
| 231 | 231 | |
| 232 | 232 | /**  | 
                                                        
| 233 | - * Gets all the spotter information based on the latest data entry and coord  | 
                                                        |
| 234 | - *  | 
                                                        |
| 235 | - * @return Array the spotter information  | 
                                                        |
| 236 | - *  | 
                                                        |
| 237 | - */  | 
                                                        |
| 233 | + * Gets all the spotter information based on the latest data entry and coord  | 
                                                        |
| 234 | + *  | 
                                                        |
| 235 | + * @return Array the spotter information  | 
                                                        |
| 236 | + *  | 
                                                        |
| 237 | + */  | 
                                                        |
| 238 | 238 | public function getLiveMarineDatabyCoord($coord, $filter = array())  | 
                                                        
| 239 | 239 |  	{ | 
                                                        
| 240 | 240 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -258,11 +258,11 @@ discard block  | 
                                                    ||
| 258 | 258 | }  | 
                                                        
| 259 | 259 | |
| 260 | 260 | /**  | 
                                                        
| 261 | - * Gets all the spotter information based on a user's latitude and longitude  | 
                                                        |
| 262 | - *  | 
                                                        |
| 263 | - * @return Array the spotter information  | 
                                                        |
| 264 | - *  | 
                                                        |
| 265 | - */  | 
                                                        |
| 261 | + * Gets all the spotter information based on a user's latitude and longitude  | 
                                                        |
| 262 | + *  | 
                                                        |
| 263 | + * @return Array the spotter information  | 
                                                        |
| 264 | + *  | 
                                                        |
| 265 | + */  | 
                                                        |
| 266 | 266 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval)  | 
                                                        
| 267 | 267 |  	{ | 
                                                        
| 268 | 268 | $Marine = new Marine($this->db);  | 
                                                        
@@ -275,134 +275,134 @@ discard block  | 
                                                    ||
| 275 | 275 | if ($lng != '')  | 
                                                        
| 276 | 276 |  		{ | 
                                                        
| 277 | 277 | if (!is_numeric($lng))  | 
                                                        
| 278 | -                        { | 
                                                        |
| 279 | - return false;  | 
                                                        |
| 280 | - }  | 
                                                        |
| 281 | - }  | 
                                                        |
| 282 | -  | 
                                                        |
| 283 | - if ($radius != '')  | 
                                                        |
| 284 | -                { | 
                                                        |
| 285 | - if (!is_numeric($radius))  | 
                                                        |
| 286 | -                        { | 
                                                        |
| 287 | - return false;  | 
                                                        |
| 288 | - }  | 
                                                        |
| 289 | - }  | 
                                                        |
| 278 | +						{ | 
                                                        |
| 279 | + return false;  | 
                                                        |
| 280 | + }  | 
                                                        |
| 281 | + }  | 
                                                        |
| 282 | +  | 
                                                        |
| 283 | + if ($radius != '')  | 
                                                        |
| 284 | +				{ | 
                                                        |
| 285 | + if (!is_numeric($radius))  | 
                                                        |
| 286 | +						{ | 
                                                        |
| 287 | + return false;  | 
                                                        |
| 288 | + }  | 
                                                        |
| 289 | + }  | 
                                                        |
| 290 | 290 | $additional_query = '';  | 
                                                        
| 291 | 291 | if ($interval != '')  | 
                                                        
| 292 | -                { | 
                                                        |
| 293 | - if (!is_string($interval))  | 
                                                        |
| 294 | -                        { | 
                                                        |
| 295 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 296 | - return false;  | 
                                                        |
| 297 | -                        } else { | 
                                                        |
| 298 | - if ($interval == '1m')  | 
                                                        |
| 299 | -                { | 
                                                        |
| 300 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 301 | -                } else if ($interval == '15m'){ | 
                                                        |
| 302 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';  | 
                                                        |
| 303 | - }  | 
                                                        |
| 304 | - }  | 
                                                        |
| 305 | -                } else { | 
                                                        |
| 306 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 307 | - }  | 
                                                        |
| 308 | -  | 
                                                        |
| 309 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live  | 
                                                        |
| 292 | +				{ | 
                                                        |
| 293 | + if (!is_string($interval))  | 
                                                        |
| 294 | +						{ | 
                                                        |
| 295 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 296 | + return false;  | 
                                                        |
| 297 | +						} else { | 
                                                        |
| 298 | + if ($interval == '1m')  | 
                                                        |
| 299 | +				{ | 
                                                        |
| 300 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 301 | +				} else if ($interval == '15m'){ | 
                                                        |
| 302 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';  | 
                                                        |
| 303 | + }  | 
                                                        |
| 304 | + }  | 
                                                        |
| 305 | +				} else { | 
                                                        |
| 306 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 307 | + }  | 
                                                        |
| 308 | +  | 
                                                        |
| 309 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live  | 
                                                        |
| 310 | 310 | WHERE marine_live.latitude <> ''  | 
                                                        
| 311 | 311 | AND marine_live.longitude <> ''  | 
                                                        
| 312 | 312 | ".$additional_query."  | 
                                                        
| 313 | 313 | HAVING distance < :radius  | 
                                                        
| 314 | 314 | ORDER BY distance";  | 
                                                        
| 315 | 315 | |
| 316 | -                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); | 
                                                        |
| 316 | +				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); | 
                                                        |
| 317 | 317 | |
| 318 | - return $spotter_array;  | 
                                                        |
| 319 | - }  | 
                                                        |
| 318 | + return $spotter_array;  | 
                                                        |
| 319 | + }  | 
                                                        |
| 320 | 320 | |
| 321 | 321 | |
| 322 | - /**  | 
                                                        |
| 323 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 324 | - *  | 
                                                        |
| 325 | - * @return Array the spotter information  | 
                                                        |
| 326 | - *  | 
                                                        |
| 327 | - */  | 
                                                        |
| 322 | + /**  | 
                                                        |
| 323 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 324 | + *  | 
                                                        |
| 325 | + * @return Array the spotter information  | 
                                                        |
| 326 | + *  | 
                                                        |
| 327 | + */  | 
                                                        |
| 328 | 328 | public function getLastLiveMarineDataByIdent($ident)  | 
                                                        
| 329 | 329 |  	{ | 
                                                        
| 330 | 330 | $Marine = new Marine($this->db);  | 
                                                        
| 331 | 331 |  		date_default_timezone_set('UTC'); | 
                                                        
| 332 | 332 | |
| 333 | 333 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 334 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 334 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 335 | 335 | |
| 336 | 336 |  		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); | 
                                                        
| 337 | 337 | |
| 338 | 338 | return $spotter_array;  | 
                                                        
| 339 | 339 | }  | 
                                                        
| 340 | 340 | |
| 341 | - /**  | 
                                                        |
| 342 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 343 | - *  | 
                                                        |
| 344 | - * @return Array the spotter information  | 
                                                        |
| 345 | - *  | 
                                                        |
| 346 | - */  | 
                                                        |
| 341 | + /**  | 
                                                        |
| 342 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 343 | + *  | 
                                                        |
| 344 | + * @return Array the spotter information  | 
                                                        |
| 345 | + *  | 
                                                        |
| 346 | + */  | 
                                                        |
| 347 | 347 | public function getDateLiveMarineDataByIdent($ident,$date)  | 
                                                        
| 348 | 348 |  	{ | 
                                                        
| 349 | 349 | $Marine = new Marine($this->db);  | 
                                                        
| 350 | 350 |  		date_default_timezone_set('UTC'); | 
                                                        
| 351 | 351 | |
| 352 | 352 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 353 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 353 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 354 | 354 | |
| 355 | -                $date = date('c',$date); | 
                                                        |
| 355 | +				$date = date('c',$date); | 
                                                        |
| 356 | 356 |  		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); | 
                                                        
| 357 | 357 | |
| 358 | 358 | return $spotter_array;  | 
                                                        
| 359 | 359 | }  | 
                                                        
| 360 | 360 | |
| 361 | - /**  | 
                                                        |
| 362 | - * Gets last spotter information based on a particular callsign  | 
                                                        |
| 363 | - *  | 
                                                        |
| 364 | - * @return Array the spotter information  | 
                                                        |
| 365 | - *  | 
                                                        |
| 366 | - */  | 
                                                        |
| 361 | + /**  | 
                                                        |
| 362 | + * Gets last spotter information based on a particular callsign  | 
                                                        |
| 363 | + *  | 
                                                        |
| 364 | + * @return Array the spotter information  | 
                                                        |
| 365 | + *  | 
                                                        |
| 366 | + */  | 
                                                        |
| 367 | 367 | public function getLastLiveMarineDataById($id)  | 
                                                        
| 368 | 368 |  	{ | 
                                                        
| 369 | 369 | $Marine = new Marine($this->db);  | 
                                                        
| 370 | 370 |  		date_default_timezone_set('UTC'); | 
                                                        
| 371 | 371 | |
| 372 | 372 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 373 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 373 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 374 | 374 | |
| 375 | 375 |  		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); | 
                                                        
| 376 | 376 | |
| 377 | 377 | return $spotter_array;  | 
                                                        
| 378 | 378 | }  | 
                                                        
| 379 | 379 | |
| 380 | - /**  | 
                                                        |
| 381 | - * Gets last spotter information based on a particular callsign  | 
                                                        |
| 382 | - *  | 
                                                        |
| 383 | - * @return Array the spotter information  | 
                                                        |
| 384 | - *  | 
                                                        |
| 385 | - */  | 
                                                        |
| 380 | + /**  | 
                                                        |
| 381 | + * Gets last spotter information based on a particular callsign  | 
                                                        |
| 382 | + *  | 
                                                        |
| 383 | + * @return Array the spotter information  | 
                                                        |
| 384 | + *  | 
                                                        |
| 385 | + */  | 
                                                        |
| 386 | 386 | public function getDateLiveMarineDataById($id,$date)  | 
                                                        
| 387 | 387 |  	{ | 
                                                        
| 388 | 388 | $Marine = new Marine($this->db);  | 
                                                        
| 389 | 389 |  		date_default_timezone_set('UTC'); | 
                                                        
| 390 | 390 | |
| 391 | 391 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 392 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 393 | -                $date = date('c',$date); | 
                                                        |
| 392 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 393 | +				$date = date('c',$date); | 
                                                        |
| 394 | 394 |  		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); | 
                                                        
| 395 | 395 | |
| 396 | 396 | return $spotter_array;  | 
                                                        
| 397 | 397 | }  | 
                                                        
| 398 | 398 | |
| 399 | 399 | |
| 400 | - /**  | 
                                                        |
| 401 | - * Gets all the spotter information based on a particular id  | 
                                                        |
| 402 | - *  | 
                                                        |
| 403 | - * @return Array the spotter information  | 
                                                        |
| 404 | - *  | 
                                                        |
| 405 | - */  | 
                                                        |
| 400 | + /**  | 
                                                        |
| 401 | + * Gets all the spotter information based on a particular id  | 
                                                        |
| 402 | + *  | 
                                                        |
| 403 | + * @return Array the spotter information  | 
                                                        |
| 404 | + *  | 
                                                        |
| 405 | + */  | 
                                                        |
| 406 | 406 | public function getAllLiveMarineDataById($id,$liveinterval = false)  | 
                                                        
| 407 | 407 |  	{ | 
                                                        
| 408 | 408 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -430,18 +430,18 @@ discard block  | 
                                                    ||
| 430 | 430 | return $spotter_array;  | 
                                                        
| 431 | 431 | }  | 
                                                        
| 432 | 432 | |
| 433 | - /**  | 
                                                        |
| 434 | - * Gets all the spotter information based on a particular ident  | 
                                                        |
| 435 | - *  | 
                                                        |
| 436 | - * @return Array the spotter information  | 
                                                        |
| 437 | - *  | 
                                                        |
| 438 | - */  | 
                                                        |
| 433 | + /**  | 
                                                        |
| 434 | + * Gets all the spotter information based on a particular ident  | 
                                                        |
| 435 | + *  | 
                                                        |
| 436 | + * @return Array the spotter information  | 
                                                        |
| 437 | + *  | 
                                                        |
| 438 | + */  | 
                                                        |
| 439 | 439 | public function getAllLiveMarineDataByIdent($ident)  | 
                                                        
| 440 | 440 |  	{ | 
                                                        
| 441 | 441 |  		date_default_timezone_set('UTC'); | 
                                                        
| 442 | 442 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 443 | 443 | $query = self::$global_query.' WHERE marine_live.ident = :ident';  | 
                                                        
| 444 | -    		try { | 
                                                        |
| 444 | +			try { | 
                                                        |
| 445 | 445 | |
| 446 | 446 | $sth = $this->db->prepare($query);  | 
                                                        
| 447 | 447 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
@@ -455,23 +455,23 @@ discard block  | 
                                                    ||
| 455 | 455 | |
| 456 | 456 | |
| 457 | 457 | /**  | 
                                                        
| 458 | - * Deletes all info in the table  | 
                                                        |
| 459 | - *  | 
                                                        |
| 460 | - * @return String success or false  | 
                                                        |
| 461 | - *  | 
                                                        |
| 462 | - */  | 
                                                        |
| 458 | + * Deletes all info in the table  | 
                                                        |
| 459 | + *  | 
                                                        |
| 460 | + * @return String success or false  | 
                                                        |
| 461 | + *  | 
                                                        |
| 462 | + */  | 
                                                        |
| 463 | 463 | public function deleteLiveMarineData()  | 
                                                        
| 464 | 464 |  	{ | 
                                                        
| 465 | 465 | global $globalDBdriver;  | 
                                                        
| 466 | 466 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 467 | 467 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";  | 
                                                        
| 468 | 468 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';  | 
                                                        
| 469 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";  | 
                                                        |
| 469 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";  | 
                                                        |
| 470 | 470 |  		} else { | 
                                                        
| 471 | 471 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";  | 
                                                        
| 472 | 472 | }  | 
                                                        
| 473 | 473 | |
| 474 | -    		try { | 
                                                        |
| 474 | +			try { | 
                                                        |
| 475 | 475 | |
| 476 | 476 | $sth = $this->db->prepare($query);  | 
                                                        
| 477 | 477 | $sth->execute();  | 
                                                        
@@ -483,18 +483,18 @@ discard block  | 
                                                    ||
| 483 | 483 | }  | 
                                                        
| 484 | 484 | |
| 485 | 485 | /**  | 
                                                        
| 486 | - * Deletes all info in the table for aircraft not seen since 2 HOUR  | 
                                                        |
| 487 | - *  | 
                                                        |
| 488 | - * @return String success or false  | 
                                                        |
| 489 | - *  | 
                                                        |
| 490 | - */  | 
                                                        |
| 486 | + * Deletes all info in the table for aircraft not seen since 2 HOUR  | 
                                                        |
| 487 | + *  | 
                                                        |
| 488 | + * @return String success or false  | 
                                                        |
| 489 | + *  | 
                                                        |
| 490 | + */  | 
                                                        |
| 491 | 491 | public function deleteLiveMarineDataNotUpdated()  | 
                                                        
| 492 | 492 |  	{ | 
                                                        
| 493 | 493 | global $globalDBdriver, $globalDebug;  | 
                                                        
| 494 | 494 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 495 | 495 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';  | 
                                                        
| 496 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";  | 
                                                        |
| 497 | -    			try { | 
                                                        |
| 496 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";  | 
                                                        |
| 497 | +				try { | 
                                                        |
| 498 | 498 | |
| 499 | 499 | $sth = $this->db->prepare($query);  | 
                                                        
| 500 | 500 | $sth->execute();  | 
                                                        
@@ -502,8 +502,8 @@ discard block  | 
                                                    ||
| 502 | 502 | return "error";  | 
                                                        
| 503 | 503 | }  | 
                                                        
| 504 | 504 |  			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; | 
                                                        
| 505 | - $i = 0;  | 
                                                        |
| 506 | - $j =0;  | 
                                                        |
| 505 | + $i = 0;  | 
                                                        |
| 506 | + $j =0;  | 
                                                        |
| 507 | 507 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 508 | 508 | foreach($all as $row)  | 
                                                        
| 509 | 509 |  			{ | 
                                                        
@@ -511,20 +511,20 @@ discard block  | 
                                                    ||
| 511 | 511 | $j++;  | 
                                                        
| 512 | 512 |  				if ($j == 30) { | 
                                                        
| 513 | 513 | if ($globalDebug) echo ".";  | 
                                                        
| 514 | -				    	try { | 
                                                        |
| 514 | +						try { | 
                                                        |
| 515 | 515 | |
| 516 | 516 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
| 517 | 517 | $sth->execute();  | 
                                                        
| 518 | 518 |  					} catch(PDOException $e) { | 
                                                        
| 519 | 519 | return "error";  | 
                                                        
| 520 | 520 | }  | 
                                                        
| 521 | -                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; | 
                                                        |
| 522 | - $j = 0;  | 
                                                        |
| 521 | +									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; | 
                                                        |
| 522 | + $j = 0;  | 
                                                        |
| 523 | 523 | }  | 
                                                        
| 524 | 524 | $query_delete .= "'".$row['fammarine_id']."',";  | 
                                                        
| 525 | 525 | }  | 
                                                        
| 526 | 526 |  			if ($i > 0) { | 
                                                        
| 527 | -    				try { | 
                                                        |
| 527 | +					try { | 
                                                        |
| 528 | 528 | |
| 529 | 529 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
| 530 | 530 | $sth->execute();  | 
                                                        
@@ -535,9 +535,9 @@ discard block  | 
                                                    ||
| 535 | 535 | return "success";  | 
                                                        
| 536 | 536 |  		} elseif ($globalDBdriver == 'pgsql') { | 
                                                        
| 537 | 537 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";  | 
                                                        
| 538 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";  | 
                                                        |
| 539 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";  | 
                                                        |
| 540 | -    			try { | 
                                                        |
| 538 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";  | 
                                                        |
| 539 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";  | 
                                                        |
| 540 | +				try { | 
                                                        |
| 541 | 541 | |
| 542 | 542 | $sth = $this->db->prepare($query);  | 
                                                        
| 543 | 543 | $sth->execute();  | 
                                                        
@@ -581,17 +581,17 @@ discard block  | 
                                                    ||
| 581 | 581 | }  | 
                                                        
| 582 | 582 | |
| 583 | 583 | /**  | 
                                                        
| 584 | - * Deletes all info in the table for an ident  | 
                                                        |
| 585 | - *  | 
                                                        |
| 586 | - * @return String success or false  | 
                                                        |
| 587 | - *  | 
                                                        |
| 588 | - */  | 
                                                        |
| 584 | + * Deletes all info in the table for an ident  | 
                                                        |
| 585 | + *  | 
                                                        |
| 586 | + * @return String success or false  | 
                                                        |
| 587 | + *  | 
                                                        |
| 588 | + */  | 
                                                        |
| 589 | 589 | public function deleteLiveMarineDataByIdent($ident)  | 
                                                        
| 590 | 590 |  	{ | 
                                                        
| 591 | 591 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 592 | 592 | $query = 'DELETE FROM marine_live WHERE ident = :ident';  | 
                                                        
| 593 | 593 | |
| 594 | -    		try { | 
                                                        |
| 594 | +			try { | 
                                                        |
| 595 | 595 | |
| 596 | 596 | $sth = $this->db->prepare($query);  | 
                                                        
| 597 | 597 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
@@ -603,17 +603,17 @@ discard block  | 
                                                    ||
| 603 | 603 | }  | 
                                                        
| 604 | 604 | |
| 605 | 605 | /**  | 
                                                        
| 606 | - * Deletes all info in the table for an id  | 
                                                        |
| 607 | - *  | 
                                                        |
| 608 | - * @return String success or false  | 
                                                        |
| 609 | - *  | 
                                                        |
| 610 | - */  | 
                                                        |
| 606 | + * Deletes all info in the table for an id  | 
                                                        |
| 607 | + *  | 
                                                        |
| 608 | + * @return String success or false  | 
                                                        |
| 609 | + *  | 
                                                        |
| 610 | + */  | 
                                                        |
| 611 | 611 | public function deleteLiveMarineDataById($id)  | 
                                                        
| 612 | 612 |  	{ | 
                                                        
| 613 | 613 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 614 | 614 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id';  | 
                                                        
| 615 | 615 | |
| 616 | -    		try { | 
                                                        |
| 616 | +			try { | 
                                                        |
| 617 | 617 | |
| 618 | 618 | $sth = $this->db->prepare($query);  | 
                                                        
| 619 | 619 |  			$sth->execute(array(':id' => $id)); | 
                                                        
@@ -626,11 +626,11 @@ discard block  | 
                                                    ||
| 626 | 626 | |
| 627 | 627 | |
| 628 | 628 | /**  | 
                                                        
| 629 | - * Gets the aircraft ident within the last hour  | 
                                                        |
| 630 | - *  | 
                                                        |
| 631 | - * @return String the ident  | 
                                                        |
| 632 | - *  | 
                                                        |
| 633 | - */  | 
                                                        |
| 629 | + * Gets the aircraft ident within the last hour  | 
                                                        |
| 630 | + *  | 
                                                        |
| 631 | + * @return String the ident  | 
                                                        |
| 632 | + *  | 
                                                        |
| 633 | + */  | 
                                                        |
| 634 | 634 | public function getIdentFromLastHour($ident)  | 
                                                        
| 635 | 635 |  	{ | 
                                                        
| 636 | 636 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -656,14 +656,14 @@ discard block  | 
                                                    ||
| 656 | 656 | $ident_result = $row['ident'];  | 
                                                        
| 657 | 657 | }  | 
                                                        
| 658 | 658 | return $ident_result;  | 
                                                        
| 659 | - }  | 
                                                        |
| 659 | + }  | 
                                                        |
| 660 | 660 | |
| 661 | 661 | /**  | 
                                                        
| 662 | - * Check recent aircraft  | 
                                                        |
| 663 | - *  | 
                                                        |
| 664 | - * @return String the ident  | 
                                                        |
| 665 | - *  | 
                                                        |
| 666 | - */  | 
                                                        |
| 662 | + * Check recent aircraft  | 
                                                        |
| 663 | + *  | 
                                                        |
| 664 | + * @return String the ident  | 
                                                        |
| 665 | + *  | 
                                                        |
| 666 | + */  | 
                                                        |
| 667 | 667 | public function checkIdentRecent($ident)  | 
                                                        
| 668 | 668 |  	{ | 
                                                        
| 669 | 669 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -689,14 +689,14 @@ discard block  | 
                                                    ||
| 689 | 689 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 690 | 690 | }  | 
                                                        
| 691 | 691 | return $ident_result;  | 
                                                        
| 692 | - }  | 
                                                        |
| 692 | + }  | 
                                                        |
| 693 | 693 | |
| 694 | 694 | /**  | 
                                                        
| 695 | - * Check recent aircraft by id  | 
                                                        |
| 696 | - *  | 
                                                        |
| 697 | - * @return String the ident  | 
                                                        |
| 698 | - *  | 
                                                        |
| 699 | - */  | 
                                                        |
| 695 | + * Check recent aircraft by id  | 
                                                        |
| 696 | + *  | 
                                                        |
| 697 | + * @return String the ident  | 
                                                        |
| 698 | + *  | 
                                                        |
| 699 | + */  | 
                                                        |
| 700 | 700 | public function checkIdRecent($id)  | 
                                                        
| 701 | 701 |  	{ | 
                                                        
| 702 | 702 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -722,14 +722,14 @@ discard block  | 
                                                    ||
| 722 | 722 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 723 | 723 | }  | 
                                                        
| 724 | 724 | return $ident_result;  | 
                                                        
| 725 | - }  | 
                                                        |
| 725 | + }  | 
                                                        |
| 726 | 726 | |
| 727 | 727 | /**  | 
                                                        
| 728 | - * Check recent aircraft by mmsi  | 
                                                        |
| 729 | - *  | 
                                                        |
| 730 | - * @return String the ident  | 
                                                        |
| 731 | - *  | 
                                                        |
| 732 | - */  | 
                                                        |
| 728 | + * Check recent aircraft by mmsi  | 
                                                        |
| 729 | + *  | 
                                                        |
| 730 | + * @return String the ident  | 
                                                        |
| 731 | + *  | 
                                                        |
| 732 | + */  | 
                                                        |
| 733 | 733 | public function checkMMSIRecent($mmsi)  | 
                                                        
| 734 | 734 |  	{ | 
                                                        
| 735 | 735 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -755,19 +755,19 @@ discard block  | 
                                                    ||
| 755 | 755 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 756 | 756 | }  | 
                                                        
| 757 | 757 | return $ident_result;  | 
                                                        
| 758 | - }  | 
                                                        |
| 758 | + }  | 
                                                        |
| 759 | 759 | |
| 760 | 760 | /**  | 
                                                        
| 761 | - * Adds a new spotter data  | 
                                                        |
| 762 | - *  | 
                                                        |
| 763 | - * @param String $fammarine_id the ID from flightaware  | 
                                                        |
| 764 | - * @param String $ident the flight ident  | 
                                                        |
| 765 | - * @param String $aircraft_icao the aircraft type  | 
                                                        |
| 766 | - * @param String $departure_airport_icao the departure airport  | 
                                                        |
| 767 | - * @param String $arrival_airport_icao the arrival airport  | 
                                                        |
| 768 | - * @return String success or false  | 
                                                        |
| 769 | - *  | 
                                                        |
| 770 | - */  | 
                                                        |
| 761 | + * Adds a new spotter data  | 
                                                        |
| 762 | + *  | 
                                                        |
| 763 | + * @param String $fammarine_id the ID from flightaware  | 
                                                        |
| 764 | + * @param String $ident the flight ident  | 
                                                        |
| 765 | + * @param String $aircraft_icao the aircraft type  | 
                                                        |
| 766 | + * @param String $departure_airport_icao the departure airport  | 
                                                        |
| 767 | + * @param String $arrival_airport_icao the arrival airport  | 
                                                        |
| 768 | + * @return String success or false  | 
                                                        |
| 769 | + *  | 
                                                        |
| 770 | + */  | 
                                                        |
| 771 | 771 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')  | 
                                                        
| 772 | 772 |  	{ | 
                                                        
| 773 | 773 | global $globalURL, $globalArchive, $globalDebug;  | 
                                                        
@@ -833,8 +833,8 @@ discard block  | 
                                                    ||
| 833 | 833 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        
| 834 | 834 | $status = filter_var($status,FILTER_SANITIZE_STRING);  | 
                                                        
| 835 | 835 | |
| 836 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 837 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 836 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 837 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 838 | 838 | |
| 839 | 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)';  | 
                                                        
@@ -844,9 +844,9 @@ discard block  | 
                                                    ||
| 844 | 844 | |
| 845 | 845 | $sth = $this->db->prepare($query);  | 
                                                        
| 846 | 846 | $sth->execute($query_values);  | 
                                                        
| 847 | -                } catch(PDOException $e) { | 
                                                        |
| 848 | - return "error : ".$e->getMessage();  | 
                                                        |
| 849 | - }  | 
                                                        |
| 847 | +				} catch(PDOException $e) { | 
                                                        |
| 848 | + return "error : ".$e->getMessage();  | 
                                                        |
| 849 | + }  | 
                                                        |
| 850 | 850 | /*  | 
                                                        
| 851 | 851 |  		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { | 
                                                        
| 852 | 852 | if ($globalDebug) echo '(Add to SBS archive : ';  | 
                                                        
@@ -16,33 +16,33 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | |
@@ -29,7 +29,9 @@ discard block  | 
                                                    ||
| 29 | 29 |  		if (isset($filter[0]['source'])) { | 
                                                        
| 30 | 30 | $filters = array_merge($filters,$filter);  | 
                                                        
| 31 | 31 | }  | 
                                                        
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 32 | +		if (is_array($globalFilter)) { | 
                                                        |
| 33 | + $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 34 | + }  | 
                                                        |
| 33 | 35 | $filter_query_join = '';  | 
                                                        
| 34 | 36 | $filter_query_where = '';  | 
                                                        
| 35 | 37 |  		foreach($filters as $flt) { | 
                                                        
@@ -76,8 +78,11 @@ discard block  | 
                                                    ||
| 76 | 78 |  		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 77 | 79 |  			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        
| 78 | 80 | }  | 
                                                        
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';  | 
                                                        |
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';  | 
                                                        |
| 81 | +		if ($filter_query_where == '' && $where) { | 
                                                        |
| 82 | + $filter_query_where = ' WHERE';  | 
                                                        |
| 83 | +		} elseif ($filter_query_where != '' && $and) { | 
                                                        |
| 84 | + $filter_query_where .= ' AND';  | 
                                                        |
| 85 | + }  | 
                                                        |
| 81 | 86 |  		if ($filter_query_where != '') { | 
                                                        
| 82 | 87 |  			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                        
| 83 | 88 | }  | 
                                                        
@@ -119,7 +124,9 @@ discard block  | 
                                                    ||
| 119 | 124 | }  | 
                                                        
| 120 | 125 | }  | 
                                                        
| 121 | 126 | |
| 122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 127 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 128 | + $globalLiveInterval = '200';  | 
                                                        |
| 129 | + }  | 
                                                        |
| 123 | 130 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 124 | 131 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";  | 
                                                        
| 125 | 132 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;  | 
                                                        
@@ -144,7 +151,9 @@ discard block  | 
                                                    ||
| 144 | 151 | |
| 145 | 152 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 146 | 153 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 154 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 155 | + $globalLiveInterval = '200';  | 
                                                        |
| 156 | + }  | 
                                                        |
| 148 | 157 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 149 | 158 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 150 | 159 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";  | 
                                                        
@@ -178,7 +187,9 @@ discard block  | 
                                                    ||
| 178 | 187 | |
| 179 | 188 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 180 | 189 | |
| 181 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 190 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 191 | + $globalLiveInterval = '200';  | 
                                                        |
| 192 | + }  | 
                                                        |
| 182 | 193 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 183 | 194 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 184 | 195 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'  | 
                                                        
@@ -211,7 +222,9 @@ discard block  | 
                                                    ||
| 211 | 222 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 212 | 223 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 213 | 224 | |
| 214 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 225 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 226 | + $globalLiveInterval = '200';  | 
                                                        |
| 227 | + }  | 
                                                        |
| 215 | 228 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 216 | 229 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        
| 217 | 230 |  		} else { | 
                                                        
@@ -239,7 +252,9 @@ discard block  | 
                                                    ||
| 239 | 252 |  	{ | 
                                                        
| 240 | 253 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 241 | 254 | $Spotter = new Spotter($this->db);  | 
                                                        
| 242 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 255 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 256 | + $globalLiveInterval = '200';  | 
                                                        |
| 257 | + }  | 
                                                        |
| 243 | 258 | $filter_query = $this->getFilter($filter);  | 
                                                        
| 244 | 259 | |
| 245 | 260 |  		if (is_array($coord)) { | 
                                                        
@@ -247,7 +262,9 @@ discard block  | 
                                                    ||
| 247 | 262 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 248 | 263 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 249 | 264 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 250 | - } else return array();  | 
                                                        |
| 265 | +		} else { | 
                                                        |
| 266 | + return array();  | 
                                                        |
| 267 | + }  | 
                                                        |
| 251 | 268 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 252 | 269 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;  | 
                                                        
| 253 | 270 |  		} else { | 
                                                        
@@ -411,11 +428,15 @@ discard block  | 
                                                    ||
| 411 | 428 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';  | 
                                                        
| 412 | 429 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 413 | 430 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';  | 
                                                        
| 414 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        |
| 431 | +			if ($liveinterval) { | 
                                                        |
| 432 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        |
| 433 | + }  | 
                                                        |
| 415 | 434 | $query .= ' ORDER BY date';  | 
                                                        
| 416 | 435 |  		} else { | 
                                                        
| 417 | 436 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';  | 
                                                        
| 418 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";  | 
                                                        |
| 437 | +			if ($liveinterval) { | 
                                                        |
| 438 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";  | 
                                                        |
| 439 | + }  | 
                                                        |
| 419 | 440 | $query .= ' ORDER BY date';  | 
                                                        
| 420 | 441 | }  | 
                                                        
| 421 | 442 | |
@@ -510,7 +531,9 @@ discard block  | 
                                                    ||
| 510 | 531 | $i++;  | 
                                                        
| 511 | 532 | $j++;  | 
                                                        
| 512 | 533 |  				if ($j == 30) { | 
                                                        
| 513 | - if ($globalDebug) echo ".";  | 
                                                        |
| 534 | +					if ($globalDebug) { | 
                                                        |
| 535 | + echo ".";  | 
                                                        |
| 536 | + }  | 
                                                        |
| 514 | 537 |  				    	try { | 
                                                        
| 515 | 538 | |
| 516 | 539 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
@@ -790,7 +813,9 @@ discard block  | 
                                                    ||
| 790 | 813 |  			{ | 
                                                        
| 791 | 814 | return false;  | 
                                                        
| 792 | 815 | }  | 
                                                        
| 793 | - } else return '';  | 
                                                        |
| 816 | +		} else { | 
                                                        |
| 817 | + return '';  | 
                                                        |
| 818 | + }  | 
                                                        |
| 794 | 819 | |
| 795 | 820 | if ($longitude != '')  | 
                                                        
| 796 | 821 |  		{ | 
                                                        
@@ -798,7 +823,9 @@ discard block  | 
                                                    ||
| 798 | 823 |  			{ | 
                                                        
| 799 | 824 | return false;  | 
                                                        
| 800 | 825 | }  | 
                                                        
| 801 | - } else return '';  | 
                                                        |
| 826 | +		} else { | 
                                                        |
| 827 | + return '';  | 
                                                        |
| 828 | + }  | 
                                                        |
| 802 | 829 | |
| 803 | 830 | |
| 804 | 831 | if ($heading != '')  | 
                                                        
@@ -807,7 +834,9 @@ discard block  | 
                                                    ||
| 807 | 834 |  			{ | 
                                                        
| 808 | 835 | return false;  | 
                                                        
| 809 | 836 | }  | 
                                                        
| 810 | - } else $heading = 0;  | 
                                                        |
| 837 | +		} else { | 
                                                        |
| 838 | + $heading = 0;  | 
                                                        |
| 839 | + }  | 
                                                        |
| 811 | 840 | |
| 812 | 841 | if ($groundspeed != '')  | 
                                                        
| 813 | 842 |  		{ | 
                                                        
@@ -815,9 +844,13 @@ discard block  | 
                                                    ||
| 815 | 844 |  			{ | 
                                                        
| 816 | 845 | return false;  | 
                                                        
| 817 | 846 | }  | 
                                                        
| 818 | - } else $groundspeed = 0;  | 
                                                        |
| 847 | +		} else { | 
                                                        |
| 848 | + $groundspeed = 0;  | 
                                                        |
| 849 | + }  | 
                                                        |
| 819 | 850 |  		date_default_timezone_set('UTC'); | 
                                                        
| 820 | -		if ($date == '') $date = date("Y-m-d H:i:s", time()); | 
                                                        |
| 851 | +		if ($date == '') { | 
                                                        |
| 852 | +			$date = date("Y-m-d H:i:s", time()); | 
                                                        |
| 853 | + }  | 
                                                        |
| 821 | 854 | |
| 822 | 855 | |
| 823 | 856 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);  | 
                                                        
@@ -833,8 +866,12 @@ discard block  | 
                                                    ||
| 833 | 866 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        
| 834 | 867 | $status = filter_var($status,FILTER_SANITIZE_STRING);  | 
                                                        
| 835 | 868 | |
| 836 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 837 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 869 | +            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { | 
                                                        |
| 870 | + $groundspeed = 0;  | 
                                                        |
| 871 | + }  | 
                                                        |
| 872 | +            	if ($heading == '' || $Common->isInteger($heading) === false ) { | 
                                                        |
| 873 | + $heading = 0;  | 
                                                        |
| 874 | + }  | 
                                                        |
| 838 | 875 | |
| 839 | 876 | $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status)  | 
                                                        
| 840 | 877 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status)';  | 
                                                        
@@ -15,7 +15,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | */  | 
                                                        
@@ -13,10 +13,10 @@ discard block  | 
                                                    ||
| 13 | 13 | }  | 
                                                        
| 14 | 14 | |
| 15 | 15 | /**  | 
                                                        
| 16 | - * Get SQL query part for filter used  | 
                                                        |
| 17 | - * @param Array $filter the filter  | 
                                                        |
| 18 | - * @return Array the SQL part  | 
                                                        |
| 19 | - */  | 
                                                        |
| 16 | + * Get SQL query part for filter used  | 
                                                        |
| 17 | + * @param Array $filter the filter  | 
                                                        |
| 18 | + * @return Array the SQL part  | 
                                                        |
| 19 | + */  | 
                                                        |
| 20 | 20 | |
| 21 | 21 |  	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        
| 22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
@@ -80,14 +80,14 @@ discard block  | 
                                                    ||
| 80 | 80 | }  | 
                                                        
| 81 | 81 | |
| 82 | 82 | /**  | 
                                                        
| 83 | - * Executes the SQL statements to get the spotter information  | 
                                                        |
| 84 | - *  | 
                                                        |
| 85 | - * @param String $query the SQL query  | 
                                                        |
| 86 | - * @param Array $params parameter of the query  | 
                                                        |
| 87 | - * @param String $limitQuery the limit query  | 
                                                        |
| 88 | - * @return Array the spotter information  | 
                                                        |
| 89 | - *  | 
                                                        |
| 90 | - */  | 
                                                        |
| 83 | + * Executes the SQL statements to get the spotter information  | 
                                                        |
| 84 | + *  | 
                                                        |
| 85 | + * @param String $query the SQL query  | 
                                                        |
| 86 | + * @param Array $params parameter of the query  | 
                                                        |
| 87 | + * @param String $limitQuery the limit query  | 
                                                        |
| 88 | + * @return Array the spotter information  | 
                                                        |
| 89 | + *  | 
                                                        |
| 90 | + */  | 
                                                        |
| 91 | 91 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)  | 
                                                        
| 92 | 92 |  	{ | 
                                                        
| 93 | 93 |  		date_default_timezone_set('UTC'); | 
                                                        
@@ -200,11 +200,11 @@ discard block  | 
                                                    ||
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | /**  | 
                                                        
| 203 | - * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 204 | - *  | 
                                                        |
| 205 | - * @return Array the spotter information  | 
                                                        |
| 206 | - *  | 
                                                        |
| 207 | - */  | 
                                                        |
| 203 | + * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 204 | + *  | 
                                                        |
| 205 | + * @return Array the spotter information  | 
                                                        |
| 206 | + *  | 
                                                        |
| 207 | + */  | 
                                                        |
| 208 | 208 | public function getLatestTrackerData($limit = '', $sort = '', $filter = array())  | 
                                                        
| 209 | 209 |  	{ | 
                                                        
| 210 | 210 | global $global_query;  | 
                                                        
@@ -262,11 +262,11 @@ discard block  | 
                                                    ||
| 262 | 262 | }  | 
                                                        
| 263 | 263 | |
| 264 | 264 | /**  | 
                                                        
| 265 | - * Gets all the spotter information based on the callsign  | 
                                                        |
| 266 | - *  | 
                                                        |
| 267 | - * @return Array the spotter information  | 
                                                        |
| 268 | - *  | 
                                                        |
| 269 | - */  | 
                                                        |
| 265 | + * Gets all the spotter information based on the callsign  | 
                                                        |
| 266 | + *  | 
                                                        |
| 267 | + * @return Array the spotter information  | 
                                                        |
| 268 | + *  | 
                                                        |
| 269 | + */  | 
                                                        |
| 270 | 270 | public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())  | 
                                                        
| 271 | 271 |  	{ | 
                                                        
| 272 | 272 | global $global_query;  | 
                                                        
@@ -377,12 +377,12 @@ discard block  | 
                                                    ||
| 377 | 377 | |
| 378 | 378 | |
| 379 | 379 | /**  | 
                                                        
| 380 | - * Gets all source name  | 
                                                        |
| 381 | - *  | 
                                                        |
| 382 | - * @param String type format of source  | 
                                                        |
| 383 | - * @return Array list of source name  | 
                                                        |
| 384 | - *  | 
                                                        |
| 385 | - */  | 
                                                        |
| 380 | + * Gets all source name  | 
                                                        |
| 381 | + *  | 
                                                        |
| 382 | + * @param String type format of source  | 
                                                        |
| 383 | + * @return Array list of source name  | 
                                                        |
| 384 | + *  | 
                                                        |
| 385 | + */  | 
                                                        |
| 386 | 386 | public function getAllSourceName($type = '',$filters = array())  | 
                                                        
| 387 | 387 |  	{ | 
                                                        
| 388 | 388 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
@@ -412,11 +412,11 @@ discard block  | 
                                                    ||
| 412 | 412 | |
| 413 | 413 | |
| 414 | 414 | /**  | 
                                                        
| 415 | - * Gets a list of all idents/callsigns  | 
                                                        |
| 416 | - *  | 
                                                        |
| 417 | - * @return Array list of ident/callsign names  | 
                                                        |
| 418 | - *  | 
                                                        |
| 419 | - */  | 
                                                        |
| 415 | + * Gets a list of all idents/callsigns  | 
                                                        |
| 416 | + *  | 
                                                        |
| 417 | + * @return Array list of ident/callsign names  | 
                                                        |
| 418 | + *  | 
                                                        |
| 419 | + */  | 
                                                        |
| 420 | 420 | public function getAllIdents($filters = array())  | 
                                                        
| 421 | 421 |  	{ | 
                                                        
| 422 | 422 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
@@ -484,18 +484,18 @@ discard block  | 
                                                    ||
| 484 | 484 | |
| 485 | 485 | |
| 486 | 486 | /**  | 
                                                        
| 487 | - * Update ident spotter data  | 
                                                        |
| 488 | - *  | 
                                                        |
| 489 | - * @param String $flightaware_id the ID from flightaware  | 
                                                        |
| 490 | - * @param String $ident the flight ident  | 
                                                        |
| 491 | - * @return String success or false  | 
                                                        |
| 492 | - *  | 
                                                        |
| 493 | - */  | 
                                                        |
| 487 | + * Update ident spotter data  | 
                                                        |
| 488 | + *  | 
                                                        |
| 489 | + * @param String $flightaware_id the ID from flightaware  | 
                                                        |
| 490 | + * @param String $ident the flight ident  | 
                                                        |
| 491 | + * @return String success or false  | 
                                                        |
| 492 | + *  | 
                                                        |
| 493 | + */  | 
                                                        |
| 494 | 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);  | 
                                                        
@@ -508,18 +508,18 @@ discard block  | 
                                                    ||
| 508 | 508 | |
| 509 | 509 | }  | 
                                                        
| 510 | 510 | /**  | 
                                                        
| 511 | - * Update latest spotter data  | 
                                                        |
| 512 | - *  | 
                                                        |
| 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 | - *  | 
                                                        |
| 518 | - */  | 
                                                        |
| 511 | + * Update latest spotter data  | 
                                                        |
| 512 | + *  | 
                                                        |
| 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 | + *  | 
                                                        |
| 518 | + */  | 
                                                        |
| 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);  | 
                                                        
@@ -533,32 +533,32 @@ discard block  | 
                                                    ||
| 533 | 533 | }  | 
                                                        
| 534 | 534 | |
| 535 | 535 | /**  | 
                                                        
| 536 | - * Adds a new spotter data  | 
                                                        |
| 537 | - *  | 
                                                        |
| 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 | - */  | 
                                                        |
| 536 | + * Adds a new spotter data  | 
                                                        |
| 537 | + *  | 
                                                        |
| 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 | + */  | 
                                                        |
| 562 | 562 | public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')  | 
                                                        
| 563 | 563 |  	{ | 
                                                        
| 564 | 564 | global $globalURL;  | 
                                                        
@@ -643,16 +643,16 @@ discard block  | 
                                                    ||
| 643 | 643 | $comment = filter_var($comment,FILTER_SANITIZE_STRING);  | 
                                                        
| 644 | 644 | $type = filter_var($type,FILTER_SANITIZE_STRING);  | 
                                                        
| 645 | 645 | |
| 646 | -                if ($latitude == '' && $longitude == '') { | 
                                                        |
| 647 | - $latitude = 0;  | 
                                                        |
| 648 | - $longitude = 0;  | 
                                                        |
| 649 | - }  | 
                                                        |
| 650 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;  | 
                                                        |
| 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)  | 
                                                        |
| 646 | +				if ($latitude == '' && $longitude == '') { | 
                                                        |
| 647 | + $latitude = 0;  | 
                                                        |
| 648 | + $longitude = 0;  | 
                                                        |
| 649 | + }  | 
                                                        |
| 650 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;  | 
                                                        |
| 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)  | 
                                                        |
| 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 | |
@@ -660,7 +660,7 @@ discard block  | 
                                                    ||
| 660 | 660 | $sth->execute($query_values);  | 
                                                        
| 661 | 661 | $this->db = null;  | 
                                                        
| 662 | 662 |  		} catch (PDOException $e) { | 
                                                        
| 663 | - return "error : ".$e->getMessage();  | 
                                                        |
| 663 | + return "error : ".$e->getMessage();  | 
                                                        |
| 664 | 664 | }  | 
                                                        
| 665 | 665 | |
| 666 | 666 | return "success";  | 
                                                        
@@ -669,11 +669,11 @@ discard block  | 
                                                    ||
| 669 | 669 | |
| 670 | 670 | |
| 671 | 671 | /**  | 
                                                        
| 672 | - * Gets the aircraft ident within the last hour  | 
                                                        |
| 673 | - *  | 
                                                        |
| 674 | - * @return String the ident  | 
                                                        |
| 675 | - *  | 
                                                        |
| 676 | - */  | 
                                                        |
| 672 | + * Gets the aircraft ident within the last hour  | 
                                                        |
| 673 | + *  | 
                                                        |
| 674 | + * @return String the ident  | 
                                                        |
| 675 | + *  | 
                                                        |
| 676 | + */  | 
                                                        |
| 677 | 677 | public function getIdentFromLastHour($ident)  | 
                                                        
| 678 | 678 |  	{ | 
                                                        
| 679 | 679 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -689,11 +689,11 @@ discard block  | 
                                                    ||
| 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'";  | 
                                                        
| 691 | 691 |  			$query_data = array(':ident' => $ident); | 
                                                        
| 692 | - }  | 
                                                        |
| 692 | + }  | 
                                                        |
| 693 | 693 | |
| 694 | 694 | $sth = $this->db->prepare($query);  | 
                                                        
| 695 | 695 | $sth->execute($query_data);  | 
                                                        
| 696 | - $ident_result='';  | 
                                                        |
| 696 | + $ident_result='';  | 
                                                        |
| 697 | 697 | while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        
| 698 | 698 |  		{ | 
                                                        
| 699 | 699 | $ident_result = $row['ident'];  | 
                                                        
@@ -704,11 +704,11 @@ discard block  | 
                                                    ||
| 704 | 704 | |
| 705 | 705 | |
| 706 | 706 | /**  | 
                                                        
| 707 | - * Gets the aircraft data from the last 20 seconds  | 
                                                        |
| 708 | - *  | 
                                                        |
| 709 | - * @return Array the spotter data  | 
                                                        |
| 710 | - *  | 
                                                        |
| 711 | - */  | 
                                                        |
| 707 | + * Gets the aircraft data from the last 20 seconds  | 
                                                        |
| 708 | + *  | 
                                                        |
| 709 | + * @return Array the spotter data  | 
                                                        |
| 710 | + *  | 
                                                        |
| 711 | + */  | 
                                                        |
| 712 | 712 | public function getRealTimeData($q = '')  | 
                                                        
| 713 | 713 |  	{ | 
                                                        
| 714 | 714 | global $globalDBdriver;  | 
                                                        
@@ -746,11 +746,11 @@ discard block  | 
                                                    ||
| 746 | 746 | |
| 747 | 747 | |
| 748 | 748 | /**  | 
                                                        
| 749 | - * Gets all number of flight over countries  | 
                                                        |
| 750 | - *  | 
                                                        |
| 751 | - * @return Array the airline country list  | 
                                                        |
| 752 | - *  | 
                                                        |
| 753 | - */  | 
                                                        |
| 749 | + * Gets all number of flight over countries  | 
                                                        |
| 750 | + *  | 
                                                        |
| 751 | + * @return Array the airline country list  | 
                                                        |
| 752 | + *  | 
                                                        |
| 753 | + */  | 
                                                        |
| 754 | 754 | /*  | 
                                                        
| 755 | 755 | public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())  | 
                                                        
| 756 | 756 |  	{ | 
                                                        
@@ -801,11 +801,11 @@ discard block  | 
                                                    ||
| 801 | 801 | |
| 802 | 802 | |
| 803 | 803 | /**  | 
                                                        
| 804 | - * Gets all callsigns that have flown over  | 
                                                        |
| 805 | - *  | 
                                                        |
| 806 | - * @return Array the callsign list  | 
                                                        |
| 807 | - *  | 
                                                        |
| 808 | - */  | 
                                                        |
| 804 | + * Gets all callsigns that have flown over  | 
                                                        |
| 805 | + *  | 
                                                        |
| 806 | + * @return Array the callsign list  | 
                                                        |
| 807 | + *  | 
                                                        |
| 808 | + */  | 
                                                        |
| 809 | 809 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')  | 
                                                        
| 810 | 810 |  	{ | 
                                                        
| 811 | 811 | global $globalDBdriver;  | 
                                                        
@@ -872,11 +872,11 @@ discard block  | 
                                                    ||
| 872 | 872 | |
| 873 | 873 | |
| 874 | 874 | /**  | 
                                                        
| 875 | - * Counts all dates  | 
                                                        |
| 876 | - *  | 
                                                        |
| 877 | - * @return Array the date list  | 
                                                        |
| 878 | - *  | 
                                                        |
| 879 | - */  | 
                                                        |
| 875 | + * Counts all dates  | 
                                                        |
| 876 | + *  | 
                                                        |
| 877 | + * @return Array the date list  | 
                                                        |
| 878 | + *  | 
                                                        |
| 879 | + */  | 
                                                        |
| 880 | 880 | public function countAllDates($filters = array())  | 
                                                        
| 881 | 881 |  	{ | 
                                                        
| 882 | 882 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -922,11 +922,11 @@ discard block  | 
                                                    ||
| 922 | 922 | |
| 923 | 923 | |
| 924 | 924 | /**  | 
                                                        
| 925 | - * Counts all dates during the last 7 days  | 
                                                        |
| 926 | - *  | 
                                                        |
| 927 | - * @return Array the date list  | 
                                                        |
| 928 | - *  | 
                                                        |
| 929 | - */  | 
                                                        |
| 925 | + * Counts all dates during the last 7 days  | 
                                                        |
| 926 | + *  | 
                                                        |
| 927 | + * @return Array the date list  | 
                                                        |
| 928 | + *  | 
                                                        |
| 929 | + */  | 
                                                        |
| 930 | 930 | public function countAllDatesLast7Days($filters = array())  | 
                                                        
| 931 | 931 |  	{ | 
                                                        
| 932 | 932 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -948,7 +948,7 @@ discard block  | 
                                                    ||
| 948 | 948 | $query .= " GROUP BY date_name  | 
                                                        
| 949 | 949 | ORDER BY date_name ASC";  | 
                                                        
| 950 | 950 |  			$query_data = array(':offset' => $offset); | 
                                                        
| 951 | - }  | 
                                                        |
| 951 | + }  | 
                                                        |
| 952 | 952 | |
| 953 | 953 | $sth = $this->db->prepare($query);  | 
                                                        
| 954 | 954 | $sth->execute($query_data);  | 
                                                        
@@ -968,11 +968,11 @@ discard block  | 
                                                    ||
| 968 | 968 | }  | 
                                                        
| 969 | 969 | |
| 970 | 970 | /**  | 
                                                        
| 971 | - * Counts all dates during the last month  | 
                                                        |
| 972 | - *  | 
                                                        |
| 973 | - * @return Array the date list  | 
                                                        |
| 974 | - *  | 
                                                        |
| 975 | - */  | 
                                                        |
| 971 | + * Counts all dates during the last month  | 
                                                        |
| 972 | + *  | 
                                                        |
| 973 | + * @return Array the date list  | 
                                                        |
| 974 | + *  | 
                                                        |
| 975 | + */  | 
                                                        |
| 976 | 976 | public function countAllDatesLastMonth($filters = array())  | 
                                                        
| 977 | 977 |  	{ | 
                                                        
| 978 | 978 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -994,7 +994,7 @@ discard block  | 
                                                    ||
| 994 | 994 | $query .= " GROUP BY date_name  | 
                                                        
| 995 | 995 | ORDER BY date_name ASC";  | 
                                                        
| 996 | 996 |  			$query_data = array(':offset' => $offset); | 
                                                        
| 997 | - }  | 
                                                        |
| 997 | + }  | 
                                                        |
| 998 | 998 | |
| 999 | 999 | $sth = $this->db->prepare($query);  | 
                                                        
| 1000 | 1000 | $sth->execute($query_data);  | 
                                                        
@@ -1016,11 +1016,11 @@ discard block  | 
                                                    ||
| 1016 | 1016 | |
| 1017 | 1017 | |
| 1018 | 1018 | /**  | 
                                                        
| 1019 | - * Counts all month  | 
                                                        |
| 1020 | - *  | 
                                                        |
| 1021 | - * @return Array the month list  | 
                                                        |
| 1022 | - *  | 
                                                        |
| 1023 | - */  | 
                                                        |
| 1019 | + * Counts all month  | 
                                                        |
| 1020 | + *  | 
                                                        |
| 1021 | + * @return Array the month list  | 
                                                        |
| 1022 | + *  | 
                                                        |
| 1023 | + */  | 
                                                        |
| 1024 | 1024 | public function countAllMonths($filters = array())  | 
                                                        
| 1025 | 1025 |  	{ | 
                                                        
| 1026 | 1026 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1065,11 +1065,11 @@ discard block  | 
                                                    ||
| 1065 | 1065 | |
| 1066 | 1066 | |
| 1067 | 1067 | /**  | 
                                                        
| 1068 | - * Counts all dates during the last year  | 
                                                        |
| 1069 | - *  | 
                                                        |
| 1070 | - * @return Array the date list  | 
                                                        |
| 1071 | - *  | 
                                                        |
| 1072 | - */  | 
                                                        |
| 1068 | + * Counts all dates during the last year  | 
                                                        |
| 1069 | + *  | 
                                                        |
| 1070 | + * @return Array the date list  | 
                                                        |
| 1071 | + *  | 
                                                        |
| 1072 | + */  | 
                                                        |
| 1073 | 1073 | public function countAllMonthsLastYear($filters)  | 
                                                        
| 1074 | 1074 |  	{ | 
                                                        
| 1075 | 1075 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1091,7 +1091,7 @@ discard block  | 
                                                    ||
| 1091 | 1091 | $query .= " GROUP BY year_name, month_name  | 
                                                        
| 1092 | 1092 | ORDER BY year_name, month_name ASC";  | 
                                                        
| 1093 | 1093 |  			$query_data = array(':offset' => $offset); | 
                                                        
| 1094 | - }  | 
                                                        |
| 1094 | + }  | 
                                                        |
| 1095 | 1095 | |
| 1096 | 1096 | $sth = $this->db->prepare($query);  | 
                                                        
| 1097 | 1097 | $sth->execute($query_data);  | 
                                                        
@@ -1114,11 +1114,11 @@ discard block  | 
                                                    ||
| 1114 | 1114 | |
| 1115 | 1115 | |
| 1116 | 1116 | /**  | 
                                                        
| 1117 | - * Counts all hours  | 
                                                        |
| 1118 | - *  | 
                                                        |
| 1119 | - * @return Array the hour list  | 
                                                        |
| 1120 | - *  | 
                                                        |
| 1121 | - */  | 
                                                        |
| 1117 | + * Counts all hours  | 
                                                        |
| 1118 | + *  | 
                                                        |
| 1119 | + * @return Array the hour list  | 
                                                        |
| 1120 | + *  | 
                                                        |
| 1121 | + */  | 
                                                        |
| 1122 | 1122 | public function countAllHours($orderby,$filters = array())  | 
                                                        
| 1123 | 1123 |  	{ | 
                                                        
| 1124 | 1124 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1181,11 +1181,11 @@ discard block  | 
                                                    ||
| 1181 | 1181 | |
| 1182 | 1182 | |
| 1183 | 1183 | /**  | 
                                                        
| 1184 | - * Counts all hours by date  | 
                                                        |
| 1185 | - *  | 
                                                        |
| 1186 | - * @return Array the hour list  | 
                                                        |
| 1187 | - *  | 
                                                        |
| 1188 | - */  | 
                                                        |
| 1184 | + * Counts all hours by date  | 
                                                        |
| 1185 | + *  | 
                                                        |
| 1186 | + * @return Array the hour list  | 
                                                        |
| 1187 | + *  | 
                                                        |
| 1188 | + */  | 
                                                        |
| 1189 | 1189 | public function countAllHoursByDate($date, $filters = array())  | 
                                                        
| 1190 | 1190 |  	{ | 
                                                        
| 1191 | 1191 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1229,11 +1229,11 @@ discard block  | 
                                                    ||
| 1229 | 1229 | |
| 1230 | 1230 | |
| 1231 | 1231 | /**  | 
                                                        
| 1232 | - * Counts all hours by a ident/callsign  | 
                                                        |
| 1233 | - *  | 
                                                        |
| 1234 | - * @return Array the hour list  | 
                                                        |
| 1235 | - *  | 
                                                        |
| 1236 | - */  | 
                                                        |
| 1232 | + * Counts all hours by a ident/callsign  | 
                                                        |
| 1233 | + *  | 
                                                        |
| 1234 | + * @return Array the hour list  | 
                                                        |
| 1235 | + *  | 
                                                        |
| 1236 | + */  | 
                                                        |
| 1237 | 1237 | public function countAllHoursByIdent($ident, $filters = array())  | 
                                                        
| 1238 | 1238 |  	{ | 
                                                        
| 1239 | 1239 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1278,11 +1278,11 @@ discard block  | 
                                                    ||
| 1278 | 1278 | |
| 1279 | 1279 | |
| 1280 | 1280 | /**  | 
                                                        
| 1281 | - * Counts all flights that have flown over  | 
                                                        |
| 1282 | - *  | 
                                                        |
| 1283 | - * @return Integer the number of flights  | 
                                                        |
| 1284 | - *  | 
                                                        |
| 1285 | - */  | 
                                                        |
| 1281 | + * Counts all flights that have flown over  | 
                                                        |
| 1282 | + *  | 
                                                        |
| 1283 | + * @return Integer the number of flights  | 
                                                        |
| 1284 | + *  | 
                                                        |
| 1285 | + */  | 
                                                        |
| 1286 | 1286 | public function countOverallTracked($filters = array(),$year = '',$month = '')  | 
                                                        
| 1287 | 1287 |  	{ | 
                                                        
| 1288 | 1288 | global $globalDBdriver;  | 
                                                        
@@ -1317,11 +1317,11 @@ discard block  | 
                                                    ||
| 1317 | 1317 | |
| 1318 | 1318 | |
| 1319 | 1319 | /**  | 
                                                        
| 1320 | - * Counts all hours of today  | 
                                                        |
| 1321 | - *  | 
                                                        |
| 1322 | - * @return Array the hour list  | 
                                                        |
| 1323 | - *  | 
                                                        |
| 1324 | - */  | 
                                                        |
| 1320 | + * Counts all hours of today  | 
                                                        |
| 1321 | + *  | 
                                                        |
| 1322 | + * @return Array the hour list  | 
                                                        |
| 1323 | + *  | 
                                                        |
| 1324 | + */  | 
                                                        |
| 1325 | 1325 | public function countAllHoursFromToday($filters = array())  | 
                                                        
| 1326 | 1326 |  	{ | 
                                                        
| 1327 | 1327 | global $globalTimezone, $globalDBdriver;  | 
                                                        
@@ -1361,12 +1361,12 @@ discard block  | 
                                                    ||
| 1361 | 1361 | }  | 
                                                        
| 1362 | 1362 | |
| 1363 | 1363 | |
| 1364 | - /**  | 
                                                        |
| 1365 | - * Gets the Barrie Spotter ID based on the FlightAware ID  | 
                                                        |
| 1366 | - *  | 
                                                        |
| 1367 | - * @return Integer the Barrie Spotter ID  | 
                                                        |
| 1364 | + /**  | 
                                                        |
| 1365 | + * Gets the Barrie Spotter ID based on the FlightAware ID  | 
                                                        |
| 1366 | + *  | 
                                                        |
| 1367 | + * @return Integer the Barrie Spotter ID  | 
                                                        |
| 1368 | 1368 | q *  | 
                                                        
| 1369 | - */  | 
                                                        |
| 1369 | + */  | 
                                                        |
| 1370 | 1370 | public function getTrackerIDBasedOnFamTrackID($famtrackid)  | 
                                                        
| 1371 | 1371 |  	{ | 
                                                        
| 1372 | 1372 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);  | 
                                                        
@@ -1387,13 +1387,13 @@ discard block  | 
                                                    ||
| 1387 | 1387 | |
| 1388 | 1388 | |
| 1389 | 1389 | /**  | 
                                                        
| 1390 | - * Parses a date string  | 
                                                        |
| 1391 | - *  | 
                                                        |
| 1392 | - * @param String $dateString the date string  | 
                                                        |
| 1393 | - * @param String $timezone the timezone of a user  | 
                                                        |
| 1394 | - * @return Array the time information  | 
                                                        |
| 1395 | - *  | 
                                                        |
| 1396 | - */  | 
                                                        |
| 1390 | + * Parses a date string  | 
                                                        |
| 1391 | + *  | 
                                                        |
| 1392 | + * @param String $dateString the date string  | 
                                                        |
| 1393 | + * @param String $timezone the timezone of a user  | 
                                                        |
| 1394 | + * @return Array the time information  | 
                                                        |
| 1395 | + *  | 
                                                        |
| 1396 | + */  | 
                                                        |
| 1397 | 1397 | public function parseDateString($dateString, $timezone = '')  | 
                                                        
| 1398 | 1398 |  	{ | 
                                                        
| 1399 | 1399 | $time_array = array();  | 
                                                        
@@ -1426,12 +1426,12 @@ discard block  | 
                                                    ||
| 1426 | 1426 | }  | 
                                                        
| 1427 | 1427 | |
| 1428 | 1428 | /**  | 
                                                        
| 1429 | - * Parses the direction degrees to working  | 
                                                        |
| 1430 | - *  | 
                                                        |
| 1431 | - * @param Float $direction the direction in degrees  | 
                                                        |
| 1432 | - * @return Array the direction information  | 
                                                        |
| 1433 | - *  | 
                                                        |
| 1434 | - */  | 
                                                        |
| 1429 | + * Parses the direction degrees to working  | 
                                                        |
| 1430 | + *  | 
                                                        |
| 1431 | + * @param Float $direction the direction in degrees  | 
                                                        |
| 1432 | + * @return Array the direction information  | 
                                                        |
| 1433 | + *  | 
                                                        |
| 1434 | + */  | 
                                                        |
| 1435 | 1435 | public function parseDirection($direction = 0)  | 
                                                        
| 1436 | 1436 |  	{ | 
                                                        
| 1437 | 1437 | if ($direction == '') $direction = 0;  | 
                                                        
@@ -1510,12 +1510,12 @@ discard block  | 
                                                    ||
| 1510 | 1510 | |
| 1511 | 1511 | |
| 1512 | 1512 | /**  | 
                                                        
| 1513 | - * Gets Country from latitude/longitude  | 
                                                        |
| 1514 | - *  | 
                                                        |
| 1515 | - * @param Float $latitude latitute of the flight  | 
                                                        |
| 1516 | - * @param Float $longitude longitute of the flight  | 
                                                        |
| 1517 | - * @return String the countrie  | 
                                                        |
| 1518 | - */  | 
                                                        |
| 1513 | + * Gets Country from latitude/longitude  | 
                                                        |
| 1514 | + *  | 
                                                        |
| 1515 | + * @param Float $latitude latitute of the flight  | 
                                                        |
| 1516 | + * @param Float $longitude longitute of the flight  | 
                                                        |
| 1517 | + * @return String the countrie  | 
                                                        |
| 1518 | + */  | 
                                                        |
| 1519 | 1519 | public function getCountryFromLatitudeLongitude($latitude,$longitude)  | 
                                                        
| 1520 | 1520 |  	{ | 
                                                        
| 1521 | 1521 | global $globalDBdriver, $globalDebug;  | 
                                                        
@@ -1552,11 +1552,11 @@ discard block  | 
                                                    ||
| 1552 | 1552 | }  | 
                                                        
| 1553 | 1553 | |
| 1554 | 1554 | /**  | 
                                                        
| 1555 | - * Gets Country from iso2  | 
                                                        |
| 1556 | - *  | 
                                                        |
| 1557 | - * @param String $iso2 ISO2 country code  | 
                                                        |
| 1558 | - * @return String the countrie  | 
                                                        |
| 1559 | - */  | 
                                                        |
| 1555 | + * Gets Country from iso2  | 
                                                        |
| 1556 | + *  | 
                                                        |
| 1557 | + * @param String $iso2 ISO2 country code  | 
                                                        |
| 1558 | + * @return String the countrie  | 
                                                        |
| 1559 | + */  | 
                                                        |
| 1560 | 1560 | public function getCountryFromISO2($iso2)  | 
                                                        
| 1561 | 1561 |  	{ | 
                                                        
| 1562 | 1562 | global $globalDBdriver, $globalDebug;  | 
                                                        
@@ -1585,12 +1585,12 @@ discard block  | 
                                                    ||
| 1585 | 1585 | |
| 1586 | 1586 | |
| 1587 | 1587 | /**  | 
                                                        
| 1588 | - * Gets the short url from bit.ly  | 
                                                        |
| 1589 | - *  | 
                                                        |
| 1590 | - * @param String $url the full url  | 
                                                        |
| 1591 | - * @return String the bit.ly url  | 
                                                        |
| 1592 | - *  | 
                                                        |
| 1593 | - */  | 
                                                        |
| 1588 | + * Gets the short url from bit.ly  | 
                                                        |
| 1589 | + *  | 
                                                        |
| 1590 | + * @param String $url the full url  | 
                                                        |
| 1591 | + * @return String the bit.ly url  | 
                                                        |
| 1592 | + *  | 
                                                        |
| 1593 | + */  | 
                                                        |
| 1594 | 1594 | public function getBitlyURL($url)  | 
                                                        
| 1595 | 1595 |  	{ | 
                                                        
| 1596 | 1596 | global $globalBitlyAccessToken;  | 
                                                        
@@ -4,7 +4,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | |
@@ -31,7 +31,9 @@ discard block  | 
                                                    ||
| 31 | 31 |  		if (isset($filter[0]['source'])) { | 
                                                        
| 32 | 32 | $filters = array_merge($filters,$filter);  | 
                                                        
| 33 | 33 | }  | 
                                                        
| 34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 34 | +		if (is_array($globalFilter)) { | 
                                                        |
| 35 | + $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 36 | + }  | 
                                                        |
| 35 | 37 | $filter_query_join = '';  | 
                                                        
| 36 | 38 | $filter_query_where = '';  | 
                                                        
| 37 | 39 |  		foreach($filters as $flt) { | 
                                                        
@@ -70,8 +72,11 @@ discard block  | 
                                                    ||
| 70 | 72 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";  | 
                                                        
| 71 | 73 | }  | 
                                                        
| 72 | 74 | }  | 
                                                        
| 73 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';  | 
                                                        |
| 74 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';  | 
                                                        |
| 75 | +		if ($filter_query_where == '' && $where) { | 
                                                        |
| 76 | + $filter_query_where = ' WHERE';  | 
                                                        |
| 77 | +		} elseif ($filter_query_where != '' && $and) { | 
                                                        |
| 78 | + $filter_query_where .= ' AND';  | 
                                                        |
| 79 | + }  | 
                                                        |
| 75 | 80 |  		if ($filter_query_where != '') { | 
                                                        
| 76 | 81 |  			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                        
| 77 | 82 | }  | 
                                                        
@@ -125,26 +130,43 @@ discard block  | 
                                                    ||
| 125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_id'];  | 
                                                        
| 126 | 131 |  			} elseif (isset($row['spotter_archive_output_id'])) { | 
                                                        
| 127 | 132 | $temp_array['spotter_id'] = $row['spotter_archive_output_id'];  | 
                                                        
| 128 | - */}  | 
                                                        |
| 129 | -			elseif (isset($row['trackerid'])) { | 
                                                        |
| 133 | +			*/} elseif (isset($row['trackerid'])) { | 
                                                        |
| 130 | 134 | $temp_array['trackerid'] = $row['trackerid'];  | 
                                                        
| 131 | 135 |  			} else { | 
                                                        
| 132 | 136 | $temp_array['trackerid'] = '';  | 
                                                        
| 133 | 137 | }  | 
                                                        
| 134 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];  | 
                                                        |
| 135 | - if (isset($row['type'])) $temp_array['type'] = $row['type'];  | 
                                                        |
| 136 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];  | 
                                                        |
| 138 | +			if (isset($row['famtrackid'])) { | 
                                                        |
| 139 | + $temp_array['famtrackid'] = $row['famtrackid'];  | 
                                                        |
| 140 | + }  | 
                                                        |
| 141 | +			if (isset($row['type'])) { | 
                                                        |
| 142 | + $temp_array['type'] = $row['type'];  | 
                                                        |
| 143 | + }  | 
                                                        |
| 144 | +			if (isset($row['comment'])) { | 
                                                        |
| 145 | + $temp_array['comment'] = $row['comment'];  | 
                                                        |
| 146 | + }  | 
                                                        |
| 137 | 147 | $temp_array['ident'] = $row['ident'];  | 
                                                        
| 138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];  | 
                                                        |
| 139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];  | 
                                                        |
| 140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];  | 
                                                        |
| 141 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];  | 
                                                        |
| 148 | +			if (isset($row['latitude'])) { | 
                                                        |
| 149 | + $temp_array['latitude'] = $row['latitude'];  | 
                                                        |
| 150 | + }  | 
                                                        |
| 151 | +			if (isset($row['longitude'])) { | 
                                                        |
| 152 | + $temp_array['longitude'] = $row['longitude'];  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | +			if (isset($row['format_source'])) { | 
                                                        |
| 155 | + $temp_array['format_source'] = $row['format_source'];  | 
                                                        |
| 156 | + }  | 
                                                        |
| 157 | +			if (isset($row['altitude'])) { | 
                                                        |
| 158 | + $temp_array['altitude'] = $row['altitude'];  | 
                                                        |
| 159 | + }  | 
                                                        |
| 142 | 160 |  			if (isset($row['heading'])) { | 
                                                        
| 143 | 161 | $temp_array['heading'] = $row['heading'];  | 
                                                        
| 144 | 162 | $heading_direction = $this->parseDirection($row['heading']);  | 
                                                        
| 145 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];  | 
                                                        |
| 163 | +				if (isset($heading_direction[0]['direction_fullname'])) { | 
                                                        |
| 164 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];  | 
                                                        |
| 165 | + }  | 
                                                        |
| 166 | + }  | 
                                                        |
| 167 | +			if (isset($row['ground_speed'])) { | 
                                                        |
| 168 | + $temp_array['ground_speed'] = $row['ground_speed'];  | 
                                                        |
| 146 | 169 | }  | 
                                                        
| 147 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];  | 
                                                        |
| 148 | 170 | |
| 149 | 171 |  			if (isset($row['date'])) { | 
                                                        
| 150 | 172 | $dateArray = $this->parseDateString($row['date']);  | 
                                                        
@@ -187,13 +209,21 @@ discard block  | 
                                                    ||
| 187 | 209 | }  | 
                                                        
| 188 | 210 | |
| 189 | 211 | $fromsource = NULL;  | 
                                                        
| 190 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];  | 
                                                        |
| 191 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];  | 
                                                        |
| 192 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];  | 
                                                        |
| 212 | +			if (isset($row['source_name']) && $row['source_name'] != '') { | 
                                                        |
| 213 | + $temp_array['source_name'] = $row['source_name'];  | 
                                                        |
| 214 | + }  | 
                                                        |
| 215 | +			if (isset($row['over_country']) && $row['over_country'] != '') { | 
                                                        |
| 216 | + $temp_array['over_country'] = $row['over_country'];  | 
                                                        |
| 217 | + }  | 
                                                        |
| 218 | +			if (isset($row['distance']) && $row['distance'] != '') { | 
                                                        |
| 219 | + $temp_array['distance'] = $row['distance'];  | 
                                                        |
| 220 | + }  | 
                                                        |
| 193 | 221 | $temp_array['query_number_rows'] = $num_rows;  | 
                                                        
| 194 | 222 | $spotter_array[] = $temp_array;  | 
                                                        
| 195 | 223 | }  | 
                                                        
| 196 | - if ($num_rows == 0) return array();  | 
                                                        |
| 224 | +		if ($num_rows == 0) { | 
                                                        |
| 225 | + return array();  | 
                                                        |
| 226 | + }  | 
                                                        |
| 197 | 227 | $spotter_array[0]['query_number_rows'] = $num_rows;  | 
                                                        
| 198 | 228 | return $spotter_array;  | 
                                                        
| 199 | 229 | }  | 
                                                        
@@ -224,8 +254,12 @@ discard block  | 
                                                    ||
| 224 | 254 |  			{ | 
                                                        
| 225 | 255 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 226 | 256 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 227 | - } else $limit_query = "";  | 
                                                        |
| 228 | - } else $limit_query = "";  | 
                                                        |
| 257 | +			} else { | 
                                                        |
| 258 | + $limit_query = "";  | 
                                                        |
| 259 | + }  | 
                                                        |
| 260 | +		} else { | 
                                                        |
| 261 | + $limit_query = "";  | 
                                                        |
| 262 | + }  | 
                                                        |
| 229 | 263 | |
| 230 | 264 | if ($sort != "")  | 
                                                        
| 231 | 265 |  		{ | 
                                                        
@@ -253,7 +287,9 @@ discard block  | 
                                                    ||
| 253 | 287 | global $global_query;  | 
                                                        
| 254 | 288 | |
| 255 | 289 |  		date_default_timezone_set('UTC'); | 
                                                        
| 256 | - if ($id == '') return array();  | 
                                                        |
| 290 | +		if ($id == '') { | 
                                                        |
| 291 | + return array();  | 
                                                        |
| 292 | + }  | 
                                                        |
| 257 | 293 | $additional_query = "tracker_output.famtrackid = :id";  | 
                                                        
| 258 | 294 |  		$query_values = array(':id' => $id); | 
                                                        
| 259 | 295 | $query = $global_query." WHERE ".$additional_query." ";  | 
                                                        
@@ -396,8 +432,11 @@ discard block  | 
                                                    ||
| 396 | 432 | $query .= " ORDER BY tracker_output.source_name ASC";  | 
                                                        
| 397 | 433 | |
| 398 | 434 | $sth = $this->db->prepare($query);  | 
                                                        
| 399 | - if (!empty($query_values)) $sth->execute($query_values);  | 
                                                        |
| 400 | - else $sth->execute();  | 
                                                        |
| 435 | +		if (!empty($query_values)) { | 
                                                        |
| 436 | + $sth->execute($query_values);  | 
                                                        |
| 437 | +		} else { | 
                                                        |
| 438 | + $sth->execute();  | 
                                                        |
| 439 | + }  | 
                                                        |
| 401 | 440 | |
| 402 | 441 | $source_array = array();  | 
                                                        
| 403 | 442 | $temp_array = array();  | 
                                                        
@@ -452,7 +491,9 @@ discard block  | 
                                                    ||
| 452 | 491 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 453 | 492 | $datetime = new DateTime();  | 
                                                        
| 454 | 493 |  			$offset = $datetime->format('P'); | 
                                                        
| 455 | - } else $offset = '+00:00';  | 
                                                        |
| 494 | +		} else { | 
                                                        |
| 495 | + $offset = '+00:00';  | 
                                                        |
| 496 | + }  | 
                                                        |
| 456 | 497 | |
| 457 | 498 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 458 | 499 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date  | 
                                                        
@@ -608,7 +649,9 @@ discard block  | 
                                                    ||
| 608 | 649 |  			{ | 
                                                        
| 609 | 650 | return false;  | 
                                                        
| 610 | 651 | }  | 
                                                        
| 611 | - } else $altitude = 0;  | 
                                                        |
| 652 | +		} else { | 
                                                        |
| 653 | + $altitude = 0;  | 
                                                        |
| 654 | + }  | 
                                                        |
| 612 | 655 | |
| 613 | 656 | if ($heading != "")  | 
                                                        
| 614 | 657 |  		{ | 
                                                        
@@ -647,8 +690,12 @@ discard block  | 
                                                    ||
| 647 | 690 | $latitude = 0;  | 
                                                        
| 648 | 691 | $longitude = 0;  | 
                                                        
| 649 | 692 | }  | 
                                                        
| 650 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;  | 
                                                        |
| 651 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;  | 
                                                        |
| 693 | +                if ($heading == '' || $Common->isInteger($heading) === false) { | 
                                                        |
| 694 | + $heading = 0;  | 
                                                        |
| 695 | + }  | 
                                                        |
| 696 | +                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { | 
                                                        |
| 697 | + $groundspeed = 0;  | 
                                                        |
| 698 | + }  | 
                                                        |
| 652 | 699 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type)  | 
                                                        
| 653 | 700 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";  | 
                                                        
| 654 | 701 | |
@@ -813,12 +860,18 @@ discard block  | 
                                                    ||
| 813 | 860 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count  | 
                                                        
| 814 | 861 | FROM tracker_output".$filter_query." tracker_output.ident <> ''";  | 
                                                        
| 815 | 862 |  		 if ($olderthanmonths > 0) { | 
                                                        
| 816 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';  | 
                                                        |
| 817 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        |
| 863 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 864 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';  | 
                                                        |
| 865 | +			} else { | 
                                                        |
| 866 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        |
| 867 | + }  | 
                                                        |
| 818 | 868 | }  | 
                                                        
| 819 | 869 |  		if ($sincedate != '') { | 
                                                        
| 820 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";  | 
                                                        |
| 821 | -			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
                                                        |
| 870 | +			if ($globalDBdriver == 'mysql') { | 
                                                        |
| 871 | + $query .= " AND tracker_output.date > '".$sincedate."'";  | 
                                                        |
| 872 | +			} else { | 
                                                        |
| 873 | +				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
                                                        |
| 874 | + }  | 
                                                        |
| 822 | 875 | }  | 
                                                        
| 823 | 876 | $query_values = array();  | 
                                                        
| 824 | 877 |  		if ($year != '') { | 
                                                        
@@ -849,7 +902,9 @@ discard block  | 
                                                    ||
| 849 | 902 | }  | 
                                                        
| 850 | 903 | }  | 
                                                        
| 851 | 904 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";  | 
                                                        
| 852 | - if ($limit) $query .= " LIMIT 10 OFFSET 0";  | 
                                                        |
| 905 | +		if ($limit) { | 
                                                        |
| 906 | + $query .= " LIMIT 10 OFFSET 0";  | 
                                                        |
| 907 | + }  | 
                                                        |
| 853 | 908 | |
| 854 | 909 | $sth = $this->db->prepare($query);  | 
                                                        
| 855 | 910 | $sth->execute($query_values);  | 
                                                        
@@ -884,7 +939,9 @@ discard block  | 
                                                    ||
| 884 | 939 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 885 | 940 | $datetime = new DateTime();  | 
                                                        
| 886 | 941 |  			$offset = $datetime->format('P'); | 
                                                        
| 887 | - } else $offset = '+00:00';  | 
                                                        |
| 942 | +		} else { | 
                                                        |
| 943 | + $offset = '+00:00';  | 
                                                        |
| 944 | + }  | 
                                                        |
| 888 | 945 | |
| 889 | 946 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 890 | 947 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count  | 
                                                        
@@ -934,7 +991,9 @@ discard block  | 
                                                    ||
| 934 | 991 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 935 | 992 | $datetime = new DateTime();  | 
                                                        
| 936 | 993 |  			$offset = $datetime->format('P'); | 
                                                        
| 937 | - } else $offset = '+00:00';  | 
                                                        |
| 994 | +		} else { | 
                                                        |
| 995 | + $offset = '+00:00';  | 
                                                        |
| 996 | + }  | 
                                                        |
| 938 | 997 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
| 939 | 998 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 940 | 999 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count  | 
                                                        
@@ -980,7 +1039,9 @@ discard block  | 
                                                    ||
| 980 | 1039 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 981 | 1040 | $datetime = new DateTime();  | 
                                                        
| 982 | 1041 |  			$offset = $datetime->format('P'); | 
                                                        
| 983 | - } else $offset = '+00:00';  | 
                                                        |
| 1042 | +		} else { | 
                                                        |
| 1043 | + $offset = '+00:00';  | 
                                                        |
| 1044 | + }  | 
                                                        |
| 984 | 1045 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
| 985 | 1046 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 986 | 1047 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count  | 
                                                        
@@ -1028,7 +1089,9 @@ discard block  | 
                                                    ||
| 1028 | 1089 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1029 | 1090 | $datetime = new DateTime();  | 
                                                        
| 1030 | 1091 |  			$offset = $datetime->format('P'); | 
                                                        
| 1031 | - } else $offset = '+00:00';  | 
                                                        |
| 1092 | +		} else { | 
                                                        |
| 1093 | + $offset = '+00:00';  | 
                                                        |
| 1094 | + }  | 
                                                        |
| 1032 | 1095 | |
| 1033 | 1096 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1034 | 1097 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count  | 
                                                        
@@ -1077,7 +1140,9 @@ discard block  | 
                                                    ||
| 1077 | 1140 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1078 | 1141 | $datetime = new DateTime();  | 
                                                        
| 1079 | 1142 |  			$offset = $datetime->format('P'); | 
                                                        
| 1080 | - } else $offset = '+00:00';  | 
                                                        |
| 1143 | +		} else { | 
                                                        |
| 1144 | + $offset = '+00:00';  | 
                                                        |
| 1145 | + }  | 
                                                        |
| 1081 | 1146 | $filter_query = $this->getFilter($filters,true,true);  | 
                                                        
| 1082 | 1147 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1083 | 1148 | $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  | 
                                                        
@@ -1126,7 +1191,9 @@ discard block  | 
                                                    ||
| 1126 | 1191 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1127 | 1192 | $datetime = new DateTime();  | 
                                                        
| 1128 | 1193 |  			$offset = $datetime->format('P'); | 
                                                        
| 1129 | - } else $offset = '+00:00';  | 
                                                        |
| 1194 | +		} else { | 
                                                        |
| 1195 | + $offset = '+00:00';  | 
                                                        |
| 1196 | + }  | 
                                                        |
| 1130 | 1197 | |
| 1131 | 1198 | $orderby_sql = '';  | 
                                                        
| 1132 | 1199 | if ($orderby == "hour")  | 
                                                        
@@ -1195,7 +1262,9 @@ discard block  | 
                                                    ||
| 1195 | 1262 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1196 | 1263 | $datetime = new DateTime($date);  | 
                                                        
| 1197 | 1264 |  			$offset = $datetime->format('P'); | 
                                                        
| 1198 | - } else $offset = '+00:00';  | 
                                                        |
| 1265 | +		} else { | 
                                                        |
| 1266 | + $offset = '+00:00';  | 
                                                        |
| 1267 | + }  | 
                                                        |
| 1199 | 1268 | |
| 1200 | 1269 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1201 | 1270 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count  | 
                                                        
@@ -1243,7 +1312,9 @@ discard block  | 
                                                    ||
| 1243 | 1312 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1244 | 1313 | $datetime = new DateTime();  | 
                                                        
| 1245 | 1314 |  			$offset = $datetime->format('P'); | 
                                                        
| 1246 | - } else $offset = '+00:00';  | 
                                                        |
| 1315 | +		} else { | 
                                                        |
| 1316 | + $offset = '+00:00';  | 
                                                        |
| 1317 | + }  | 
                                                        |
| 1247 | 1318 | |
| 1248 | 1319 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1249 | 1320 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count  | 
                                                        
@@ -1307,8 +1378,11 @@ discard block  | 
                                                    ||
| 1307 | 1378 |  				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                        
| 1308 | 1379 | }  | 
                                                        
| 1309 | 1380 | }  | 
                                                        
| 1310 | - if (empty($query_values)) $queryi .= $this->getFilter($filters);  | 
                                                        |
| 1311 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4);  | 
                                                        |
| 1381 | +		if (empty($query_values)) { | 
                                                        |
| 1382 | + $queryi .= $this->getFilter($filters);  | 
                                                        |
| 1383 | +		} else { | 
                                                        |
| 1384 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4);  | 
                                                        |
| 1385 | + }  | 
                                                        |
| 1312 | 1386 | |
| 1313 | 1387 | $sth = $this->db->prepare($queryi);  | 
                                                        
| 1314 | 1388 | $sth->execute($query_values);  | 
                                                        
@@ -1330,7 +1404,9 @@ discard block  | 
                                                    ||
| 1330 | 1404 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 1331 | 1405 | $datetime = new DateTime();  | 
                                                        
| 1332 | 1406 |  			$offset = $datetime->format('P'); | 
                                                        
| 1333 | - } else $offset = '+00:00';  | 
                                                        |
| 1407 | +		} else { | 
                                                        |
| 1408 | + $offset = '+00:00';  | 
                                                        |
| 1409 | + }  | 
                                                        |
| 1334 | 1410 | |
| 1335 | 1411 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 1336 | 1412 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count  | 
                                                        
@@ -1434,7 +1510,9 @@ discard block  | 
                                                    ||
| 1434 | 1510 | */  | 
                                                        
| 1435 | 1511 | public function parseDirection($direction = 0)  | 
                                                        
| 1436 | 1512 |  	{ | 
                                                        
| 1437 | - if ($direction == '') $direction = 0;  | 
                                                        |
| 1513 | +		if ($direction == '') { | 
                                                        |
| 1514 | + $direction = 0;  | 
                                                        |
| 1515 | + }  | 
                                                        |
| 1438 | 1516 | $direction_array = array();  | 
                                                        
| 1439 | 1517 | $temp_array = array();  | 
                                                        
| 1440 | 1518 | |
@@ -1523,7 +1601,9 @@ discard block  | 
                                                    ||
| 1523 | 1601 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 1524 | 1602 | |
| 1525 | 1603 | $Connection = new Connection($this->db);  | 
                                                        
| 1526 | -		if (!$Connection->tableExists('countries')) return ''; | 
                                                        |
| 1604 | +		if (!$Connection->tableExists('countries')) { | 
                                                        |
| 1605 | + return '';  | 
                                                        |
| 1606 | + }  | 
                                                        |
| 1527 | 1607 | |
| 1528 | 1608 |  		try { | 
                                                        
| 1529 | 1609 | /*  | 
                                                        
@@ -1543,9 +1623,13 @@ discard block  | 
                                                    ||
| 1543 | 1623 | $sth->closeCursor();  | 
                                                        
| 1544 | 1624 |  			if (count($row) > 0) { | 
                                                        
| 1545 | 1625 | return $row;  | 
                                                        
| 1546 | - } else return '';  | 
                                                        |
| 1626 | +			} else { | 
                                                        |
| 1627 | + return '';  | 
                                                        |
| 1628 | + }  | 
                                                        |
| 1547 | 1629 |  		} catch (PDOException $e) { | 
                                                        
| 1548 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";  | 
                                                        |
| 1630 | +			if (isset($globalDebug) && $globalDebug) { | 
                                                        |
| 1631 | + echo 'Error : '.$e->getMessage()."\n";  | 
                                                        |
| 1632 | + }  | 
                                                        |
| 1549 | 1633 | return '';  | 
                                                        
| 1550 | 1634 | }  | 
                                                        
| 1551 | 1635 | |
@@ -1563,7 +1647,9 @@ discard block  | 
                                                    ||
| 1563 | 1647 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);  | 
                                                        
| 1564 | 1648 | |
| 1565 | 1649 | $Connection = new Connection($this->db);  | 
                                                        
| 1566 | -		if (!$Connection->tableExists('countries')) return ''; | 
                                                        |
| 1650 | +		if (!$Connection->tableExists('countries')) { | 
                                                        |
| 1651 | + return '';  | 
                                                        |
| 1652 | + }  | 
                                                        |
| 1567 | 1653 | |
| 1568 | 1654 |  		try { | 
                                                        
| 1569 | 1655 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";  | 
                                                        
@@ -1575,9 +1661,13 @@ discard block  | 
                                                    ||
| 1575 | 1661 | $sth->closeCursor();  | 
                                                        
| 1576 | 1662 |  			if (count($row) > 0) { | 
                                                        
| 1577 | 1663 | return $row;  | 
                                                        
| 1578 | - } else return '';  | 
                                                        |
| 1664 | +			} else { | 
                                                        |
| 1665 | + return '';  | 
                                                        |
| 1666 | + }  | 
                                                        |
| 1579 | 1667 |  		} catch (PDOException $e) { | 
                                                        
| 1580 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";  | 
                                                        |
| 1668 | +			if (isset($globalDebug) && $globalDebug) { | 
                                                        |
| 1669 | + echo 'Error : '.$e->getMessage()."\n";  | 
                                                        |
| 1670 | + }  | 
                                                        |
| 1581 | 1671 | return '';  | 
                                                        
| 1582 | 1672 | }  | 
                                                        
| 1583 | 1673 | |
@@ -1595,7 +1685,9 @@ discard block  | 
                                                    ||
| 1595 | 1685 |  	{ | 
                                                        
| 1596 | 1686 | global $globalBitlyAccessToken;  | 
                                                        
| 1597 | 1687 | |
| 1598 | - if ($globalBitlyAccessToken == '') return $url;  | 
                                                        |
| 1688 | +		if ($globalBitlyAccessToken == '') { | 
                                                        |
| 1689 | + return $url;  | 
                                                        |
| 1690 | + }  | 
                                                        |
| 1599 | 1691 | |
| 1600 | 1692 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;  | 
                                                        
| 1601 | 1693 | |
@@ -14,7 +14,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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 = '')  | 
                                                        
@@ -12,10 +12,10 @@ discard block  | 
                                                    ||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /**  | 
                                                        
| 15 | - * Get SQL query part for filter used  | 
                                                        |
| 16 | - * @param Array $filter the filter  | 
                                                        |
| 17 | - * @return Array the SQL part  | 
                                                        |
| 18 | - */  | 
                                                        |
| 15 | + * Get SQL query part for filter used  | 
                                                        |
| 16 | + * @param Array $filter the filter  | 
                                                        |
| 17 | + * @return Array the SQL part  | 
                                                        |
| 18 | + */  | 
                                                        |
| 19 | 19 |  	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
| 21 | 21 | $filters = array();  | 
                                                        
@@ -86,11 +86,11 @@ discard block  | 
                                                    ||
| 86 | 86 | }  | 
                                                        
| 87 | 87 | |
| 88 | 88 | /**  | 
                                                        
| 89 | - * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 90 | - *  | 
                                                        |
| 91 | - * @return Array the spotter information  | 
                                                        |
| 92 | - *  | 
                                                        |
| 93 | - */  | 
                                                        |
| 89 | + * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 90 | + *  | 
                                                        |
| 91 | + * @return Array the spotter information  | 
                                                        |
| 92 | + *  | 
                                                        |
| 93 | + */  | 
                                                        |
| 94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array())  | 
                                                        
| 95 | 95 |  	{ | 
                                                        
| 96 | 96 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -132,11 +132,11 @@ discard block  | 
                                                    ||
| 132 | 132 | }  | 
                                                        
| 133 | 133 | |
| 134 | 134 | /**  | 
                                                        
| 135 | - * Gets Minimal Live Spotter data  | 
                                                        |
| 136 | - *  | 
                                                        |
| 137 | - * @return Array the spotter information  | 
                                                        |
| 138 | - *  | 
                                                        |
| 139 | - */  | 
                                                        |
| 135 | + * Gets Minimal Live Spotter data  | 
                                                        |
| 136 | + *  | 
                                                        |
| 137 | + * @return Array the spotter information  | 
                                                        |
| 138 | + *  | 
                                                        |
| 139 | + */  | 
                                                        |
| 140 | 140 | public function getMinLiveTrackerData($filter = array())  | 
                                                        
| 141 | 141 |  	{ | 
                                                        
| 142 | 142 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -170,11 +170,11 @@ discard block  | 
                                                    ||
| 170 | 170 | }  | 
                                                        
| 171 | 171 | |
| 172 | 172 | /**  | 
                                                        
| 173 | - * Gets Minimal Live Spotter data since xx seconds  | 
                                                        |
| 174 | - *  | 
                                                        |
| 175 | - * @return Array the spotter information  | 
                                                        |
| 176 | - *  | 
                                                        |
| 177 | - */  | 
                                                        |
| 173 | + * Gets Minimal Live Spotter data since xx seconds  | 
                                                        |
| 174 | + *  | 
                                                        |
| 175 | + * @return Array the spotter information  | 
                                                        |
| 176 | + *  | 
                                                        |
| 177 | + */  | 
                                                        |
| 178 | 178 | public function getMinLastLiveTrackerData($filter = array())  | 
                                                        
| 179 | 179 |  	{ | 
                                                        
| 180 | 180 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -187,13 +187,13 @@ discard block  | 
                                                    ||
| 187 | 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 | -                } else { | 
                                                        |
| 190 | +				} else { | 
                                                        |
| 191 | 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 | }  | 
                                                        
| 195 | 195 | |
| 196 | -    		try { | 
                                                        |
| 196 | +			try { | 
                                                        |
| 197 | 197 | $sth = $this->db->prepare($query);  | 
                                                        
| 198 | 198 | $sth->execute();  | 
                                                        
| 199 | 199 |  		} catch(PDOException $e) { | 
                                                        
@@ -205,11 +205,11 @@ discard block  | 
                                                    ||
| 205 | 205 | }  | 
                                                        
| 206 | 206 | |
| 207 | 207 | /**  | 
                                                        
| 208 | - * Gets number of latest data entry  | 
                                                        |
| 209 | - *  | 
                                                        |
| 210 | - * @return String number of entry  | 
                                                        |
| 211 | - *  | 
                                                        |
| 212 | - */  | 
                                                        |
| 208 | + * Gets number of latest data entry  | 
                                                        |
| 209 | + *  | 
                                                        |
| 210 | + * @return String number of entry  | 
                                                        |
| 211 | + *  | 
                                                        |
| 212 | + */  | 
                                                        |
| 213 | 213 | public function getLiveTrackerCount($filter = array())  | 
                                                        
| 214 | 214 |  	{ | 
                                                        
| 215 | 215 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -234,11 +234,11 @@ discard block  | 
                                                    ||
| 234 | 234 | }  | 
                                                        
| 235 | 235 | |
| 236 | 236 | /**  | 
                                                        
| 237 | - * Gets all the spotter information based on the latest data entry and coord  | 
                                                        |
| 238 | - *  | 
                                                        |
| 239 | - * @return Array the spotter information  | 
                                                        |
| 240 | - *  | 
                                                        |
| 241 | - */  | 
                                                        |
| 237 | + * Gets all the spotter information based on the latest data entry and coord  | 
                                                        |
| 238 | + *  | 
                                                        |
| 239 | + * @return Array the spotter information  | 
                                                        |
| 240 | + *  | 
                                                        |
| 241 | + */  | 
                                                        |
| 242 | 242 | public function getLiveTrackerDatabyCoord($coord, $filter = array())  | 
                                                        
| 243 | 243 |  	{ | 
                                                        
| 244 | 244 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -262,11 +262,11 @@ discard block  | 
                                                    ||
| 262 | 262 | }  | 
                                                        
| 263 | 263 | |
| 264 | 264 | /**  | 
                                                        
| 265 | - * Gets all the spotter information based on a user's latitude and longitude  | 
                                                        |
| 266 | - *  | 
                                                        |
| 267 | - * @return Array the spotter information  | 
                                                        |
| 268 | - *  | 
                                                        |
| 269 | - */  | 
                                                        |
| 265 | + * Gets all the spotter information based on a user's latitude and longitude  | 
                                                        |
| 266 | + *  | 
                                                        |
| 267 | + * @return Array the spotter information  | 
                                                        |
| 268 | + *  | 
                                                        |
| 269 | + */  | 
                                                        |
| 270 | 270 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval)  | 
                                                        
| 271 | 271 |  	{ | 
                                                        
| 272 | 272 | $Tracker = new Tracker($this->db);  | 
                                                        
@@ -279,142 +279,142 @@ discard block  | 
                                                    ||
| 279 | 279 | if ($lng != '')  | 
                                                        
| 280 | 280 |  		{ | 
                                                        
| 281 | 281 | if (!is_numeric($lng))  | 
                                                        
| 282 | -                        { | 
                                                        |
| 283 | - return false;  | 
                                                        |
| 284 | - }  | 
                                                        |
| 285 | - }  | 
                                                        |
| 286 | -  | 
                                                        |
| 287 | - if ($radius != '')  | 
                                                        |
| 288 | -                { | 
                                                        |
| 289 | - if (!is_numeric($radius))  | 
                                                        |
| 290 | -                        { | 
                                                        |
| 291 | - return false;  | 
                                                        |
| 292 | - }  | 
                                                        |
| 293 | - }  | 
                                                        |
| 282 | +						{ | 
                                                        |
| 283 | + return false;  | 
                                                        |
| 284 | + }  | 
                                                        |
| 285 | + }  | 
                                                        |
| 286 | +  | 
                                                        |
| 287 | + if ($radius != '')  | 
                                                        |
| 288 | +				{ | 
                                                        |
| 289 | + if (!is_numeric($radius))  | 
                                                        |
| 290 | +						{ | 
                                                        |
| 291 | + return false;  | 
                                                        |
| 292 | + }  | 
                                                        |
| 293 | + }  | 
                                                        |
| 294 | 294 | $additional_query = '';  | 
                                                        
| 295 | 295 | if ($interval != '')  | 
                                                        
| 296 | -                { | 
                                                        |
| 297 | - if (!is_string($interval))  | 
                                                        |
| 298 | -                        { | 
                                                        |
| 299 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';  | 
                                                        |
| 300 | - return false;  | 
                                                        |
| 301 | -                        } else { | 
                                                        |
| 302 | - if ($interval == '1m')  | 
                                                        |
| 303 | -                { | 
                                                        |
| 304 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';  | 
                                                        |
| 305 | -                } else if ($interval == '15m'){ | 
                                                        |
| 306 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';  | 
                                                        |
| 307 | - }  | 
                                                        |
| 308 | - }  | 
                                                        |
| 309 | -                } else { | 
                                                        |
| 310 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';  | 
                                                        |
| 311 | - }  | 
                                                        |
| 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  | 
                                                        |
| 296 | +				{ | 
                                                        |
| 297 | + if (!is_string($interval))  | 
                                                        |
| 298 | +						{ | 
                                                        |
| 299 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';  | 
                                                        |
| 300 | + return false;  | 
                                                        |
| 301 | +						} else { | 
                                                        |
| 302 | + if ($interval == '1m')  | 
                                                        |
| 303 | +				{ | 
                                                        |
| 304 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';  | 
                                                        |
| 305 | +				} else if ($interval == '15m'){ | 
                                                        |
| 306 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';  | 
                                                        |
| 307 | + }  | 
                                                        |
| 308 | + }  | 
                                                        |
| 309 | +				} else { | 
                                                        |
| 310 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';  | 
                                                        |
| 311 | + }  | 
                                                        |
| 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  | 
                                                        |
| 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 | - return $spotter_array;  | 
                                                        |
| 323 | - }  | 
                                                        |
| 322 | + return $spotter_array;  | 
                                                        |
| 323 | + }  | 
                                                        |
| 324 | 324 | |
| 325 | 325 | |
| 326 | - /**  | 
                                                        |
| 327 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 328 | - *  | 
                                                        |
| 329 | - * @return Array the spotter information  | 
                                                        |
| 330 | - *  | 
                                                        |
| 331 | - */  | 
                                                        |
| 326 | + /**  | 
                                                        |
| 327 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 328 | + *  | 
                                                        |
| 329 | + * @return Array the spotter information  | 
                                                        |
| 330 | + *  | 
                                                        |
| 331 | + */  | 
                                                        |
| 332 | 332 | public function getLastLiveTrackerDataByIdent($ident)  | 
                                                        
| 333 | 333 |  	{ | 
                                                        
| 334 | 334 | $Tracker = new Tracker($this->db);  | 
                                                        
| 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 | 340 |  		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); | 
                                                        
| 341 | 341 | |
| 342 | 342 | return $spotter_array;  | 
                                                        
| 343 | 343 | }  | 
                                                        
| 344 | 344 | |
| 345 | - /**  | 
                                                        |
| 346 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 347 | - *  | 
                                                        |
| 348 | - * @return Array the spotter information  | 
                                                        |
| 349 | - *  | 
                                                        |
| 350 | - */  | 
                                                        |
| 345 | + /**  | 
                                                        |
| 346 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 347 | + *  | 
                                                        |
| 348 | + * @return Array the spotter information  | 
                                                        |
| 349 | + *  | 
                                                        |
| 350 | + */  | 
                                                        |
| 351 | 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); | 
                                                        |
| 359 | +				$date = date('c',$date); | 
                                                        |
| 360 | 360 |  		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); | 
                                                        
| 361 | 361 | |
| 362 | 362 | return $spotter_array;  | 
                                                        
| 363 | 363 | }  | 
                                                        
| 364 | 364 | |
| 365 | - /**  | 
                                                        |
| 366 | - * Gets last spotter information based on a particular callsign  | 
                                                        |
| 367 | - *  | 
                                                        |
| 368 | - * @return Array the spotter information  | 
                                                        |
| 369 | - *  | 
                                                        |
| 370 | - */  | 
                                                        |
| 365 | + /**  | 
                                                        |
| 366 | + * Gets last spotter information based on a particular callsign  | 
                                                        |
| 367 | + *  | 
                                                        |
| 368 | + * @return Array the spotter information  | 
                                                        |
| 369 | + *  | 
                                                        |
| 370 | + */  | 
                                                        |
| 371 | 371 | public function getLastLiveTrackerDataById($id)  | 
                                                        
| 372 | 372 |  	{ | 
                                                        
| 373 | 373 | $Tracker = new Tracker($this->db);  | 
                                                        
| 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 | 379 |  		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); | 
                                                        
| 380 | 380 | |
| 381 | 381 | return $spotter_array;  | 
                                                        
| 382 | 382 | }  | 
                                                        
| 383 | 383 | |
| 384 | - /**  | 
                                                        |
| 385 | - * Gets last spotter information based on a particular callsign  | 
                                                        |
| 386 | - *  | 
                                                        |
| 387 | - * @return Array the spotter information  | 
                                                        |
| 388 | - *  | 
                                                        |
| 389 | - */  | 
                                                        |
| 384 | + /**  | 
                                                        |
| 385 | + * Gets last spotter information based on a particular callsign  | 
                                                        |
| 386 | + *  | 
                                                        |
| 387 | + * @return Array the spotter information  | 
                                                        |
| 388 | + *  | 
                                                        |
| 389 | + */  | 
                                                        |
| 390 | 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); | 
                                                        |
| 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 | 398 |  		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); | 
                                                        
| 399 | 399 | |
| 400 | 400 | return $spotter_array;  | 
                                                        
| 401 | 401 | }  | 
                                                        
| 402 | 402 | |
| 403 | - /**  | 
                                                        |
| 404 | - * Gets altitude information based on a particular callsign  | 
                                                        |
| 405 | - *  | 
                                                        |
| 406 | - * @return Array the spotter information  | 
                                                        |
| 407 | - *  | 
                                                        |
| 408 | - */  | 
                                                        |
| 403 | + /**  | 
                                                        |
| 404 | + * Gets altitude information based on a particular callsign  | 
                                                        |
| 405 | + *  | 
                                                        |
| 406 | + * @return Array the spotter information  | 
                                                        |
| 407 | + *  | 
                                                        |
| 408 | + */  | 
                                                        |
| 409 | 409 | public function getAltitudeLiveTrackerDataByIdent($ident)  | 
                                                        
| 410 | 410 |  	{ | 
                                                        
| 411 | 411 | |
| 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 | -    		try { | 
                                                        |
| 417 | +			try { | 
                                                        |
| 418 | 418 | |
| 419 | 419 | $sth = $this->db->prepare($query);  | 
                                                        
| 420 | 420 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
@@ -427,12 +427,12 @@ discard block  | 
                                                    ||
| 427 | 427 | return $spotter_array;  | 
                                                        
| 428 | 428 | }  | 
                                                        
| 429 | 429 | |
| 430 | - /**  | 
                                                        |
| 431 | - * Gets all the spotter information based on a particular id  | 
                                                        |
| 432 | - *  | 
                                                        |
| 433 | - * @return Array the spotter information  | 
                                                        |
| 434 | - *  | 
                                                        |
| 435 | - */  | 
                                                        |
| 430 | + /**  | 
                                                        |
| 431 | + * Gets all the spotter information based on a particular id  | 
                                                        |
| 432 | + *  | 
                                                        |
| 433 | + * @return Array the spotter information  | 
                                                        |
| 434 | + *  | 
                                                        |
| 435 | + */  | 
                                                        |
| 436 | 436 | public function getAllLiveTrackerDataById($id,$liveinterval = false)  | 
                                                        
| 437 | 437 |  	{ | 
                                                        
| 438 | 438 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -460,18 +460,18 @@ discard block  | 
                                                    ||
| 460 | 460 | return $spotter_array;  | 
                                                        
| 461 | 461 | }  | 
                                                        
| 462 | 462 | |
| 463 | - /**  | 
                                                        |
| 464 | - * Gets all the spotter information based on a particular ident  | 
                                                        |
| 465 | - *  | 
                                                        |
| 466 | - * @return Array the spotter information  | 
                                                        |
| 467 | - *  | 
                                                        |
| 468 | - */  | 
                                                        |
| 463 | + /**  | 
                                                        |
| 464 | + * Gets all the spotter information based on a particular ident  | 
                                                        |
| 465 | + *  | 
                                                        |
| 466 | + * @return Array the spotter information  | 
                                                        |
| 467 | + *  | 
                                                        |
| 468 | + */  | 
                                                        |
| 469 | 469 | public function getAllLiveTrackerDataByIdent($ident)  | 
                                                        
| 470 | 470 |  	{ | 
                                                        
| 471 | 471 |  		date_default_timezone_set('UTC'); | 
                                                        
| 472 | 472 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 473 | 473 | $query = self::$global_query.' WHERE tracker_live.ident = :ident';  | 
                                                        
| 474 | -    		try { | 
                                                        |
| 474 | +			try { | 
                                                        |
| 475 | 475 | |
| 476 | 476 | $sth = $this->db->prepare($query);  | 
                                                        
| 477 | 477 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
@@ -485,23 +485,23 @@ discard block  | 
                                                    ||
| 485 | 485 | |
| 486 | 486 | |
| 487 | 487 | /**  | 
                                                        
| 488 | - * Deletes all info in the table  | 
                                                        |
| 489 | - *  | 
                                                        |
| 490 | - * @return String success or false  | 
                                                        |
| 491 | - *  | 
                                                        |
| 492 | - */  | 
                                                        |
| 488 | + * Deletes all info in the table  | 
                                                        |
| 489 | + *  | 
                                                        |
| 490 | + * @return String success or false  | 
                                                        |
| 491 | + *  | 
                                                        |
| 492 | + */  | 
                                                        |
| 493 | 493 | public function deleteLiveTrackerData()  | 
                                                        
| 494 | 494 |  	{ | 
                                                        
| 495 | 495 | global $globalDBdriver;  | 
                                                        
| 496 | 496 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 497 | 497 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date";  | 
                                                        
| 498 | 498 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date';  | 
                                                        
| 499 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";  | 
                                                        |
| 499 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";  | 
                                                        |
| 500 | 500 |  		} else { | 
                                                        
| 501 | 501 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date";  | 
                                                        
| 502 | 502 | }  | 
                                                        
| 503 | 503 | |
| 504 | -    		try { | 
                                                        |
| 504 | +			try { | 
                                                        |
| 505 | 505 | |
| 506 | 506 | $sth = $this->db->prepare($query);  | 
                                                        
| 507 | 507 | $sth->execute();  | 
                                                        
@@ -513,18 +513,18 @@ discard block  | 
                                                    ||
| 513 | 513 | }  | 
                                                        
| 514 | 514 | |
| 515 | 515 | /**  | 
                                                        
| 516 | - * Deletes all info in the table for aircraft not seen since 2 HOUR  | 
                                                        |
| 517 | - *  | 
                                                        |
| 518 | - * @return String success or false  | 
                                                        |
| 519 | - *  | 
                                                        |
| 520 | - */  | 
                                                        |
| 516 | + * Deletes all info in the table for aircraft not seen since 2 HOUR  | 
                                                        |
| 517 | + *  | 
                                                        |
| 518 | + * @return String success or false  | 
                                                        |
| 519 | + *  | 
                                                        |
| 520 | + */  | 
                                                        |
| 521 | 521 | public function deleteLiveTrackerDataNotUpdated()  | 
                                                        
| 522 | 522 |  	{ | 
                                                        
| 523 | 523 | global $globalDBdriver, $globalDebug;  | 
                                                        
| 524 | 524 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 525 | 525 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0';  | 
                                                        
| 526 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";  | 
                                                        |
| 527 | -    			try { | 
                                                        |
| 526 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";  | 
                                                        |
| 527 | +				try { | 
                                                        |
| 528 | 528 | |
| 529 | 529 | $sth = $this->db->prepare($query);  | 
                                                        
| 530 | 530 | $sth->execute();  | 
                                                        
@@ -532,8 +532,8 @@ discard block  | 
                                                    ||
| 532 | 532 | return "error";  | 
                                                        
| 533 | 533 | }  | 
                                                        
| 534 | 534 |  			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; | 
                                                        
| 535 | - $i = 0;  | 
                                                        |
| 536 | - $j =0;  | 
                                                        |
| 535 | + $i = 0;  | 
                                                        |
| 536 | + $j =0;  | 
                                                        |
| 537 | 537 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 538 | 538 | foreach($all as $row)  | 
                                                        
| 539 | 539 |  			{ | 
                                                        
@@ -541,20 +541,20 @@ discard block  | 
                                                    ||
| 541 | 541 | $j++;  | 
                                                        
| 542 | 542 |  				if ($j == 30) { | 
                                                        
| 543 | 543 | if ($globalDebug) echo ".";  | 
                                                        
| 544 | -				    	try { | 
                                                        |
| 544 | +						try { | 
                                                        |
| 545 | 545 | |
| 546 | 546 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
| 547 | 547 | $sth->execute();  | 
                                                        
| 548 | 548 |  					} catch(PDOException $e) { | 
                                                        
| 549 | 549 | return "error";  | 
                                                        
| 550 | 550 | }  | 
                                                        
| 551 | -                                	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; | 
                                                        |
| 552 | - $j = 0;  | 
                                                        |
| 551 | +									$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; | 
                                                        |
| 552 | + $j = 0;  | 
                                                        |
| 553 | 553 | }  | 
                                                        
| 554 | 554 | $query_delete .= "'".$row['famtrackid']."',";  | 
                                                        
| 555 | 555 | }  | 
                                                        
| 556 | 556 |  			if ($i > 0) { | 
                                                        
| 557 | -    				try { | 
                                                        |
| 557 | +					try { | 
                                                        |
| 558 | 558 | |
| 559 | 559 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
| 560 | 560 | $sth->execute();  | 
                                                        
@@ -565,9 +565,9 @@ discard block  | 
                                                    ||
| 565 | 565 | return "success";  | 
                                                        
| 566 | 566 |  		} elseif ($globalDBdriver == 'pgsql') { | 
                                                        
| 567 | 567 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0";  | 
                                                        
| 568 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";  | 
                                                        |
| 569 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";  | 
                                                        |
| 570 | -    			try { | 
                                                        |
| 568 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";  | 
                                                        |
| 569 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";  | 
                                                        |
| 570 | +				try { | 
                                                        |
| 571 | 571 | |
| 572 | 572 | $sth = $this->db->prepare($query);  | 
                                                        
| 573 | 573 | $sth->execute();  | 
                                                        
@@ -611,17 +611,17 @@ discard block  | 
                                                    ||
| 611 | 611 | }  | 
                                                        
| 612 | 612 | |
| 613 | 613 | /**  | 
                                                        
| 614 | - * Deletes all info in the table for an ident  | 
                                                        |
| 615 | - *  | 
                                                        |
| 616 | - * @return String success or false  | 
                                                        |
| 617 | - *  | 
                                                        |
| 618 | - */  | 
                                                        |
| 614 | + * Deletes all info in the table for an ident  | 
                                                        |
| 615 | + *  | 
                                                        |
| 616 | + * @return String success or false  | 
                                                        |
| 617 | + *  | 
                                                        |
| 618 | + */  | 
                                                        |
| 619 | 619 | public function deleteLiveTrackerDataByIdent($ident)  | 
                                                        
| 620 | 620 |  	{ | 
                                                        
| 621 | 621 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 622 | 622 | $query = 'DELETE FROM tracker_live WHERE ident = :ident';  | 
                                                        
| 623 | 623 | |
| 624 | -    		try { | 
                                                        |
| 624 | +			try { | 
                                                        |
| 625 | 625 | |
| 626 | 626 | $sth = $this->db->prepare($query);  | 
                                                        
| 627 | 627 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
@@ -633,17 +633,17 @@ discard block  | 
                                                    ||
| 633 | 633 | }  | 
                                                        
| 634 | 634 | |
| 635 | 635 | /**  | 
                                                        
| 636 | - * Deletes all info in the table for an id  | 
                                                        |
| 637 | - *  | 
                                                        |
| 638 | - * @return String success or false  | 
                                                        |
| 639 | - *  | 
                                                        |
| 640 | - */  | 
                                                        |
| 636 | + * Deletes all info in the table for an id  | 
                                                        |
| 637 | + *  | 
                                                        |
| 638 | + * @return String success or false  | 
                                                        |
| 639 | + *  | 
                                                        |
| 640 | + */  | 
                                                        |
| 641 | 641 | public function deleteLiveTrackerDataById($id)  | 
                                                        
| 642 | 642 |  	{ | 
                                                        
| 643 | 643 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 644 | 644 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id';  | 
                                                        
| 645 | 645 | |
| 646 | -    		try { | 
                                                        |
| 646 | +			try { | 
                                                        |
| 647 | 647 | |
| 648 | 648 | $sth = $this->db->prepare($query);  | 
                                                        
| 649 | 649 |  			$sth->execute(array(':id' => $id)); | 
                                                        
@@ -656,11 +656,11 @@ discard block  | 
                                                    ||
| 656 | 656 | |
| 657 | 657 | |
| 658 | 658 | /**  | 
                                                        
| 659 | - * Gets the aircraft ident within the last hour  | 
                                                        |
| 660 | - *  | 
                                                        |
| 661 | - * @return String the ident  | 
                                                        |
| 662 | - *  | 
                                                        |
| 663 | - */  | 
                                                        |
| 659 | + * Gets the aircraft ident within the last hour  | 
                                                        |
| 660 | + *  | 
                                                        |
| 661 | + * @return String the ident  | 
                                                        |
| 662 | + *  | 
                                                        |
| 663 | + */  | 
                                                        |
| 664 | 664 | public function getIdentFromLastHour($ident)  | 
                                                        
| 665 | 665 |  	{ | 
                                                        
| 666 | 666 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -686,14 +686,14 @@ discard block  | 
                                                    ||
| 686 | 686 | $ident_result = $row['ident'];  | 
                                                        
| 687 | 687 | }  | 
                                                        
| 688 | 688 | return $ident_result;  | 
                                                        
| 689 | - }  | 
                                                        |
| 689 | + }  | 
                                                        |
| 690 | 690 | |
| 691 | 691 | /**  | 
                                                        
| 692 | - * Check recent aircraft  | 
                                                        |
| 693 | - *  | 
                                                        |
| 694 | - * @return String the ident  | 
                                                        |
| 695 | - *  | 
                                                        |
| 696 | - */  | 
                                                        |
| 692 | + * Check recent aircraft  | 
                                                        |
| 693 | + *  | 
                                                        |
| 694 | + * @return String the ident  | 
                                                        |
| 695 | + *  | 
                                                        |
| 696 | + */  | 
                                                        |
| 697 | 697 | public function checkIdentRecent($ident)  | 
                                                        
| 698 | 698 |  	{ | 
                                                        
| 699 | 699 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -719,14 +719,14 @@ discard block  | 
                                                    ||
| 719 | 719 | $ident_result = $row['famtrackid'];  | 
                                                        
| 720 | 720 | }  | 
                                                        
| 721 | 721 | return $ident_result;  | 
                                                        
| 722 | - }  | 
                                                        |
| 722 | + }  | 
                                                        |
| 723 | 723 | |
| 724 | 724 | /**  | 
                                                        
| 725 | - * Check recent aircraft by id  | 
                                                        |
| 726 | - *  | 
                                                        |
| 727 | - * @return String the ident  | 
                                                        |
| 728 | - *  | 
                                                        |
| 729 | - */  | 
                                                        |
| 725 | + * Check recent aircraft by id  | 
                                                        |
| 726 | + *  | 
                                                        |
| 727 | + * @return String the ident  | 
                                                        |
| 728 | + *  | 
                                                        |
| 729 | + */  | 
                                                        |
| 730 | 730 | public function checkIdRecent($id)  | 
                                                        
| 731 | 731 |  	{ | 
                                                        
| 732 | 732 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -752,19 +752,19 @@ discard block  | 
                                                    ||
| 752 | 752 | $ident_result = $row['famtrackid'];  | 
                                                        
| 753 | 753 | }  | 
                                                        
| 754 | 754 | return $ident_result;  | 
                                                        
| 755 | - }  | 
                                                        |
| 755 | + }  | 
                                                        |
| 756 | 756 | |
| 757 | 757 | /**  | 
                                                        
| 758 | - * Adds a new spotter data  | 
                                                        |
| 759 | - *  | 
                                                        |
| 760 | - * @param String $famtrackid the ID from flightaware  | 
                                                        |
| 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 | - *  | 
                                                        |
| 767 | - */  | 
                                                        |
| 758 | + * Adds a new spotter data  | 
                                                        |
| 759 | + *  | 
                                                        |
| 760 | + * @param String $famtrackid the ID from flightaware  | 
                                                        |
| 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 | + *  | 
                                                        |
| 767 | + */  | 
                                                        |
| 768 | 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;  | 
                                                        
@@ -837,8 +837,8 @@ discard block  | 
                                                    ||
| 837 | 837 | $comment = filter_var($comment,FILTER_SANITIZE_STRING);  | 
                                                        
| 838 | 838 | $type = filter_var($type,FILTER_SANITIZE_STRING);  | 
                                                        
| 839 | 839 | |
| 840 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 841 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 840 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 841 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 842 | 842 | |
| 843 | 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)';  | 
                                                        
@@ -848,9 +848,9 @@ discard block  | 
                                                    ||
| 848 | 848 | |
| 849 | 849 | $sth = $this->db->prepare($query);  | 
                                                        
| 850 | 850 | $sth->execute($query_values);  | 
                                                        
| 851 | -                } catch(PDOException $e) { | 
                                                        |
| 852 | - return "error : ".$e->getMessage();  | 
                                                        |
| 853 | - }  | 
                                                        |
| 851 | +				} catch(PDOException $e) { | 
                                                        |
| 852 | + return "error : ".$e->getMessage();  | 
                                                        |
| 853 | + }  | 
                                                        |
| 854 | 854 | /*  | 
                                                        
| 855 | 855 |  		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { | 
                                                        
| 856 | 856 | if ($globalDebug) echo '(Add to SBS archive : ';  | 
                                                        
@@ -16,33 +16,33 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | |
@@ -29,7 +29,9 @@ discard block  | 
                                                    ||
| 29 | 29 |  		if (isset($filter[0]['source'])) { | 
                                                        
| 30 | 30 | $filters = array_merge($filters,$filter);  | 
                                                        
| 31 | 31 | }  | 
                                                        
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 32 | +		if (is_array($globalFilter)) { | 
                                                        |
| 33 | + $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 34 | + }  | 
                                                        |
| 33 | 35 | $filter_query_join = '';  | 
                                                        
| 34 | 36 | $filter_query_where = '';  | 
                                                        
| 35 | 37 |  		foreach($filters as $flt) { | 
                                                        
@@ -76,8 +78,11 @@ discard block  | 
                                                    ||
| 76 | 78 |  		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 77 | 79 |  			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        
| 78 | 80 | }  | 
                                                        
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';  | 
                                                        |
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';  | 
                                                        |
| 81 | +		if ($filter_query_where == '' && $where) { | 
                                                        |
| 82 | + $filter_query_where = ' WHERE';  | 
                                                        |
| 83 | +		} elseif ($filter_query_where != '' && $and) { | 
                                                        |
| 84 | + $filter_query_where .= ' AND';  | 
                                                        |
| 85 | + }  | 
                                                        |
| 81 | 86 |  		if ($filter_query_where != '') { | 
                                                        
| 82 | 87 |  			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                        
| 83 | 88 | }  | 
                                                        
@@ -119,7 +124,9 @@ discard block  | 
                                                    ||
| 119 | 124 | }  | 
                                                        
| 120 | 125 | }  | 
                                                        
| 121 | 126 | |
| 122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 127 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 128 | + $globalLiveInterval = '200';  | 
                                                        |
| 129 | + }  | 
                                                        |
| 123 | 130 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 124 | 131 | //$query = "SELECT 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 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";  | 
                                                        
| 125 | 132 | $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'.$filter_query.$orderby_query;  | 
                                                        
@@ -144,7 +151,9 @@ discard block  | 
                                                    ||
| 144 | 151 | |
| 145 | 152 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 146 | 153 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 154 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 155 | + $globalLiveInterval = '200';  | 
                                                        |
| 156 | + }  | 
                                                        |
| 148 | 157 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 149 | 158 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source  | 
                                                        
| 150 | 159 | 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'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";  | 
                                                        
@@ -182,7 +191,9 @@ discard block  | 
                                                    ||
| 182 | 191 | |
| 183 | 192 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 184 | 193 | |
| 185 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 194 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 195 | + $globalLiveInterval = '200';  | 
                                                        |
| 196 | + }  | 
                                                        |
| 186 | 197 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 187 | 198 | $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 | 199 | 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'  | 
                                                        
@@ -215,7 +226,9 @@ discard block  | 
                                                    ||
| 215 | 226 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 216 | 227 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 217 | 228 | |
| 218 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 229 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 230 | + $globalLiveInterval = '200';  | 
                                                        |
| 231 | + }  | 
                                                        |
| 219 | 232 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 220 | 233 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        
| 221 | 234 |  		} else { | 
                                                        
@@ -243,7 +256,9 @@ discard block  | 
                                                    ||
| 243 | 256 |  	{ | 
                                                        
| 244 | 257 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 245 | 258 | $Spotter = new Spotter($this->db);  | 
                                                        
| 246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 259 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 260 | + $globalLiveInterval = '200';  | 
                                                        |
| 261 | + }  | 
                                                        |
| 247 | 262 | $filter_query = $this->getFilter($filter);  | 
                                                        
| 248 | 263 | |
| 249 | 264 |  		if (is_array($coord)) { | 
                                                        
@@ -251,7 +266,9 @@ discard block  | 
                                                    ||
| 251 | 266 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 252 | 267 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 253 | 268 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 254 | - } else return array();  | 
                                                        |
| 269 | +		} else { | 
                                                        |
| 270 | + return array();  | 
                                                        |
| 271 | + }  | 
                                                        |
| 255 | 272 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 256 | 273 | $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;  | 
                                                        
| 257 | 274 |  		} else { | 
                                                        
@@ -441,11 +458,15 @@ discard block  | 
                                                    ||
| 441 | 458 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';  | 
                                                        
| 442 | 459 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 443 | 460 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';  | 
                                                        
| 444 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        |
| 461 | +			if ($liveinterval) { | 
                                                        |
| 462 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        |
| 463 | + }  | 
                                                        |
| 445 | 464 | $query .= ' ORDER BY date';  | 
                                                        
| 446 | 465 |  		} else { | 
                                                        
| 447 | 466 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';  | 
                                                        
| 448 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";  | 
                                                        |
| 467 | +			if ($liveinterval) { | 
                                                        |
| 468 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";  | 
                                                        |
| 469 | + }  | 
                                                        |
| 449 | 470 | $query .= ' ORDER BY date';  | 
                                                        
| 450 | 471 | }  | 
                                                        
| 451 | 472 | |
@@ -540,7 +561,9 @@ discard block  | 
                                                    ||
| 540 | 561 | $i++;  | 
                                                        
| 541 | 562 | $j++;  | 
                                                        
| 542 | 563 |  				if ($j == 30) { | 
                                                        
| 543 | - if ($globalDebug) echo ".";  | 
                                                        |
| 564 | +					if ($globalDebug) { | 
                                                        |
| 565 | + echo ".";  | 
                                                        |
| 566 | + }  | 
                                                        |
| 544 | 567 |  				    	try { | 
                                                        
| 545 | 568 | |
| 546 | 569 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
@@ -787,7 +810,9 @@ discard block  | 
                                                    ||
| 787 | 810 |  			{ | 
                                                        
| 788 | 811 | return false;  | 
                                                        
| 789 | 812 | }  | 
                                                        
| 790 | - } else return '';  | 
                                                        |
| 813 | +		} else { | 
                                                        |
| 814 | + return '';  | 
                                                        |
| 815 | + }  | 
                                                        |
| 791 | 816 | |
| 792 | 817 | if ($longitude != '')  | 
                                                        
| 793 | 818 |  		{ | 
                                                        
@@ -795,7 +820,9 @@ discard block  | 
                                                    ||
| 795 | 820 |  			{ | 
                                                        
| 796 | 821 | return false;  | 
                                                        
| 797 | 822 | }  | 
                                                        
| 798 | - } else return '';  | 
                                                        |
| 823 | +		} else { | 
                                                        |
| 824 | + return '';  | 
                                                        |
| 825 | + }  | 
                                                        |
| 799 | 826 | |
| 800 | 827 | if ($altitude != '')  | 
                                                        
| 801 | 828 |  		{ | 
                                                        
@@ -803,7 +830,9 @@ discard block  | 
                                                    ||
| 803 | 830 |  			{ | 
                                                        
| 804 | 831 | return false;  | 
                                                        
| 805 | 832 | }  | 
                                                        
| 806 | - } else $altitude = 0;  | 
                                                        |
| 833 | +		} else { | 
                                                        |
| 834 | + $altitude = 0;  | 
                                                        |
| 835 | + }  | 
                                                        |
| 807 | 836 | |
| 808 | 837 | if ($heading != '')  | 
                                                        
| 809 | 838 |  		{ | 
                                                        
@@ -811,7 +840,9 @@ discard block  | 
                                                    ||
| 811 | 840 |  			{ | 
                                                        
| 812 | 841 | return false;  | 
                                                        
| 813 | 842 | }  | 
                                                        
| 814 | - } else $heading = 0;  | 
                                                        |
| 843 | +		} else { | 
                                                        |
| 844 | + $heading = 0;  | 
                                                        |
| 845 | + }  | 
                                                        |
| 815 | 846 | |
| 816 | 847 | if ($groundspeed != '')  | 
                                                        
| 817 | 848 |  		{ | 
                                                        
@@ -819,9 +850,13 @@ discard block  | 
                                                    ||
| 819 | 850 |  			{ | 
                                                        
| 820 | 851 | return false;  | 
                                                        
| 821 | 852 | }  | 
                                                        
| 822 | - } else $groundspeed = 0;  | 
                                                        |
| 853 | +		} else { | 
                                                        |
| 854 | + $groundspeed = 0;  | 
                                                        |
| 855 | + }  | 
                                                        |
| 823 | 856 |  		date_default_timezone_set('UTC'); | 
                                                        
| 824 | -		if ($date == '') $date = date("Y-m-d H:i:s", time()); | 
                                                        |
| 857 | +		if ($date == '') { | 
                                                        |
| 858 | +			$date = date("Y-m-d H:i:s", time()); | 
                                                        |
| 859 | + }  | 
                                                        |
| 825 | 860 | |
| 826 | 861 | |
| 827 | 862 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);  | 
                                                        
@@ -837,8 +872,12 @@ discard block  | 
                                                    ||
| 837 | 872 | $comment = filter_var($comment,FILTER_SANITIZE_STRING);  | 
                                                        
| 838 | 873 | $type = filter_var($type,FILTER_SANITIZE_STRING);  | 
                                                        
| 839 | 874 | |
| 840 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 841 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 875 | +            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { | 
                                                        |
| 876 | + $groundspeed = 0;  | 
                                                        |
| 877 | + }  | 
                                                        |
| 878 | +            	if ($heading == '' || $Common->isInteger($heading) === false ) { | 
                                                        |
| 879 | + $heading = 0;  | 
                                                        |
| 880 | + }  | 
                                                        |
| 842 | 881 | |
| 843 | 882 | $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type)  | 
                                                        
| 844 | 883 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';  | 
                                                        
@@ -131,5 +131,5 @@  | 
                                                    ||
| 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 | }  | 
                                                        
@@ -53,7 +53,12 @@ discard block  | 
                                                    ||
| 53 | 53 |  	} else { | 
                                                        
| 54 | 54 |  		for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) { | 
                                                        
| 55 | 55 | var entity = viewer.dataSources.get(dsn).entities.values[i];  | 
                                                        
| 56 | -			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { | 
                                                        |
| 56 | +			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { | 
                                                        |
| 57 | + print $globalMapRefresh*2000;  | 
                                                        |
| 58 | +} else { | 
                                                        |
| 59 | + print '60000';  | 
                                                        |
| 60 | +}  | 
                                                        |
| 61 | +?>)) { | 
                                                        |
| 57 | 62 | viewer.dataSources.get(dsn).entities.remove(entity);  | 
                                                        
| 58 | 63 |  			} else { | 
                                                        
| 59 | 64 | //console.log(parseInt(entity.lastupdate)+' > '+Math.floor(Date.now()-100));  | 
                                                        
@@ -127,7 +132,12 @@ discard block  | 
                                                    ||
| 127 | 132 |  		function(){ | 
                                                        
| 128 | 133 | updateMarineData();  | 
                                                        
| 129 | 134 | }  | 
                                                        
| 130 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);  | 
                                                        |
| 135 | +	,<?php if (isset($globalMapRefresh)) { | 
                                                        |
| 136 | + print $globalMapRefresh*1000;  | 
                                                        |
| 137 | +} else { | 
                                                        |
| 138 | + print '30000';  | 
                                                        |
| 139 | +}  | 
                                                        |
| 140 | +?>);  | 
                                                        |
| 131 | 141 |  } else { | 
                                                        
| 132 | 142 | var clockViewModel = new Cesium.ClockViewModel(viewer.clock);  | 
                                                        
| 133 | 143 | var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);  | 
                                                        
@@ -6,8 +6,8 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | }  | 
                                                        
@@ -3,11 +3,18 @@ discard block  | 
                                                    ||
| 3 | 3 |  require_once('../require/class.Language.php');  | 
                                                        
| 4 | 4 | |
| 5 | 5 | // Compressed GeoJson is used if true  | 
                                                        
| 6 | -if (!isset($globalJsonCompress)) $compress = true;  | 
                                                        |
| 7 | -else $compress = $globalJsonCompress;  | 
                                                        |
| 6 | +if (!isset($globalJsonCompress)) { | 
                                                        |
| 7 | + $compress = true;  | 
                                                        |
| 8 | +} else { | 
                                                        |
| 9 | + $compress = $globalJsonCompress;  | 
                                                        |
| 10 | +}  | 
                                                        |
| 8 | 11 | |
| 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);  | 
                                                        |
| 12 | +if (isset($_GET['ident'])) { | 
                                                        |
| 13 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);  | 
                                                        |
| 14 | +}  | 
                                                        |
| 15 | +if (isset($_GET['flightaware_id'])) { | 
                                                        |
| 16 | + $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);  | 
                                                        |
| 17 | +}  | 
                                                        |
| 11 | 18 | ?>  | 
                                                        
| 12 | 19 | |
| 13 | 20 | |
@@ -72,9 +79,12 @@ discard block  | 
                                                    ||
| 72 | 79 | |
| 73 | 80 |  function update_airportsLayer() { | 
                                                        
| 74 | 81 | <?php  | 
                                                        
| 75 | - if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];  | 
                                                        |
| 76 | - else $getZoom = '7';  | 
                                                        |
| 77 | -?>  | 
                                                        |
| 82 | +	if (isset($_COOKIE['AirportZoom'])) { | 
                                                        |
| 83 | + $getZoom = $_COOKIE['AirportZoom'];  | 
                                                        |
| 84 | +	} else { | 
                                                        |
| 85 | + $getZoom = '7';  | 
                                                        |
| 86 | + }  | 
                                                        |
| 87 | + ?>  | 
                                                        |
| 78 | 88 |  	if (typeof airportsLayer != 'undefined') { | 
                                                        
| 79 | 89 |  		if (map.hasLayer(airportsLayer) == true) { | 
                                                        
| 80 | 90 | map.removeLayer(airportsLayer);  | 
                                                        
@@ -290,9 +300,13 @@ discard block  | 
                                                    ||
| 290 | 300 |  					if (callsign != ""){ markerLabel += callsign; } | 
                                                        
| 291 | 301 |  					if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; } | 
                                                        
| 292 | 302 | <?php  | 
                                                        
| 293 | - if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor'];  | 
                                                        |
| 294 | - elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor;  | 
                                                        |
| 295 | - else $IconColor = '1a3151';  | 
                                                        |
| 303 | +	if (isset($_COOKIE['IconColor'])) { | 
                                                        |
| 304 | + $IconColor = $_COOKIE['IconColor'];  | 
                                                        |
| 305 | +	} elseif (isset($globalAircraftIconColor)) { | 
                                                        |
| 306 | + $IconColor = $globalAircraftIconColor;  | 
                                                        |
| 307 | +	} else { | 
                                                        |
| 308 | + $IconColor = '1a3151';  | 
                                                        |
| 309 | + }  | 
                                                        |
| 296 | 310 |  	if (!isset($ident) && !isset($flightaware_id)) { | 
                                                        
| 297 | 311 | ?>  | 
                                                        
| 298 | 312 | info_update(feature.properties.fc);  | 
                                                        
@@ -340,7 +354,12 @@ discard block  | 
                                                    ||
| 340 | 354 | <?php  | 
                                                        
| 341 | 355 |  		} else { | 
                                                        
| 342 | 356 | ?>  | 
                                                        
| 343 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);  | 
                                                        |
| 357 | +					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { | 
                                                        |
| 358 | + print $archiveupdatetime*1000;  | 
                                                        |
| 359 | +} else { | 
                                                        |
| 360 | + print $globalMapRefresh*1000+20000;  | 
                                                        |
| 361 | +}  | 
                                                        |
| 362 | +?>+feature.properties.sqt*1000);  | 
                                                        |
| 344 | 363 |  					return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ | 
                                                        
| 345 | 364 | <?php  | 
                                                        
| 346 | 365 | }  | 
                                                        
@@ -382,7 +401,12 @@ discard block  | 
                                                    ||
| 382 | 401 | <?php  | 
                                                        
| 383 | 402 |  		} else { | 
                                                        
| 384 | 403 | ?>  | 
                                                        
| 385 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);  | 
                                                        |
| 404 | +						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { | 
                                                        |
| 405 | + print $archiveupdatetime*1000;  | 
                                                        |
| 406 | +} else { | 
                                                        |
| 407 | + print $globalMapRefresh*1000+20000;  | 
                                                        |
| 408 | +}  | 
                                                        |
| 409 | +?>+feature.properties.sqt*1000);  | 
                                                        |
| 386 | 410 |  						return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ | 
                                                        
| 387 | 411 | <?php  | 
                                                        
| 388 | 412 | }  | 
                                                        
@@ -422,7 +446,12 @@ discard block  | 
                                                    ||
| 422 | 446 | <?php  | 
                                                        
| 423 | 447 |  		} else { | 
                                                        
| 424 | 448 | ?>  | 
                                                        
| 425 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);  | 
                                                        |
| 449 | +							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { | 
                                                        |
| 450 | + print $archiveupdatetime*1000;  | 
                                                        |
| 451 | +} else { | 
                                                        |
| 452 | + print $globalMapRefresh*1000+20000;  | 
                                                        |
| 453 | +}  | 
                                                        |
| 454 | +?>+feature.properties.sqt*1000);  | 
                                                        |
| 426 | 455 |  							return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ | 
                                                        
| 427 | 456 | <?php  | 
                                                        
| 428 | 457 | }  | 
                                                        
@@ -759,13 +788,23 @@ discard block  | 
                                                    ||
| 759 | 788 |  	if (isset($archive) && $archive) { | 
                                                        
| 760 | 789 | ?>  | 
                                                        
| 761 | 790 | //then load it again every 30 seconds  | 
                                                        
| 762 | -	//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); | 
                                                        |
| 791 | +	//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { | 
                                                        |
| 792 | + print ($globalMapRefresh*1000)/2;  | 
                                                        |
| 793 | +} else { | 
                                                        |
| 794 | + print '15000';  | 
                                                        |
| 795 | +}  | 
                                                        |
| 796 | +?>);  | 
                                                        |
| 763 | 797 |  	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>); | 
                                                        
| 764 | 798 | <?php  | 
                                                        
| 765 | 799 |  	} else { | 
                                                        
| 766 | 800 | ?>  | 
                                                        
| 767 | 801 | //then load it again every 30 seconds  | 
                                                        
| 768 | -	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); | 
                                                        |
| 802 | +	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { | 
                                                        |
| 803 | + print $globalMapRefresh*1000;  | 
                                                        |
| 804 | +} else { | 
                                                        |
| 805 | + print '30000';  | 
                                                        |
| 806 | +}  | 
                                                        |
| 807 | +?>);  | 
                                                        |
| 769 | 808 | var currentdate = new Date();  | 
                                                        
| 770 | 809 | var currentyear = new Date().getFullYear();  | 
                                                        
| 771 | 810 | var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0));  | 
                                                        
@@ -777,7 +816,12 @@ discard block  | 
                                                    ||
| 777 | 816 |  		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { | 
                                                        
| 778 | 817 | ?>  | 
                                                        
| 779 | 818 | update_polarLayer();  | 
                                                        
| 780 | -	setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); | 
                                                        |
| 819 | +	setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) { | 
                                                        |
| 820 | + print $globalMapRefresh*1000*2;  | 
                                                        |
| 821 | +} else { | 
                                                        |
| 822 | + print '60000';  | 
                                                        |
| 823 | +}  | 
                                                        |
| 824 | +?>);  | 
                                                        |
| 781 | 825 | <?php  | 
                                                        
| 782 | 826 | }  | 
                                                        
| 783 | 827 | ?>  | 
                                                        
@@ -792,7 +836,12 @@ discard block  | 
                                                    ||
| 792 | 836 |  	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { | 
                                                        
| 793 | 837 | ?>  | 
                                                        
| 794 | 838 | update_atcLayer();  | 
                                                        
| 795 | -	setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); | 
                                                        |
| 839 | +	setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) { | 
                                                        |
| 840 | + print $globalMapRefresh*1000*2;  | 
                                                        |
| 841 | +} else { | 
                                                        |
| 842 | + print '60000';  | 
                                                        |
| 843 | +}  | 
                                                        |
| 844 | +?>);  | 
                                                        |
| 796 | 845 | <?php  | 
                                                        
| 797 | 846 | }  | 
                                                        
| 798 | 847 | ?>  | 
                                                        
@@ -131,5 +131,5 @@  | 
                                                    ||
| 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 | }  | 
                                                        
@@ -53,7 +53,12 @@ discard block  | 
                                                    ||
| 53 | 53 |  	} else { | 
                                                        
| 54 | 54 |  		for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) { | 
                                                        
| 55 | 55 | var entity = viewer.dataSources.get(dsn).entities.values[i];  | 
                                                        
| 56 | -			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { | 
                                                        |
| 56 | +			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { | 
                                                        |
| 57 | + print $globalMapRefresh*2000;  | 
                                                        |
| 58 | +} else { | 
                                                        |
| 59 | + print '60000';  | 
                                                        |
| 60 | +}  | 
                                                        |
| 61 | +?>)) { | 
                                                        |
| 57 | 62 | viewer.dataSources.get(dsn).entities.remove(entity);  | 
                                                        
| 58 | 63 |  			} else { | 
                                                        
| 59 | 64 | //console.log(parseInt(entity.lastupdate)+' > '+Math.floor(Date.now()-100));  | 
                                                        
@@ -127,7 +132,12 @@ discard block  | 
                                                    ||
| 127 | 132 |  		function(){ | 
                                                        
| 128 | 133 | updateTrackerData();  | 
                                                        
| 129 | 134 | }  | 
                                                        
| 130 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);  | 
                                                        |
| 135 | +	,<?php if (isset($globalMapRefresh)) { | 
                                                        |
| 136 | + print $globalMapRefresh*1000;  | 
                                                        |
| 137 | +} else { | 
                                                        |
| 138 | + print '30000';  | 
                                                        |
| 139 | +}  | 
                                                        |
| 140 | +?>);  | 
                                                        |
| 131 | 141 |  } else { | 
                                                        
| 132 | 142 | var clockViewModel = new Cesium.ClockViewModel(viewer.clock);  | 
                                                        
| 133 | 143 | var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);  |