|  | @@ -2,7 +2,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 2 | 2 |  require_once(dirname(__FILE__).'/class.Image.php'); | 
                                                                                                            
                                                            | 3 | 3 |  $global_query = "SELECT marine_output.* FROM marine_output"; | 
                                                                                                            
                                                            | 4 | 4 |   | 
                                                                                                            
                                                            | 5 |  | -class Marine{ | 
                                                                                                            
                                                            |  | 5 | +class Marine { | 
                                                                                                            
                                                            | 6 | 6 |  	public $db; | 
                                                                                                            
                                                            | 7 | 7 |  	 | 
                                                                                                            
                                                            | 8 | 8 |  	public function __construct($dbc = null) { | 
                                                                                                                                                        
                                                        |  | @@ -17,33 +17,33 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 17 | 17 |  	* @return Array the SQL part | 
                                                                                                            
                                                            | 18 | 18 |  	*/ | 
                                                                                                            
                                                            | 19 | 19 |  	 | 
                                                                                                            
                                                            | 20 |  | -	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                                                                            
                                                            |  | 20 | +	public function getFilter($filter = array(), $where = false, $and = false) { | 
                                                                                                            
                                                            | 21 | 21 |  		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; | 
                                                                                                            
                                                            | 22 | 22 |  		$filters = array(); | 
                                                                                                            
                                                            | 23 | 23 |  		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { | 
                                                                                                            
                                                            | 24 | 24 |  			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { | 
                                                                                                            
                                                            | 25 | 25 |  				$filters = $globalStatsFilters[$globalFilterName]; | 
                                                                                                            
                                                            | 26 | 26 |  			} else { | 
                                                                                                            
                                                            | 27 |  | -				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); | 
                                                                                                            
                                                            |  | 27 | +				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); | 
                                                                                                            
                                                            | 28 | 28 |  			} | 
                                                                                                            
                                                            | 29 | 29 |  		} | 
                                                                                                            
                                                            | 30 | 30 |  		if (isset($filter[0]['source'])) { | 
                                                                                                            
                                                            | 31 |  | -			$filters = array_merge($filters,$filter); | 
                                                                                                            
                                                            |  | 31 | +			$filters = array_merge($filters, $filter); | 
                                                                                                            
                                                            | 32 | 32 |  		} | 
                                                                                                            
                                                            | 33 |  | -		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); | 
                                                                                                            
                                                            |  | 33 | +		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); | 
                                                                                                            
                                                            | 34 | 34 |  		$filter_query_join = ''; | 
                                                                                                            
                                                            | 35 | 35 |  		$filter_query_where = ''; | 
                                                                                                            
                                                            | 36 |  | -		foreach($filters as $flt) { | 
                                                                                                            
                                                            |  | 36 | +		foreach ($filters as $flt) { | 
                                                                                                            
                                                            | 37 | 37 |  			if (isset($flt['idents']) && !empty($flt['idents'])) { | 
                                                                                                            
                                                            | 38 | 38 |  				if (isset($flt['source'])) { | 
                                                                                                            
                                                            | 39 |  | -					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; | 
                                                                                                            
                                                            |  | 39 | +					$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 | 40 |  				} else { | 
                                                                                                            
                                                            | 41 |  | -					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; | 
                                                                                                            
                                                            |  | 41 | +					$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 | 42 |  				} | 
                                                                                                            
                                                            | 43 | 43 |  			} | 
                                                                                                            
                                                            | 44 | 44 |  		} | 
                                                                                                            
                                                            | 45 | 45 |  		if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                                                                            
                                                            | 46 |  | -			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; | 
                                                                                                            
                                                            |  | 46 | +			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; | 
                                                                                                            
                                                            | 47 | 47 |  		} | 
                                                                                                            
                                                            | 48 | 48 |  		if (isset($filter['ident']) && !empty($filter['ident'])) { | 
                                                                                                            
                                                            | 49 | 49 |  			$filter_query_where .= " AND ident = '".$filter['ident']."'"; | 
                                                                                                                                                        
                                                        |  | @@ -75,7 +75,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 75 | 75 |  		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; | 
                                                                                                            
                                                            | 76 | 76 |  		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; | 
                                                                                                            
                                                            | 77 | 77 |  		if ($filter_query_where != '') { | 
                                                                                                            
                                                            | 78 |  | -			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                                                                            
                                                            |  | 78 | +			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); | 
                                                                                                            
                                                            | 79 | 79 |  		} | 
                                                                                                            
                                                            | 80 | 80 |  		$filter_query = $filter_query_join.$filter_query_where; | 
                                                                                                            
                                                            | 81 | 81 |  		return $filter_query; | 
                                                                                                                                                        
                                                        |  | @@ -90,7 +90,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 90 | 90 |  	* @return Array the spotter information | 
                                                                                                            
                                                            | 91 | 91 |  	* | 
                                                                                                            
                                                            | 92 | 92 |  	*/ | 
                                                                                                            
                                                            | 93 |  | -	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) | 
                                                                                                            
                                                            |  | 93 | +	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) | 
                                                                                                            
                                                            | 94 | 94 |  	{ | 
                                                                                                            
                                                            | 95 | 95 |  		date_default_timezone_set('UTC'); | 
                                                                                                            
                                                            | 96 | 96 |  		if (!is_string($query)) | 
                                                                                                                                                        
                                                        |  | @@ -110,13 +110,13 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 110 | 110 |  			$sth = $this->db->prepare($query.$limitQuery); | 
                                                                                                            
                                                            | 111 | 111 |  			$sth->execute($params); | 
                                                                                                            
                                                            | 112 | 112 |  		} catch (PDOException $e) { | 
                                                                                                            
                                                            | 113 |  | -			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); | 
                                                                                                            
                                                            |  | 113 | +			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); | 
                                                                                                            
                                                            | 114 | 114 |  			exit(); | 
                                                                                                            
                                                            | 115 | 115 |  		} | 
                                                                                                            
                                                            | 116 | 116 |  		 | 
                                                                                                            
                                                            | 117 | 117 |  		$num_rows = 0; | 
                                                                                                            
                                                            | 118 | 118 |  		$spotter_array = array(); | 
                                                                                                            
                                                            | 119 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 119 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 120 | 120 |  		{ | 
                                                                                                            
                                                            | 121 | 121 |  			$num_rows++; | 
                                                                                                            
                                                            | 122 | 122 |  			$temp_array = array(); | 
                                                                                                                                                        
                                                        |  | @@ -148,10 +148,10 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 148 | 148 |  			} | 
                                                                                                            
                                                            | 149 | 149 |  			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; | 
                                                                                                            
                                                            | 150 | 150 |   | 
                                                                                                            
                                                            | 151 |  | -			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") | 
                                                                                                            
                                                            |  | 151 | +			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") | 
                                                                                                            
                                                            | 152 | 152 |  			{ | 
                                                                                                            
                                                            | 153 | 153 |  				$Image = new Image($this->db); | 
                                                                                                            
                                                            | 154 |  | -				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); | 
                                                                                                            
                                                            |  | 154 | +				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); | 
                                                                                                            
                                                            | 155 | 155 |  				else $image_array = $Image->getMarineImage($temp_array['mmsi']); | 
                                                                                                            
                                                            | 156 | 156 |  				unset($Image); | 
                                                                                                            
                                                            | 157 | 157 |  				if (count($image_array) > 0) { | 
                                                                                                                                                        
                                                        |  | @@ -187,17 +187,17 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 187 | 187 |  				{ | 
                                                                                                            
                                                            | 188 | 188 |  					$temp_array['date'] = "about ".$dateArray['hours']." hours ago"; | 
                                                                                                            
                                                            | 189 | 189 |  				} else { | 
                                                                                                            
                                                            | 190 |  | -					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); | 
                                                                                                            
                                                            |  | 190 | +					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); | 
                                                                                                            
                                                            | 191 | 191 |  				} | 
                                                                                                            
                                                            | 192 | 192 |  				$temp_array['date_minutes_past'] = $dateArray['minutes']; | 
                                                                                                            
                                                            | 193 |  | -				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); | 
                                                                                                            
                                                            | 194 |  | -				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); | 
                                                                                                            
                                                            |  | 193 | +				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); | 
                                                                                                            
                                                            |  | 194 | +				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); | 
                                                                                                            
                                                            | 195 | 195 |  				$temp_array['date_unix'] = strtotime($row['date']." UTC"); | 
                                                                                                            
                                                            | 196 | 196 |  				if (isset($row['last_seen']) && $row['last_seen'] != '') { | 
                                                                                                            
                                                            | 197 | 197 |  					if (strtotime($row['last_seen']) > strtotime($row['date'])) { | 
                                                                                                            
                                                            | 198 | 198 |  						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); | 
                                                                                                            
                                                            | 199 |  | -						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); | 
                                                                                                            
                                                            | 200 |  | -						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); | 
                                                                                                            
                                                            |  | 199 | +						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); | 
                                                                                                            
                                                            |  | 200 | +						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); | 
                                                                                                            
                                                            | 201 | 201 |  						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); | 
                                                                                                            
                                                            | 202 | 202 |  					} | 
                                                                                                            
                                                            | 203 | 203 |  				} | 
                                                                                                                                                        
                                                        |  | @@ -230,8 +230,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 230 | 230 |  		if ($limit != "") | 
                                                                                                            
                                                            | 231 | 231 |  		{ | 
                                                                                                            
                                                            | 232 | 232 |  			$limit_array = explode(",", $limit); | 
                                                                                                            
                                                            | 233 |  | -			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 234 |  | -			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 233 | +			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 234 | +			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 235 | 235 |  			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
                                                                                                            
                                                            | 236 | 236 |  			{ | 
                                                                                                            
                                                            | 237 | 237 |  				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
                                                                                                                                                        
                                                        |  | @@ -245,8 +245,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 245 | 245 |  		} else { | 
                                                                                                            
                                                            | 246 | 246 |  			$orderby_query = " ORDER BY marine_output.date DESC"; | 
                                                                                                            
                                                            | 247 | 247 |  		} | 
                                                                                                            
                                                            | 248 |  | -		$query  = $global_query.$filter_query." ".$orderby_query; | 
                                                                                                            
                                                            | 249 |  | -		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); | 
                                                                                                            
                                                            |  | 248 | +		$query = $global_query.$filter_query." ".$orderby_query; | 
                                                                                                            
                                                            |  | 249 | +		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); | 
                                                                                                            
                                                            | 250 | 250 |  		return $spotter_array; | 
                                                                                                            
                                                            | 251 | 251 |  	} | 
                                                                                                            
                                                            | 252 | 252 |       | 
                                                                                                                                                        
                                                        |  | @@ -264,8 +264,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 264 | 264 |  		if ($id == '') return array(); | 
                                                                                                            
                                                            | 265 | 265 |  		$additional_query = "marine_output.fammarine_id = :id"; | 
                                                                                                            
                                                            | 266 | 266 |  		$query_values = array(':id' => $id); | 
                                                                                                            
                                                            | 267 |  | -		$query  = $global_query." WHERE ".$additional_query." "; | 
                                                                                                            
                                                            | 268 |  | -		$spotter_array = $this->getDataFromDB($query,$query_values); | 
                                                                                                            
                                                            |  | 267 | +		$query = $global_query." WHERE ".$additional_query." "; | 
                                                                                                            
                                                            |  | 268 | +		$spotter_array = $this->getDataFromDB($query, $query_values); | 
                                                                                                            
                                                            | 269 | 269 |  		return $spotter_array; | 
                                                                                                            
                                                            | 270 | 270 |  	} | 
                                                                                                            
                                                            | 271 | 271 |   | 
                                                                                                                                                        
                                                        |  | @@ -284,7 +284,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 284 | 284 |  		$query_values = array(); | 
                                                                                                            
                                                            | 285 | 285 |  		$limit_query = ''; | 
                                                                                                            
                                                            | 286 | 286 |  		$additional_query = ''; | 
                                                                                                            
                                                            | 287 |  | -		$filter_query = $this->getFilter($filter,true,true); | 
                                                                                                            
                                                            |  | 287 | +		$filter_query = $this->getFilter($filter, true, true); | 
                                                                                                            
                                                            | 288 | 288 |  		if ($ident != "") | 
                                                                                                            
                                                            | 289 | 289 |  		{ | 
                                                                                                            
                                                            | 290 | 290 |  			if (!is_string($ident)) | 
                                                                                                                                                        
                                                        |  | @@ -300,8 +300,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 300 | 300 |  		{ | 
                                                                                                            
                                                            | 301 | 301 |  			$limit_array = explode(",", $limit); | 
                                                                                                            
                                                            | 302 | 302 |  			 | 
                                                                                                            
                                                            | 303 |  | -			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 304 |  | -			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 303 | +			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 304 | +			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 305 | 305 |  			 | 
                                                                                                            
                                                            | 306 | 306 |  			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
                                                                                                            
                                                            | 307 | 307 |  			{ | 
                                                                                                                                                        
                                                        |  | @@ -325,7 +325,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 325 | 325 |  		return $spotter_array; | 
                                                                                                            
                                                            | 326 | 326 |  	} | 
                                                                                                            
                                                            | 327 | 327 |  	 | 
                                                                                                            
                                                            | 328 |  | -	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) | 
                                                                                                            
                                                            |  | 328 | +	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) | 
                                                                                                            
                                                            | 329 | 329 |  	{ | 
                                                                                                            
                                                            | 330 | 330 |  		global $global_query, $globalTimezone, $globalDBdriver; | 
                                                                                                            
                                                            | 331 | 331 |  		 | 
                                                                                                                                                        
                                                        |  | @@ -333,7 +333,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 333 | 333 |  		$limit_query = ''; | 
                                                                                                            
                                                            | 334 | 334 |  		$additional_query = ''; | 
                                                                                                            
                                                            | 335 | 335 |   | 
                                                                                                            
                                                            | 336 |  | -		$filter_query = $this->getFilter($filter,true,true); | 
                                                                                                            
                                                            |  | 336 | +		$filter_query = $this->getFilter($filter, true, true); | 
                                                                                                            
                                                            | 337 | 337 |  		 | 
                                                                                                            
                                                            | 338 | 338 |  		if ($date != "") | 
                                                                                                            
                                                            | 339 | 339 |  		{ | 
                                                                                                                                                        
                                                        |  | @@ -359,8 +359,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 359 | 359 |  		{ | 
                                                                                                            
                                                            | 360 | 360 |  			$limit_array = explode(",", $limit); | 
                                                                                                            
                                                            | 361 | 361 |  			 | 
                                                                                                            
                                                            | 362 |  | -			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 363 |  | -			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 362 | +			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 363 | +			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 364 | 364 |  			 | 
                                                                                                            
                                                            | 365 | 365 |  			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
                                                                                                            
                                                            | 366 | 366 |  			{ | 
                                                                                                                                                        
                                                        |  | @@ -391,11 +391,11 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 391 | 391 |  	* @return Array list of source name | 
                                                                                                            
                                                            | 392 | 392 |  	* | 
                                                                                                            
                                                            | 393 | 393 |  	*/ | 
                                                                                                            
                                                            | 394 |  | -	public function getAllSourceName($type = '',$filters = array()) | 
                                                                                                            
                                                            |  | 394 | +	public function getAllSourceName($type = '', $filters = array()) | 
                                                                                                            
                                                            | 395 | 395 |  	{ | 
                                                                                                            
                                                            | 396 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            |  | 396 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            | 397 | 397 |  		$query_values = array(); | 
                                                                                                            
                                                            | 398 |  | -		$query  = "SELECT DISTINCT marine_output.source_name  | 
                                                                                                            
                                                            |  | 398 | +		$query = "SELECT DISTINCT marine_output.source_name  | 
                                                                                                            
                                                            | 399 | 399 |  				FROM marine_output".$filter_query." marine_output.source_name <> ''"; | 
                                                                                                            
                                                            | 400 | 400 |  		if ($type != '') { | 
                                                                                                            
                                                            | 401 | 401 |  			$query_values = array(':type' => $type); | 
                                                                                                                                                        
                                                        |  | @@ -410,7 +410,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 410 | 410 |  		$source_array = array(); | 
                                                                                                            
                                                            | 411 | 411 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 412 | 412 |  		 | 
                                                                                                            
                                                            | 413 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 413 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 414 | 414 |  		{ | 
                                                                                                            
                                                            | 415 | 415 |  			$temp_array['source_name'] = $row['source_name']; | 
                                                                                                            
                                                            | 416 | 416 |  			$source_array[] = $temp_array; | 
                                                                                                                                                        
                                                        |  | @@ -427,8 +427,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 427 | 427 |  	*/ | 
                                                                                                            
                                                            | 428 | 428 |  	public function getAllIdents($filters = array()) | 
                                                                                                            
                                                            | 429 | 429 |  	{ | 
                                                                                                            
                                                            | 430 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            | 431 |  | -		$query  = "SELECT DISTINCT marine_output.ident | 
                                                                                                            
                                                            |  | 430 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            |  | 431 | +		$query = "SELECT DISTINCT marine_output.ident | 
                                                                                                            
                                                            | 432 | 432 |  								FROM marine_output".$filter_query." marine_output.ident <> ''  | 
                                                                                                            
                                                            | 433 | 433 |  								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; | 
                                                                                                            
                                                            | 434 | 434 |   | 
                                                                                                                                                        
                                                        |  | @@ -438,7 +438,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 438 | 438 |  		$ident_array = array(); | 
                                                                                                            
                                                            | 439 | 439 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 440 | 440 |  		 | 
                                                                                                            
                                                            | 441 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 441 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 442 | 442 |  		{ | 
                                                                                                            
                                                            | 443 | 443 |  			$temp_array['ident'] = $row['ident']; | 
                                                                                                            
                                                            | 444 | 444 |  			$ident_array[] = $temp_array; | 
                                                                                                                                                        
                                                        |  | @@ -455,7 +455,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 455 | 455 |  	*/ | 
                                                                                                            
                                                            | 456 | 456 |  	public function getIdentity($mmsi) | 
                                                                                                            
                                                            | 457 | 457 |  	{ | 
                                                                                                            
                                                            | 458 |  | -		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 458 | +		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 459 | 459 |  		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; | 
                                                                                                            
                                                            | 460 | 460 |  		$sth = $this->db->prepare($query); | 
                                                                                                            
                                                            | 461 | 461 |  		$sth->execute(array(':mmsi' => $mmsi)); | 
                                                                                                                                                        
                                                        |  | @@ -468,18 +468,18 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 468 | 468 |  	* Add identity | 
                                                                                                            
                                                            | 469 | 469 |  	* | 
                                                                                                            
                                                            | 470 | 470 |  	*/ | 
                                                                                                            
                                                            | 471 |  | -	public function addIdentity($mmsi,$imo,$ident,$callsign,$type) | 
                                                                                                            
                                                            |  | 471 | +	public function addIdentity($mmsi, $imo, $ident, $callsign, $type) | 
                                                                                                            
                                                            | 472 | 472 |  	{ | 
                                                                                                            
                                                            | 473 |  | -		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 473 | +		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 474 | 474 |  		if ($mmsi != '') { | 
                                                                                                            
                                                            | 475 |  | -			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 476 |  | -			$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 477 |  | -			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 478 |  | -			$type = filter_var($type,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 475 | +			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 476 | +			$ident = filter_var($ident, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 477 | +			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 478 | +			$type = filter_var($type, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 479 | 479 |  			if (empty($this->getIdentity($mmsi))) { | 
                                                                                                            
                                                            | 480 |  | -				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; | 
                                                                                                            
                                                            |  | 480 | +				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; | 
                                                                                                            
                                                            | 481 | 481 |  				$sth = $this->db->prepare($query); | 
                                                                                                            
                                                            | 482 |  | -				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); | 
                                                                                                            
                                                            |  | 482 | +				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); | 
                                                                                                            
                                                            | 483 | 483 |  			} | 
                                                                                                            
                                                            | 484 | 484 |  		} | 
                                                                                                            
                                                            | 485 | 485 |  	} | 
                                                                                                                                                        
                                                        |  | @@ -500,12 +500,12 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 500 | 500 |  		} else $offset = '+00:00'; | 
                                                                                                            
                                                            | 501 | 501 |   | 
                                                                                                            
                                                            | 502 | 502 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 503 |  | -			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date | 
                                                                                                            
                                                            |  | 503 | +			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date | 
                                                                                                            
                                                            | 504 | 504 |  								FROM marine_output | 
                                                                                                            
                                                            | 505 | 505 |  								WHERE marine_output.date <> ''  | 
                                                                                                            
                                                            | 506 | 506 |  								ORDER BY marine_output.date ASC LIMIT 0,100"; | 
                                                                                                            
                                                            | 507 | 507 |  		} else { | 
                                                                                                            
                                                            | 508 |  | -			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date | 
                                                                                                            
                                                            |  | 508 | +			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date | 
                                                                                                            
                                                            | 509 | 509 |  								FROM marine_output | 
                                                                                                            
                                                            | 510 | 510 |  								WHERE marine_output.date <> ''  | 
                                                                                                            
                                                            | 511 | 511 |  								ORDER BY marine_output.date ASC LIMIT 0,100"; | 
                                                                                                                                                        
                                                        |  | @@ -517,7 +517,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 517 | 517 |  		$date_array = array(); | 
                                                                                                            
                                                            | 518 | 518 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 519 | 519 |  		 | 
                                                                                                            
                                                            | 520 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 520 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 521 | 521 |  		{ | 
                                                                                                            
                                                            | 522 | 522 |  			$temp_array['date'] = $row['date']; | 
                                                                                                            
                                                            | 523 | 523 |   | 
                                                                                                                                                        
                                                        |  | @@ -535,10 +535,10 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 535 | 535 |  	* @return String success or false | 
                                                                                                            
                                                            | 536 | 536 |  	* | 
                                                                                                            
                                                            | 537 | 537 |  	*/ | 
                                                                                                            
                                                            | 538 |  | -	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) | 
                                                                                                            
                                                            |  | 538 | +	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) | 
                                                                                                            
                                                            | 539 | 539 |  	{ | 
                                                                                                            
                                                            | 540 | 540 |  		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; | 
                                                                                                            
                                                            | 541 |  | -		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); | 
                                                                                                            
                                                            |  | 541 | +		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); | 
                                                                                                            
                                                            | 542 | 542 |  		try { | 
                                                                                                            
                                                            | 543 | 543 |  			$sth = $this->db->prepare($query); | 
                                                                                                            
                                                            | 544 | 544 |  			$sth->execute($query_values); | 
                                                                                                                                                        
                                                        |  | @@ -557,11 +557,11 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 557 | 557 |  	* @return String success or false | 
                                                                                                            
                                                            | 558 | 558 |  	* | 
                                                                                                            
                                                            | 559 | 559 |  	*/ | 
                                                                                                            
                                                            | 560 |  | -	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') | 
                                                                                                            
                                                            |  | 560 | +	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') | 
                                                                                                            
                                                            | 561 | 561 |  	{ | 
                                                                                                            
                                                            | 562 | 562 |   | 
                                                                                                            
                                                            | 563 | 563 |  		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; | 
                                                                                                            
                                                            | 564 |  | -                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); | 
                                                                                                            
                                                            |  | 564 | +                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); | 
                                                                                                            
                                                            | 565 | 565 |   | 
                                                                                                            
                                                            | 566 | 566 |  		try { | 
                                                                                                            
                                                            | 567 | 567 |  			$sth = $this->db->prepare($query); | 
                                                                                                                                                        
                                                        |  | @@ -584,7 +584,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 584 | 584 |  	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') | 
                                                                                                            
                                                            | 585 | 585 |  	{ | 
                                                                                                            
                                                            | 586 | 586 |  		$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'; | 
                                                                                                            
                                                            | 587 |  | -                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); | 
                                                                                                            
                                                            |  | 587 | +                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); | 
                                                                                                            
                                                            | 588 | 588 |   | 
                                                                                                            
                                                            | 589 | 589 |  		try { | 
                                                                                                            
                                                            | 590 | 590 |  			$sth = $this->db->prepare($query); | 
                                                                                                                                                        
                                                        |  | @@ -622,7 +622,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 622 | 622 |  	* @param String $verticalrate vertival rate of flight | 
                                                                                                            
                                                            | 623 | 623 |  	* @return String success or false | 
                                                                                                            
                                                            | 624 | 624 |  	*/ | 
                                                                                                            
                                                            | 625 |  | -	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') | 
                                                                                                            
                                                            |  | 625 | +	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') | 
                                                                                                            
                                                            | 626 | 626 |  	{ | 
                                                                                                            
                                                            | 627 | 627 |  		global $globalURL, $globalMarineImageFetch; | 
                                                                                                            
                                                            | 628 | 628 |  		 | 
                                                                                                                                                        
                                                        |  | @@ -689,31 +689,31 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 689 | 689 |  		} | 
                                                                                                            
                                                            | 690 | 690 |   | 
                                                                                                            
                                                            | 691 | 691 |       | 
                                                                                                            
                                                            | 692 |  | -		if ($date == "" || strtotime($date) < time()-20*60) | 
                                                                                                            
                                                            |  | 692 | +		if ($date == "" || strtotime($date) < time() - 20*60) | 
                                                                                                            
                                                            | 693 | 693 |  		{ | 
                                                                                                            
                                                            | 694 | 694 |  			$date = date("Y-m-d H:i:s", time()); | 
                                                                                                            
                                                            | 695 | 695 |  		} | 
                                                                                                            
                                                            | 696 | 696 |   | 
                                                                                                            
                                                            | 697 |  | -		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 698 |  | -		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 699 |  | -		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            | 700 |  | -		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            | 701 |  | -		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 702 |  | -		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            | 703 |  | -		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 704 |  | -		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 705 |  | -		$type = filter_var($type,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 706 |  | -		$status = filter_var($status,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 707 |  | -		$imo = filter_var($imo,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 708 |  | -		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 709 |  | -		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 710 |  | -		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 697 | +		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 698 | +		$ident = filter_var($ident, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 699 | +		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            |  | 700 | +		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            |  | 701 | +		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 702 | +		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            |  | 703 | +		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 704 | +		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 705 | +		$type = filter_var($type, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 706 | +		$status = filter_var($status, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 707 | +		$imo = filter_var($imo, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 708 | +		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 709 | +		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 710 | +		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 711 | 711 |  	 | 
                                                                                                            
                                                            | 712 | 712 |  		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { | 
                                                                                                            
                                                            | 713 | 713 |  			$Image = new Image($this->db); | 
                                                                                                            
                                                            | 714 |  | -			$image_array = $Image->getMarineImage($mmsi,$imo,$ident); | 
                                                                                                            
                                                            |  | 714 | +			$image_array = $Image->getMarineImage($mmsi, $imo, $ident); | 
                                                                                                            
                                                            | 715 | 715 |  			if (!isset($image_array[0]['mmsi'])) { | 
                                                                                                            
                                                            | 716 |  | -				$Image->addMarineImage($mmsi,$imo,$ident); | 
                                                                                                            
                                                            |  | 716 | +				$Image->addMarineImage($mmsi, $imo, $ident); | 
                                                                                                            
                                                            | 717 | 717 |  			} | 
                                                                                                            
                                                            | 718 | 718 |  			unset($Image); | 
                                                                                                            
                                                            | 719 | 719 |  		} | 
                                                                                                                                                        
                                                        |  | @@ -725,10 +725,10 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 725 | 725 |                  if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; | 
                                                                                                            
                                                            | 726 | 726 |                  if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; | 
                                                                                                            
                                                            | 727 | 727 |                  if ($arrival_date == '') $arrival_date = NULL; | 
                                                                                                            
                                                            | 728 |  | -		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date)  | 
                                                                                                            
                                                            |  | 728 | +		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date)  | 
                                                                                                            
                                                            | 729 | 729 |  		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; | 
                                                                                                            
                                                            | 730 | 730 |   | 
                                                                                                            
                                                            | 731 |  | -		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); | 
                                                                                                            
                                                            |  | 731 | +		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); | 
                                                                                                            
                                                            | 732 | 732 |  		try { | 
                                                                                                            
                                                            | 733 | 733 |  		         | 
                                                                                                            
                                                            | 734 | 734 |  			$sth = $this->db->prepare($query); | 
                                                                                                                                                        
                                                        |  | @@ -753,13 +753,13 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 753 | 753 |  	{ | 
                                                                                                            
                                                            | 754 | 754 |  		global $globalDBdriver, $globalTimezone; | 
                                                                                                            
                                                            | 755 | 755 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 756 |  | -			$query  = "SELECT marine_output.ident FROM marine_output  | 
                                                                                                            
                                                            |  | 756 | +			$query = "SELECT marine_output.ident FROM marine_output  | 
                                                                                                            
                                                            | 757 | 757 |  								WHERE marine_output.ident = :ident  | 
                                                                                                            
                                                            | 758 | 758 |  								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR)  | 
                                                                                                            
                                                            | 759 | 759 |  								AND marine_output.date < UTC_TIMESTAMP()"; | 
                                                                                                            
                                                            | 760 | 760 |  			$query_data = array(':ident' => $ident); | 
                                                                                                            
                                                            | 761 | 761 |  		} else { | 
                                                                                                            
                                                            | 762 |  | -			$query  = "SELECT marine_output.ident FROM marine_output  | 
                                                                                                            
                                                            |  | 762 | +			$query = "SELECT marine_output.ident FROM marine_output  | 
                                                                                                            
                                                            | 763 | 763 |  								WHERE marine_output.ident = :ident  | 
                                                                                                            
                                                            | 764 | 764 |  								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' | 
                                                                                                            
                                                            | 765 | 765 |  								AND marine_output.date < now() AT TIME ZONE 'UTC'"; | 
                                                                                                                                                        
                                                        |  | @@ -768,8 +768,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 768 | 768 |  		 | 
                                                                                                            
                                                            | 769 | 769 |  		$sth = $this->db->prepare($query); | 
                                                                                                            
                                                            | 770 | 770 |  		$sth->execute($query_data); | 
                                                                                                            
                                                            | 771 |  | -    		$ident_result=''; | 
                                                                                                            
                                                            | 772 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 771 | +    		$ident_result = ''; | 
                                                                                                            
                                                            |  | 772 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 773 | 773 |  		{ | 
                                                                                                            
                                                            | 774 | 774 |  			$ident_result = $row['ident']; | 
                                                                                                            
                                                            | 775 | 775 |  		} | 
                                                                                                                                                        
                                                        |  | @@ -795,8 +795,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 795 | 795 |  				return false; | 
                                                                                                            
                                                            | 796 | 796 |  			} else { | 
                                                                                                            
                                                            | 797 | 797 |  				$q_array = explode(" ", $q); | 
                                                                                                            
                                                            | 798 |  | -				foreach ($q_array as $q_item){ | 
                                                                                                            
                                                            | 799 |  | -					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 798 | +				foreach ($q_array as $q_item) { | 
                                                                                                            
                                                            |  | 799 | +					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 800 | 800 |  					$additional_query .= " AND ("; | 
                                                                                                            
                                                            | 801 | 801 |  					$additional_query .= "(marine_output.ident like '%".$q_item."%')"; | 
                                                                                                            
                                                            | 802 | 802 |  					$additional_query .= ")"; | 
                                                                                                                                                        
                                                        |  | @@ -804,11 +804,11 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 804 | 804 |  			} | 
                                                                                                            
                                                            | 805 | 805 |  		} | 
                                                                                                            
                                                            | 806 | 806 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 807 |  | -			$query  = "SELECT marine_output.* FROM marine_output  | 
                                                                                                            
                                                            |  | 807 | +			$query = "SELECT marine_output.* FROM marine_output  | 
                                                                                                            
                                                            | 808 | 808 |  				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query."  | 
                                                                                                            
                                                            | 809 | 809 |  				AND marine_output.date < UTC_TIMESTAMP()"; | 
                                                                                                            
                                                            | 810 | 810 |  		} else { | 
                                                                                                            
                                                            | 811 |  | -			$query  = "SELECT marine_output.* FROM marine_output  | 
                                                                                                            
                                                            |  | 811 | +			$query = "SELECT marine_output.* FROM marine_output  | 
                                                                                                            
                                                            | 812 | 812 |  				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query."  | 
                                                                                                            
                                                            | 813 | 813 |  				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; | 
                                                                                                            
                                                            | 814 | 814 |  		} | 
                                                                                                                                                        
                                                        |  | @@ -827,16 +827,16 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 827 | 827 |  	* | 
                                                                                                            
                                                            | 828 | 828 |  	*/ | 
                                                                                                            
                                                            | 829 | 829 |   | 
                                                                                                            
                                                            | 830 |  | -	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) | 
                                                                                                            
                                                            |  | 830 | +	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) | 
                                                                                                            
                                                            | 831 | 831 |  	{ | 
                                                                                                            
                                                            | 832 | 832 |  		global $globalDBdriver, $globalArchive; | 
                                                                                                            
                                                            | 833 | 833 |  		//$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            | 834 |  | -		$Connection= new Connection($this->db); | 
                                                                                                            
                                                            |  | 834 | +		$Connection = new Connection($this->db); | 
                                                                                                            
                                                            | 835 | 835 |  		if (!$Connection->tableExists('countries')) return array(); | 
                                                                                                            
                                                            | 836 | 836 |  		require_once('class.SpotterLive.php'); | 
                                                                                                            
                                                            | 837 | 837 |  		if (!isset($globalArchive) || $globalArchive !== TRUE) { | 
                                                                                                            
                                                            | 838 | 838 |  			$MarineLive = new MarineLive($this->db); | 
                                                                                                            
                                                            | 839 |  | -			$filter_query = $MarineLive->getFilter($filters,true,true); | 
                                                                                                            
                                                            |  | 839 | +			$filter_query = $MarineLive->getFilter($filters, true, true); | 
                                                                                                            
                                                            | 840 | 840 |  			$filter_query .= " over_country IS NOT NULL AND over_country <> ''"; | 
                                                                                                            
                                                            | 841 | 841 |  			if ($olderthanmonths > 0) { | 
                                                                                                            
                                                            | 842 | 842 |  				if ($globalDBdriver == 'mysql') { | 
                                                                                                                                                        
                                                        |  | @@ -856,7 +856,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 856 | 856 |  		} else { | 
                                                                                                            
                                                            | 857 | 857 |  			require_once(dirname(__FILE__)."/class.MarineArchive.php"); | 
                                                                                                            
                                                            | 858 | 858 |  			$MarineArchive = new MarineArchive($this->db); | 
                                                                                                            
                                                            | 859 |  | -			$filter_query = $MarineArchive->getFilter($filters,true,true); | 
                                                                                                            
                                                            |  | 859 | +			$filter_query = $MarineArchive->getFilter($filters, true, true); | 
                                                                                                            
                                                            | 860 | 860 |  			$filter_query .= " over_country <> ''"; | 
                                                                                                            
                                                            | 861 | 861 |  			if ($olderthanmonths > 0) { | 
                                                                                                            
                                                            | 862 | 862 |  				if ($globalDBdriver == 'mysql') { | 
                                                                                                                                                        
                                                        |  | @@ -884,7 +884,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 884 | 884 |  		$flight_array = array(); | 
                                                                                                            
                                                            | 885 | 885 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 886 | 886 |           | 
                                                                                                            
                                                            | 887 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 887 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 888 | 888 |  		{ | 
                                                                                                            
                                                            | 889 | 889 |  			$temp_array['marine_count'] = $row['nb']; | 
                                                                                                            
                                                            | 890 | 890 |  			$temp_array['marine_country'] = $row['name']; | 
                                                                                                                                                        
                                                        |  | @@ -903,11 +903,11 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 903 | 903 |  	* @return Array the callsign list | 
                                                                                                            
                                                            | 904 | 904 |  	* | 
                                                                                                            
                                                            | 905 | 905 |  	*/ | 
                                                                                                            
                                                            | 906 |  | -	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') | 
                                                                                                            
                                                            |  | 906 | +	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') | 
                                                                                                            
                                                            | 907 | 907 |  	{ | 
                                                                                                            
                                                            | 908 | 908 |  		global $globalDBdriver; | 
                                                                                                            
                                                            | 909 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            | 910 |  | -		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count  | 
                                                                                                            
                                                            |  | 909 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            |  | 910 | +		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count  | 
                                                                                                            
                                                            | 911 | 911 |                      FROM marine_output".$filter_query." marine_output.ident <> ''"; | 
                                                                                                            
                                                            | 912 | 912 |  		 if ($olderthanmonths > 0) { | 
                                                                                                            
                                                            | 913 | 913 |  			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; | 
                                                                                                                                                        
                                                        |  | @@ -921,28 +921,28 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 921 | 921 |  		if ($year != '') { | 
                                                                                                            
                                                            | 922 | 922 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 923 | 923 |  				$query .= " AND YEAR(marine_output.date) = :year"; | 
                                                                                                            
                                                            | 924 |  | -				$query_values = array_merge($query_values,array(':year' => $year)); | 
                                                                                                            
                                                            |  | 924 | +				$query_values = array_merge($query_values, array(':year' => $year)); | 
                                                                                                            
                                                            | 925 | 925 |  			} else { | 
                                                                                                            
                                                            | 926 | 926 |  				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; | 
                                                                                                            
                                                            | 927 |  | -				$query_values = array_merge($query_values,array(':year' => $year)); | 
                                                                                                            
                                                            |  | 927 | +				$query_values = array_merge($query_values, array(':year' => $year)); | 
                                                                                                            
                                                            | 928 | 928 |  			} | 
                                                                                                            
                                                            | 929 | 929 |  		} | 
                                                                                                            
                                                            | 930 | 930 |  		if ($month != '') { | 
                                                                                                            
                                                            | 931 | 931 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 932 | 932 |  				$query .= " AND MONTH(marine_output.date) = :month"; | 
                                                                                                            
                                                            | 933 |  | -				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                                                                            
                                                            |  | 933 | +				$query_values = array_merge($query_values, array(':month' => $month)); | 
                                                                                                            
                                                            | 934 | 934 |  			} else { | 
                                                                                                            
                                                            | 935 | 935 |  				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; | 
                                                                                                            
                                                            | 936 |  | -				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                                                                            
                                                            |  | 936 | +				$query_values = array_merge($query_values, array(':month' => $month)); | 
                                                                                                            
                                                            | 937 | 937 |  			} | 
                                                                                                            
                                                            | 938 | 938 |  		} | 
                                                                                                            
                                                            | 939 | 939 |  		if ($day != '') { | 
                                                                                                            
                                                            | 940 | 940 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 941 | 941 |  				$query .= " AND DAY(marine_output.date) = :day"; | 
                                                                                                            
                                                            | 942 |  | -				$query_values = array_merge($query_values,array(':day' => $day)); | 
                                                                                                            
                                                            |  | 942 | +				$query_values = array_merge($query_values, array(':day' => $day)); | 
                                                                                                            
                                                            | 943 | 943 |  			} else { | 
                                                                                                            
                                                            | 944 | 944 |  				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; | 
                                                                                                            
                                                            | 945 |  | -				$query_values = array_merge($query_values,array(':day' => $day)); | 
                                                                                                            
                                                            |  | 945 | +				$query_values = array_merge($query_values, array(':day' => $day)); | 
                                                                                                            
                                                            | 946 | 946 |  			} | 
                                                                                                            
                                                            | 947 | 947 |  		} | 
                                                                                                            
                                                            | 948 | 948 |  		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; | 
                                                                                                                                                        
                                                        |  | @@ -954,7 +954,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 954 | 954 |  		$callsign_array = array(); | 
                                                                                                            
                                                            | 955 | 955 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 956 | 956 |           | 
                                                                                                            
                                                            | 957 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 957 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 958 | 958 |  		{ | 
                                                                                                            
                                                            | 959 | 959 |  			$temp_array['callsign_icao'] = $row['ident']; | 
                                                                                                            
                                                            | 960 | 960 |  			$temp_array['airline_name'] = $row['airline_name']; | 
                                                                                                                                                        
                                                        |  | @@ -1006,7 +1006,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1006 | 1006 |  		$date_array = array(); | 
                                                                                                            
                                                            | 1007 | 1007 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1008 | 1008 |           | 
                                                                                                            
                                                            | 1009 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1009 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1010 | 1010 |  		{ | 
                                                                                                            
                                                            | 1011 | 1011 |  			$temp_array['date_name'] = $row['date_name']; | 
                                                                                                            
                                                            | 1012 | 1012 |  			$temp_array['date_count'] = $row['date_count']; | 
                                                                                                                                                        
                                                        |  | @@ -1032,7 +1032,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1032 | 1032 |  			$datetime = new DateTime(); | 
                                                                                                            
                                                            | 1033 | 1033 |  			$offset = $datetime->format('P'); | 
                                                                                                            
                                                            | 1034 | 1034 |  		} else $offset = '+00:00'; | 
                                                                                                            
                                                            | 1035 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            |  | 1035 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            | 1036 | 1036 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1037 | 1037 |  			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
                                                                                                            
                                                            | 1038 | 1038 |  								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; | 
                                                                                                                                                        
                                                        |  | @@ -1053,7 +1053,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1053 | 1053 |  		$date_array = array(); | 
                                                                                                            
                                                            | 1054 | 1054 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1055 | 1055 |           | 
                                                                                                            
                                                            | 1056 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1056 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1057 | 1057 |  		{ | 
                                                                                                            
                                                            | 1058 | 1058 |  			$temp_array['date_name'] = $row['date_name']; | 
                                                                                                            
                                                            | 1059 | 1059 |  			$temp_array['date_count'] = $row['date_count']; | 
                                                                                                                                                        
                                                        |  | @@ -1078,7 +1078,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1078 | 1078 |  			$datetime = new DateTime(); | 
                                                                                                            
                                                            | 1079 | 1079 |  			$offset = $datetime->format('P'); | 
                                                                                                            
                                                            | 1080 | 1080 |  		} else $offset = '+00:00'; | 
                                                                                                            
                                                            | 1081 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            |  | 1081 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            | 1082 | 1082 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1083 | 1083 |  			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
                                                                                                            
                                                            | 1084 | 1084 |  								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; | 
                                                                                                                                                        
                                                        |  | @@ -1099,7 +1099,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1099 | 1099 |  		$date_array = array(); | 
                                                                                                            
                                                            | 1100 | 1100 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1101 | 1101 |           | 
                                                                                                            
                                                            | 1102 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1102 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1103 | 1103 |  		{ | 
                                                                                                            
                                                            | 1104 | 1104 |  			$temp_array['date_name'] = $row['date_name']; | 
                                                                                                            
                                                            | 1105 | 1105 |  			$temp_array['date_count'] = $row['date_count']; | 
                                                                                                                                                        
                                                        |  | @@ -1146,7 +1146,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1146 | 1146 |  		$date_array = array(); | 
                                                                                                            
                                                            | 1147 | 1147 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1148 | 1148 |           | 
                                                                                                            
                                                            | 1149 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1149 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1150 | 1150 |  		{ | 
                                                                                                            
                                                            | 1151 | 1151 |  			$temp_array['month_name'] = $row['month_name']; | 
                                                                                                            
                                                            | 1152 | 1152 |  			$temp_array['year_name'] = $row['year_name']; | 
                                                                                                                                                        
                                                        |  | @@ -1175,7 +1175,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1175 | 1175 |  			$datetime = new DateTime(); | 
                                                                                                            
                                                            | 1176 | 1176 |  			$offset = $datetime->format('P'); | 
                                                                                                            
                                                            | 1177 | 1177 |  		} else $offset = '+00:00'; | 
                                                                                                            
                                                            | 1178 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            |  | 1178 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            | 1179 | 1179 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1180 | 1180 |  			$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 | 
                                                                                                            
                                                            | 1181 | 1181 |  								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; | 
                                                                                                                                                        
                                                        |  | @@ -1196,7 +1196,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1196 | 1196 |  		$date_array = array(); | 
                                                                                                            
                                                            | 1197 | 1197 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1198 | 1198 |           | 
                                                                                                            
                                                            | 1199 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1199 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1200 | 1200 |  		{ | 
                                                                                                            
                                                            | 1201 | 1201 |  			$temp_array['year_name'] = $row['year_name']; | 
                                                                                                            
                                                            | 1202 | 1202 |  			$temp_array['month_name'] = $row['month_name']; | 
                                                                                                                                                        
                                                        |  | @@ -1216,7 +1216,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1216 | 1216 |  	* @return Array the hour list | 
                                                                                                            
                                                            | 1217 | 1217 |  	* | 
                                                                                                            
                                                            | 1218 | 1218 |  	*/ | 
                                                                                                            
                                                            | 1219 |  | -	public function countAllHours($orderby,$filters = array()) | 
                                                                                                            
                                                            |  | 1219 | +	public function countAllHours($orderby, $filters = array()) | 
                                                                                                            
                                                            | 1220 | 1220 |  	{ | 
                                                                                                            
                                                            | 1221 | 1221 |  		global $globalTimezone, $globalDBdriver; | 
                                                                                                            
                                                            | 1222 | 1222 |  		if ($globalTimezone != '') { | 
                                                                                                                                                        
                                                        |  | @@ -1264,7 +1264,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 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']; | 
                                                                                                                                                        
                                                        |  | @@ -1286,8 +1286,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1286 | 1286 |  	public function countAllHoursByDate($date, $filters = array()) | 
                                                                                                            
                                                            | 1287 | 1287 |  	{ | 
                                                                                                            
                                                            | 1288 | 1288 |  		global $globalTimezone, $globalDBdriver; | 
                                                                                                            
                                                            | 1289 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            | 1290 |  | -		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1289 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            |  | 1290 | +		$date = filter_var($date, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1291 | 1291 |  		if ($globalTimezone != '') { | 
                                                                                                            
                                                            | 1292 | 1292 |  			date_default_timezone_set($globalTimezone); | 
                                                                                                            
                                                            | 1293 | 1293 |  			$datetime = new DateTime($date); | 
                                                                                                                                                        
                                                        |  | @@ -1295,12 +1295,12 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1295 | 1295 |  		} else $offset = '+00:00'; | 
                                                                                                            
                                                            | 1296 | 1296 |   | 
                                                                                                            
                                                            | 1297 | 1297 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1298 |  | -			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            |  | 1298 | +			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            | 1299 | 1299 |  								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date | 
                                                                                                            
                                                            | 1300 | 1300 |  								GROUP BY hour_name  | 
                                                                                                            
                                                            | 1301 | 1301 |  								ORDER BY hour_name ASC"; | 
                                                                                                            
                                                            | 1302 | 1302 |  		} else { | 
                                                                                                            
                                                            | 1303 |  | -			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            |  | 1303 | +			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            | 1304 | 1304 |  								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date | 
                                                                                                            
                                                            | 1305 | 1305 |  								GROUP BY hour_name  | 
                                                                                                            
                                                            | 1306 | 1306 |  								ORDER BY hour_name ASC"; | 
                                                                                                                                                        
                                                        |  | @@ -1312,7 +1312,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1312 | 1312 |  		$hour_array = array(); | 
                                                                                                            
                                                            | 1313 | 1313 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1314 | 1314 |           | 
                                                                                                            
                                                            | 1315 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1315 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1316 | 1316 |  		{ | 
                                                                                                            
                                                            | 1317 | 1317 |  			$temp_array['hour_name'] = $row['hour_name']; | 
                                                                                                            
                                                            | 1318 | 1318 |  			$temp_array['hour_count'] = $row['hour_count']; | 
                                                                                                                                                        
                                                        |  | @@ -1334,8 +1334,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1334 | 1334 |  	public function countAllHoursByIdent($ident, $filters = array()) | 
                                                                                                            
                                                            | 1335 | 1335 |  	{ | 
                                                                                                            
                                                            | 1336 | 1336 |  		global $globalTimezone, $globalDBdriver; | 
                                                                                                            
                                                            | 1337 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            | 1338 |  | -		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1337 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            |  | 1338 | +		$ident = filter_var($ident, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1339 | 1339 |  		if ($globalTimezone != '') { | 
                                                                                                            
                                                            | 1340 | 1340 |  			date_default_timezone_set($globalTimezone); | 
                                                                                                            
                                                            | 1341 | 1341 |  			$datetime = new DateTime(); | 
                                                                                                                                                        
                                                        |  | @@ -1343,12 +1343,12 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1343 | 1343 |  		} else $offset = '+00:00'; | 
                                                                                                            
                                                            | 1344 | 1344 |   | 
                                                                                                            
                                                            | 1345 | 1345 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1346 |  | -			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            |  | 1346 | +			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            | 1347 | 1347 |  								FROM marine_output".$filter_query." marine_output.ident = :ident  | 
                                                                                                            
                                                            | 1348 | 1348 |  								GROUP BY hour_name  | 
                                                                                                            
                                                            | 1349 | 1349 |  								ORDER BY hour_name ASC"; | 
                                                                                                            
                                                            | 1350 | 1350 |  		} else { | 
                                                                                                            
                                                            | 1351 |  | -			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            |  | 1351 | +			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            | 1352 | 1352 |  								FROM marine_output".$filter_query." marine_output.ident = :ident  | 
                                                                                                            
                                                            | 1353 | 1353 |  								GROUP BY hour_name  | 
                                                                                                            
                                                            | 1354 | 1354 |  								ORDER BY hour_name ASC"; | 
                                                                                                                                                        
                                                        |  | @@ -1356,12 +1356,12 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1356 | 1356 |         | 
                                                                                                            
                                                            | 1357 | 1357 |  		 | 
                                                                                                            
                                                            | 1358 | 1358 |  		$sth = $this->db->prepare($query); | 
                                                                                                            
                                                            | 1359 |  | -		$sth->execute(array(':ident' => $ident,':offset' => $offset)); | 
                                                                                                            
                                                            |  | 1359 | +		$sth->execute(array(':ident' => $ident, ':offset' => $offset)); | 
                                                                                                            
                                                            | 1360 | 1360 |         | 
                                                                                                            
                                                            | 1361 | 1361 |  		$hour_array = array(); | 
                                                                                                            
                                                            | 1362 | 1362 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1363 | 1363 |           | 
                                                                                                            
                                                            | 1364 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1364 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1365 | 1365 |  		{ | 
                                                                                                            
                                                            | 1366 | 1366 |  			$temp_array['hour_name'] = $row['hour_name']; | 
                                                                                                            
                                                            | 1367 | 1367 |  			$temp_array['hour_count'] = $row['hour_count']; | 
                                                                                                                                                        
                                                        |  | @@ -1380,33 +1380,33 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1380 | 1380 |  	* @return Integer the number of vessels | 
                                                                                                            
                                                            | 1381 | 1381 |  	* | 
                                                                                                            
                                                            | 1382 | 1382 |  	*/ | 
                                                                                                            
                                                            | 1383 |  | -	public function countOverallMarine($filters = array(),$year = '',$month = '') | 
                                                                                                            
                                                            |  | 1383 | +	public function countOverallMarine($filters = array(), $year = '', $month = '') | 
                                                                                                            
                                                            | 1384 | 1384 |  	{ | 
                                                                                                            
                                                            | 1385 | 1385 |  		global $globalDBdriver; | 
                                                                                                            
                                                            | 1386 | 1386 |  		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; | 
                                                                                                            
                                                            | 1387 |  | -		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; | 
                                                                                                            
                                                            |  | 1387 | +		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; | 
                                                                                                            
                                                            | 1388 | 1388 |  		$query_values = array(); | 
                                                                                                            
                                                            | 1389 | 1389 |  		$query = ''; | 
                                                                                                            
                                                            | 1390 | 1390 |  		if ($year != '') { | 
                                                                                                            
                                                            | 1391 | 1391 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1392 | 1392 |  				$query .= " AND YEAR(marine_output.date) = :year"; | 
                                                                                                            
                                                            | 1393 |  | -				$query_values = array_merge($query_values,array(':year' => $year)); | 
                                                                                                            
                                                            |  | 1393 | +				$query_values = array_merge($query_values, array(':year' => $year)); | 
                                                                                                            
                                                            | 1394 | 1394 |  			} else { | 
                                                                                                            
                                                            | 1395 | 1395 |  				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; | 
                                                                                                            
                                                            | 1396 |  | -				$query_values = array_merge($query_values,array(':year' => $year)); | 
                                                                                                            
                                                            |  | 1396 | +				$query_values = array_merge($query_values, array(':year' => $year)); | 
                                                                                                            
                                                            | 1397 | 1397 |  			} | 
                                                                                                            
                                                            | 1398 | 1398 |  		} | 
                                                                                                            
                                                            | 1399 | 1399 |  		if ($month != '') { | 
                                                                                                            
                                                            | 1400 | 1400 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1401 | 1401 |  				$query .= " AND MONTH(marine_output.date) = :month"; | 
                                                                                                            
                                                            | 1402 |  | -				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                                                                            
                                                            |  | 1402 | +				$query_values = array_merge($query_values, array(':month' => $month)); | 
                                                                                                            
                                                            | 1403 | 1403 |  			} else { | 
                                                                                                            
                                                            | 1404 | 1404 |  				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; | 
                                                                                                            
                                                            | 1405 |  | -				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                                                                            
                                                            |  | 1405 | +				$query_values = array_merge($query_values, array(':month' => $month)); | 
                                                                                                            
                                                            | 1406 | 1406 |  			} | 
                                                                                                            
                                                            | 1407 | 1407 |  		} | 
                                                                                                            
                                                            | 1408 | 1408 |  		if (empty($query_values)) $queryi .= $this->getFilter($filters); | 
                                                                                                            
                                                            | 1409 |  | -		else $queryi .= $this->getFilter($filters,true,true).substr($query,4); | 
                                                                                                            
                                                            |  | 1409 | +		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); | 
                                                                                                            
                                                            | 1410 | 1410 |  		 | 
                                                                                                            
                                                            | 1411 | 1411 |  		$sth = $this->db->prepare($queryi); | 
                                                                                                            
                                                            | 1412 | 1412 |  		$sth->execute($query_values); | 
                                                                                                                                                        
                                                        |  | @@ -1419,32 +1419,32 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1419 | 1419 |  	* @return Integer the number of vessels | 
                                                                                                            
                                                            | 1420 | 1420 |  	* | 
                                                                                                            
                                                            | 1421 | 1421 |  	*/ | 
                                                                                                            
                                                            | 1422 |  | -	public function countOverallMarineTypes($filters = array(),$year = '',$month = '') | 
                                                                                                            
                                                            |  | 1422 | +	public function countOverallMarineTypes($filters = array(), $year = '', $month = '') | 
                                                                                                            
                                                            | 1423 | 1423 |  	{ | 
                                                                                                            
                                                            | 1424 | 1424 |  		global $globalDBdriver; | 
                                                                                                            
                                                            | 1425 |  | -		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; | 
                                                                                                            
                                                            |  | 1425 | +		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; | 
                                                                                                            
                                                            | 1426 | 1426 |  		$query_values = array(); | 
                                                                                                            
                                                            | 1427 | 1427 |  		$query = ''; | 
                                                                                                            
                                                            | 1428 | 1428 |  		if ($year != '') { | 
                                                                                                            
                                                            | 1429 | 1429 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1430 | 1430 |  				$query .= " AND YEAR(marine_output.date) = :year"; | 
                                                                                                            
                                                            | 1431 |  | -				$query_values = array_merge($query_values,array(':year' => $year)); | 
                                                                                                            
                                                            |  | 1431 | +				$query_values = array_merge($query_values, array(':year' => $year)); | 
                                                                                                            
                                                            | 1432 | 1432 |  			} else { | 
                                                                                                            
                                                            | 1433 | 1433 |  				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; | 
                                                                                                            
                                                            | 1434 |  | -				$query_values = array_merge($query_values,array(':year' => $year)); | 
                                                                                                            
                                                            |  | 1434 | +				$query_values = array_merge($query_values, array(':year' => $year)); | 
                                                                                                            
                                                            | 1435 | 1435 |  			} | 
                                                                                                            
                                                            | 1436 | 1436 |  		} | 
                                                                                                            
                                                            | 1437 | 1437 |  		if ($month != '') { | 
                                                                                                            
                                                            | 1438 | 1438 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1439 | 1439 |  				$query .= " AND MONTH(marine_output.date) = :month"; | 
                                                                                                            
                                                            | 1440 |  | -				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                                                                            
                                                            |  | 1440 | +				$query_values = array_merge($query_values, array(':month' => $month)); | 
                                                                                                            
                                                            | 1441 | 1441 |  			} else { | 
                                                                                                            
                                                            | 1442 | 1442 |  				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; | 
                                                                                                            
                                                            | 1443 |  | -				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                                                                            
                                                            |  | 1443 | +				$query_values = array_merge($query_values, array(':month' => $month)); | 
                                                                                                            
                                                            | 1444 | 1444 |  			} | 
                                                                                                            
                                                            | 1445 | 1445 |  		} | 
                                                                                                            
                                                            | 1446 | 1446 |  		if (empty($query_values)) $queryi .= $this->getFilter($filters); | 
                                                                                                            
                                                            | 1447 |  | -		else $queryi .= $this->getFilter($filters,true,true).substr($query,4); | 
                                                                                                            
                                                            |  | 1447 | +		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); | 
                                                                                                            
                                                            | 1448 | 1448 |  		 | 
                                                                                                            
                                                            | 1449 | 1449 |  		$sth = $this->db->prepare($queryi); | 
                                                                                                            
                                                            | 1450 | 1450 |  		$sth->execute($query_values); | 
                                                                                                                                                        
                                                        |  | @@ -1461,7 +1461,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1461 | 1461 |  	public function countAllHoursFromToday($filters = array()) | 
                                                                                                            
                                                            | 1462 | 1462 |  	{ | 
                                                                                                            
                                                            | 1463 | 1463 |  		global $globalTimezone, $globalDBdriver; | 
                                                                                                            
                                                            | 1464 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            |  | 1464 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            | 1465 | 1465 |  		if ($globalTimezone != '') { | 
                                                                                                            
                                                            | 1466 | 1466 |  			date_default_timezone_set($globalTimezone); | 
                                                                                                            
                                                            | 1467 | 1467 |  			$datetime = new DateTime(); | 
                                                                                                                                                        
                                                        |  | @@ -1469,12 +1469,12 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1469 | 1469 |  		} else $offset = '+00:00'; | 
                                                                                                            
                                                            | 1470 | 1470 |   | 
                                                                                                            
                                                            | 1471 | 1471 |  		if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1472 |  | -			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            |  | 1472 | +			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            | 1473 | 1473 |  								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() | 
                                                                                                            
                                                            | 1474 | 1474 |  								GROUP BY hour_name  | 
                                                                                                            
                                                            | 1475 | 1475 |  								ORDER BY hour_name ASC"; | 
                                                                                                            
                                                            | 1476 | 1476 |  		} else { | 
                                                                                                            
                                                            | 1477 |  | -			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            |  | 1477 | +			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
                                                                                                            
                                                            | 1478 | 1478 |  								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) | 
                                                                                                            
                                                            | 1479 | 1479 |  								GROUP BY hour_name  | 
                                                                                                            
                                                            | 1480 | 1480 |  								ORDER BY hour_name ASC"; | 
                                                                                                                                                        
                                                        |  | @@ -1486,7 +1486,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1486 | 1486 |  		$hour_array = array(); | 
                                                                                                            
                                                            | 1487 | 1487 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1488 | 1488 |           | 
                                                                                                            
                                                            | 1489 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1489 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1490 | 1490 |  		{ | 
                                                                                                            
                                                            | 1491 | 1491 |  			$temp_array['hour_name'] = $row['hour_name']; | 
                                                                                                            
                                                            | 1492 | 1492 |  			$temp_array['hour_count'] = $row['hour_count']; | 
                                                                                                                                                        
                                                        |  | @@ -1505,9 +1505,9 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1505 | 1505 |  	*/ | 
                                                                                                            
                                                            | 1506 | 1506 |  	public function getMarineIDBasedOnFamMarineID($fammarine_id) | 
                                                                                                            
                                                            | 1507 | 1507 |  	{ | 
                                                                                                            
                                                            | 1508 |  | -		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1508 | +		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1509 | 1509 |   | 
                                                                                                            
                                                            | 1510 |  | -		$query  = "SELECT marine_output.marine_id | 
                                                                                                            
                                                            |  | 1510 | +		$query = "SELECT marine_output.marine_id | 
                                                                                                            
                                                            | 1511 | 1511 |  				FROM marine_output  | 
                                                                                                            
                                                            | 1512 | 1512 |  				WHERE marine_output.fammarine_id = '".$fammarine_id."'"; | 
                                                                                                            
                                                            | 1513 | 1513 |           | 
                                                                                                                                                        
                                                        |  | @@ -1515,7 +1515,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1515 | 1515 |  		$sth = $this->db->prepare($query); | 
                                                                                                            
                                                            | 1516 | 1516 |  		$sth->execute(); | 
                                                                                                            
                                                            | 1517 | 1517 |   | 
                                                                                                            
                                                            | 1518 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1518 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1519 | 1519 |  		{ | 
                                                                                                            
                                                            | 1520 | 1520 |  			return $row['marine_id']; | 
                                                                                                            
                                                            | 1521 | 1521 |  		} | 
                                                                                                                                                        
                                                        |  | @@ -1540,23 +1540,23 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1540 | 1540 |  		} | 
                                                                                                            
                                                            | 1541 | 1541 |  		 | 
                                                                                                            
                                                            | 1542 | 1542 |  		$current_date = date("Y-m-d H:i:s"); | 
                                                                                                            
                                                            | 1543 |  | -		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); | 
                                                                                                            
                                                            |  | 1543 | +		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); | 
                                                                                                            
                                                            | 1544 | 1544 |  		 | 
                                                                                                            
                                                            | 1545 | 1545 |  		$diff = abs(strtotime($current_date) - strtotime($date)); | 
                                                                                                            
                                                            | 1546 | 1546 |   | 
                                                                                                            
                                                            | 1547 |  | -		$time_array['years'] = floor($diff / (365*60*60*24));  | 
                                                                                                            
                                                            |  | 1547 | +		$time_array['years'] = floor($diff/(365*60*60*24));  | 
                                                                                                            
                                                            | 1548 | 1548 |  		$years = $time_array['years']; | 
                                                                                                            
                                                            | 1549 | 1549 |  		 | 
                                                                                                            
                                                            | 1550 |  | -		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); | 
                                                                                                            
                                                            |  | 1550 | +		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); | 
                                                                                                            
                                                            | 1551 | 1551 |  		$months = $time_array['months']; | 
                                                                                                            
                                                            | 1552 | 1552 |  		 | 
                                                                                                            
                                                            | 1553 |  | -		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); | 
                                                                                                            
                                                            |  | 1553 | +		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); | 
                                                                                                            
                                                            | 1554 | 1554 |  		$days = $time_array['days']; | 
                                                                                                            
                                                            | 1555 |  | -		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); | 
                                                                                                            
                                                            |  | 1555 | +		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); | 
                                                                                                            
                                                            | 1556 | 1556 |  		$hours = $time_array['hours']; | 
                                                                                                            
                                                            | 1557 |  | -		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); | 
                                                                                                            
                                                            |  | 1557 | +		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); | 
                                                                                                            
                                                            | 1558 | 1558 |  		$minutes = $time_array['minutes']; | 
                                                                                                            
                                                            | 1559 |  | -		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));   | 
                                                                                                            
                                                            |  | 1559 | +		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));   | 
                                                                                                            
                                                            | 1560 | 1560 |  		 | 
                                                                                                            
                                                            | 1561 | 1561 |  		return $time_array; | 
                                                                                                            
                                                            | 1562 | 1562 |  	} | 
                                                                                                                                                        
                                                        |  | @@ -1579,63 +1579,63 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1579 | 1579 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1580 | 1580 |  			$temp_array['direction_shortname'] = "N"; | 
                                                                                                            
                                                            | 1581 | 1581 |  			$temp_array['direction_fullname'] = "North"; | 
                                                                                                            
                                                            | 1582 |  | -		} elseif ($direction >= 22.5 && $direction < 45){ | 
                                                                                                            
                                                            |  | 1582 | +		} elseif ($direction >= 22.5 && $direction < 45) { | 
                                                                                                            
                                                            | 1583 | 1583 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1584 | 1584 |  			$temp_array['direction_shortname'] = "NNE"; | 
                                                                                                            
                                                            | 1585 | 1585 |  			$temp_array['direction_fullname'] = "North-Northeast"; | 
                                                                                                            
                                                            | 1586 |  | -		} elseif ($direction >= 45 && $direction < 67.5){ | 
                                                                                                            
                                                            |  | 1586 | +		} elseif ($direction >= 45 && $direction < 67.5) { | 
                                                                                                            
                                                            | 1587 | 1587 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1588 | 1588 |  			$temp_array['direction_shortname'] = "NE"; | 
                                                                                                            
                                                            | 1589 | 1589 |  			$temp_array['direction_fullname'] = "Northeast"; | 
                                                                                                            
                                                            | 1590 |  | -		} elseif ($direction >= 67.5 && $direction < 90){ | 
                                                                                                            
                                                            |  | 1590 | +		} elseif ($direction >= 67.5 && $direction < 90) { | 
                                                                                                            
                                                            | 1591 | 1591 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1592 | 1592 |  			$temp_array['direction_shortname'] = "ENE"; | 
                                                                                                            
                                                            | 1593 | 1593 |  			$temp_array['direction_fullname'] = "East-Northeast"; | 
                                                                                                            
                                                            | 1594 |  | -		} elseif ($direction >= 90 && $direction < 112.5){ | 
                                                                                                            
                                                            |  | 1594 | +		} elseif ($direction >= 90 && $direction < 112.5) { | 
                                                                                                            
                                                            | 1595 | 1595 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1596 | 1596 |  			$temp_array['direction_shortname'] = "E"; | 
                                                                                                            
                                                            | 1597 | 1597 |  			$temp_array['direction_fullname'] = "East"; | 
                                                                                                            
                                                            | 1598 |  | -		} elseif ($direction >= 112.5 && $direction < 135){ | 
                                                                                                            
                                                            |  | 1598 | +		} elseif ($direction >= 112.5 && $direction < 135) { | 
                                                                                                            
                                                            | 1599 | 1599 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1600 | 1600 |  			$temp_array['direction_shortname'] = "ESE"; | 
                                                                                                            
                                                            | 1601 | 1601 |  			$temp_array['direction_fullname'] = "East-Southeast"; | 
                                                                                                            
                                                            | 1602 |  | -		} elseif ($direction >= 135 && $direction < 157.5){ | 
                                                                                                            
                                                            |  | 1602 | +		} elseif ($direction >= 135 && $direction < 157.5) { | 
                                                                                                            
                                                            | 1603 | 1603 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1604 | 1604 |  			$temp_array['direction_shortname'] = "SE"; | 
                                                                                                            
                                                            | 1605 | 1605 |  			$temp_array['direction_fullname'] = "Southeast"; | 
                                                                                                            
                                                            | 1606 |  | -		} elseif ($direction >= 157.5 && $direction < 180){ | 
                                                                                                            
                                                            |  | 1606 | +		} elseif ($direction >= 157.5 && $direction < 180) { | 
                                                                                                            
                                                            | 1607 | 1607 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1608 | 1608 |  			$temp_array['direction_shortname'] = "SSE"; | 
                                                                                                            
                                                            | 1609 | 1609 |  			$temp_array['direction_fullname'] = "South-Southeast"; | 
                                                                                                            
                                                            | 1610 |  | -		} elseif ($direction >= 180 && $direction < 202.5){ | 
                                                                                                            
                                                            |  | 1610 | +		} elseif ($direction >= 180 && $direction < 202.5) { | 
                                                                                                            
                                                            | 1611 | 1611 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1612 | 1612 |  			$temp_array['direction_shortname'] = "S"; | 
                                                                                                            
                                                            | 1613 | 1613 |  			$temp_array['direction_fullname'] = "South"; | 
                                                                                                            
                                                            | 1614 |  | -		} elseif ($direction >= 202.5 && $direction < 225){ | 
                                                                                                            
                                                            |  | 1614 | +		} elseif ($direction >= 202.5 && $direction < 225) { | 
                                                                                                            
                                                            | 1615 | 1615 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1616 | 1616 |  			$temp_array['direction_shortname'] = "SSW"; | 
                                                                                                            
                                                            | 1617 | 1617 |  			$temp_array['direction_fullname'] = "South-Southwest"; | 
                                                                                                            
                                                            | 1618 |  | -		} elseif ($direction >= 225 && $direction < 247.5){ | 
                                                                                                            
                                                            |  | 1618 | +		} elseif ($direction >= 225 && $direction < 247.5) { | 
                                                                                                            
                                                            | 1619 | 1619 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1620 | 1620 |  			$temp_array['direction_shortname'] = "SW"; | 
                                                                                                            
                                                            | 1621 | 1621 |  			$temp_array['direction_fullname'] = "Southwest"; | 
                                                                                                            
                                                            | 1622 |  | -		} elseif ($direction >= 247.5 && $direction < 270){ | 
                                                                                                            
                                                            |  | 1622 | +		} elseif ($direction >= 247.5 && $direction < 270) { | 
                                                                                                            
                                                            | 1623 | 1623 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1624 | 1624 |  			$temp_array['direction_shortname'] = "WSW"; | 
                                                                                                            
                                                            | 1625 | 1625 |  			$temp_array['direction_fullname'] = "West-Southwest"; | 
                                                                                                            
                                                            | 1626 |  | -		} elseif ($direction >= 270 && $direction < 292.5){ | 
                                                                                                            
                                                            |  | 1626 | +		} elseif ($direction >= 270 && $direction < 292.5) { | 
                                                                                                            
                                                            | 1627 | 1627 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1628 | 1628 |  			$temp_array['direction_shortname'] = "W"; | 
                                                                                                            
                                                            | 1629 | 1629 |  			$temp_array['direction_fullname'] = "West"; | 
                                                                                                            
                                                            | 1630 |  | -		} elseif ($direction >= 292.5 && $direction < 315){ | 
                                                                                                            
                                                            |  | 1630 | +		} elseif ($direction >= 292.5 && $direction < 315) { | 
                                                                                                            
                                                            | 1631 | 1631 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1632 | 1632 |  			$temp_array['direction_shortname'] = "WNW"; | 
                                                                                                            
                                                            | 1633 | 1633 |  			$temp_array['direction_fullname'] = "West-Northwest"; | 
                                                                                                            
                                                            | 1634 |  | -		} elseif ($direction >= 315 && $direction < 337.5){ | 
                                                                                                            
                                                            |  | 1634 | +		} elseif ($direction >= 315 && $direction < 337.5) { | 
                                                                                                            
                                                            | 1635 | 1635 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1636 | 1636 |  			$temp_array['direction_shortname'] = "NW"; | 
                                                                                                            
                                                            | 1637 | 1637 |  			$temp_array['direction_fullname'] = "Northwest"; | 
                                                                                                            
                                                            | 1638 |  | -		} elseif ($direction >= 337.5 && $direction < 360){ | 
                                                                                                            
                                                            |  | 1638 | +		} elseif ($direction >= 337.5 && $direction < 360) { | 
                                                                                                            
                                                            | 1639 | 1639 |  			$temp_array['direction_degree'] = $direction; | 
                                                                                                            
                                                            | 1640 | 1640 |  			$temp_array['direction_shortname'] = "NNW"; | 
                                                                                                            
                                                            | 1641 | 1641 |  			$temp_array['direction_fullname'] = "North-Northwest"; | 
                                                                                                                                                        
                                                        |  | @@ -1652,11 +1652,11 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1652 | 1652 |  	* @param Float $longitude longitute of the flight | 
                                                                                                            
                                                            | 1653 | 1653 |  	* @return String the countrie | 
                                                                                                            
                                                            | 1654 | 1654 |  	*/ | 
                                                                                                            
                                                            | 1655 |  | -	public function getCountryFromLatitudeLongitude($latitude,$longitude) | 
                                                                                                            
                                                            |  | 1655 | +	public function getCountryFromLatitudeLongitude($latitude, $longitude) | 
                                                                                                            
                                                            | 1656 | 1656 |  	{ | 
                                                                                                            
                                                            | 1657 | 1657 |  		global $globalDBdriver, $globalDebug; | 
                                                                                                            
                                                            | 1658 |  | -		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            | 1659 |  | -		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            |  | 1658 | +		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            |  | 1659 | +		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); | 
                                                                                                            
                                                            | 1660 | 1660 |  	 | 
                                                                                                            
                                                            | 1661 | 1661 |  		$Connection = new Connection($this->db); | 
                                                                                                            
                                                            | 1662 | 1662 |  		if (!$Connection->tableExists('countries')) return ''; | 
                                                                                                                                                        
                                                        |  | @@ -1696,7 +1696,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1696 | 1696 |  	public function getCountryFromISO2($iso2) | 
                                                                                                            
                                                            | 1697 | 1697 |  	{ | 
                                                                                                            
                                                            | 1698 | 1698 |  		global $globalDBdriver, $globalDebug; | 
                                                                                                            
                                                            | 1699 |  | -		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1699 | +		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1700 | 1700 |  	 | 
                                                                                                            
                                                            | 1701 | 1701 |  		$Connection = new Connection($this->db); | 
                                                                                                            
                                                            | 1702 | 1702 |  		if (!$Connection->tableExists('countries')) return ''; | 
                                                                                                                                                        
                                                        |  | @@ -1744,7 +1744,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1744 | 1744 |  		 | 
                                                                                                            
                                                            | 1745 | 1745 |  		$bitly_data = json_decode($bitly_data); | 
                                                                                                            
                                                            | 1746 | 1746 |  		$bitly_url = ''; | 
                                                                                                            
                                                            | 1747 |  | -		if ($bitly_data->status_txt = "OK"){ | 
                                                                                                            
                                                            |  | 1747 | +		if ($bitly_data->status_txt = "OK") { | 
                                                                                                            
                                                            | 1748 | 1748 |  			$bitly_url = $bitly_data->data->url; | 
                                                                                                            
                                                            | 1749 | 1749 |  		} | 
                                                                                                            
                                                            | 1750 | 1750 |   | 
                                                                                                                                                        
                                                        |  | @@ -1758,11 +1758,11 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1758 | 1758 |  	* @return Array the vessel type list | 
                                                                                                            
                                                            | 1759 | 1759 |  	* | 
                                                                                                            
                                                            | 1760 | 1760 |  	*/ | 
                                                                                                            
                                                            | 1761 |  | -	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') | 
                                                                                                            
                                                            |  | 1761 | +	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') | 
                                                                                                            
                                                            | 1762 | 1762 |  	{ | 
                                                                                                            
                                                            | 1763 | 1763 |  		global $globalDBdriver; | 
                                                                                                            
                                                            | 1764 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            | 1765 |  | -		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count  | 
                                                                                                            
                                                            |  | 1764 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            |  | 1765 | +		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count  | 
                                                                                                            
                                                            | 1766 | 1766 |  		    FROM marine_output ".$filter_query." marine_output.type  <> ''"; | 
                                                                                                            
                                                            | 1767 | 1767 |  		if ($olderthanmonths > 0) { | 
                                                                                                            
                                                            | 1768 | 1768 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                                                                        
                                                        |  | @@ -1782,28 +1782,28 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1782 | 1782 |  		if ($year != '') { | 
                                                                                                            
                                                            | 1783 | 1783 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1784 | 1784 |  				$query .= " AND YEAR(marine_output.date) = :year"; | 
                                                                                                            
                                                            | 1785 |  | -				$query_values = array_merge($query_values,array(':year' => $year)); | 
                                                                                                            
                                                            |  | 1785 | +				$query_values = array_merge($query_values, array(':year' => $year)); | 
                                                                                                            
                                                            | 1786 | 1786 |  			} else { | 
                                                                                                            
                                                            | 1787 | 1787 |  				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; | 
                                                                                                            
                                                            | 1788 |  | -				$query_values = array_merge($query_values,array(':year' => $year)); | 
                                                                                                            
                                                            |  | 1788 | +				$query_values = array_merge($query_values, array(':year' => $year)); | 
                                                                                                            
                                                            | 1789 | 1789 |  			} | 
                                                                                                            
                                                            | 1790 | 1790 |  		} | 
                                                                                                            
                                                            | 1791 | 1791 |  		if ($month != '') { | 
                                                                                                            
                                                            | 1792 | 1792 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1793 | 1793 |  				$query .= " AND MONTH(marine_output.date) = :month"; | 
                                                                                                            
                                                            | 1794 |  | -				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                                                                            
                                                            |  | 1794 | +				$query_values = array_merge($query_values, array(':month' => $month)); | 
                                                                                                            
                                                            | 1795 | 1795 |  			} else { | 
                                                                                                            
                                                            | 1796 | 1796 |  				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; | 
                                                                                                            
                                                            | 1797 |  | -				$query_values = array_merge($query_values,array(':month' => $month)); | 
                                                                                                            
                                                            |  | 1797 | +				$query_values = array_merge($query_values, array(':month' => $month)); | 
                                                                                                            
                                                            | 1798 | 1798 |  			} | 
                                                                                                            
                                                            | 1799 | 1799 |  		} | 
                                                                                                            
                                                            | 1800 | 1800 |  		if ($day != '') { | 
                                                                                                            
                                                            | 1801 | 1801 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1802 | 1802 |  				$query .= " AND DAY(marine_output.date) = :day"; | 
                                                                                                            
                                                            | 1803 |  | -				$query_values = array_merge($query_values,array(':day' => $day)); | 
                                                                                                            
                                                            |  | 1803 | +				$query_values = array_merge($query_values, array(':day' => $day)); | 
                                                                                                            
                                                            | 1804 | 1804 |  			} else { | 
                                                                                                            
                                                            | 1805 | 1805 |  				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; | 
                                                                                                            
                                                            | 1806 |  | -				$query_values = array_merge($query_values,array(':day' => $day)); | 
                                                                                                            
                                                            |  | 1806 | +				$query_values = array_merge($query_values, array(':day' => $day)); | 
                                                                                                            
                                                            | 1807 | 1807 |  			} | 
                                                                                                            
                                                            | 1808 | 1808 |  		} | 
                                                                                                            
                                                            | 1809 | 1809 |  		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; | 
                                                                                                                                                        
                                                        |  | @@ -1812,7 +1812,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1812 | 1812 |  		$sth->execute($query_values); | 
                                                                                                            
                                                            | 1813 | 1813 |  		$marine_array = array(); | 
                                                                                                            
                                                            | 1814 | 1814 |  		$temp_array = array(); | 
                                                                                                            
                                                            | 1815 |  | -		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            |  | 1815 | +		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
                                                                                                            
                                                            | 1816 | 1816 |  		{ | 
                                                                                                            
                                                            | 1817 | 1817 |  			$temp_array['marine_type'] = $row['marine_type']; | 
                                                                                                            
                                                            | 1818 | 1818 |  			$temp_array['marine_type_count'] = $row['marine_type_count']; | 
                                                                                                                                                        
                                                        |  | @@ -1827,13 +1827,13 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1827 | 1827 |  	* @return Array the tracker information | 
                                                                                                            
                                                            | 1828 | 1828 |  	* | 
                                                                                                            
                                                            | 1829 | 1829 |  	*/ | 
                                                                                                            
                                                            | 1830 |  | -	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) | 
                                                                                                            
                                                            |  | 1830 | +	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) | 
                                                                                                            
                                                            | 1831 | 1831 |  	{ | 
                                                                                                            
                                                            | 1832 | 1832 |  		global $globalTimezone, $globalDBdriver; | 
                                                                                                            
                                                            | 1833 | 1833 |  		date_default_timezone_set('UTC'); | 
                                                                                                            
                                                            | 1834 | 1834 |  		$query_values = array(); | 
                                                                                                            
                                                            | 1835 | 1835 |  		$additional_query = ''; | 
                                                                                                            
                                                            | 1836 |  | -		$filter_query = $this->getFilter($filters,true,true); | 
                                                                                                            
                                                            |  | 1836 | +		$filter_query = $this->getFilter($filters, true, true); | 
                                                                                                            
                                                            | 1837 | 1837 |  		if ($q != "") | 
                                                                                                            
                                                            | 1838 | 1838 |  		{ | 
                                                                                                            
                                                            | 1839 | 1839 |  			if (!is_string($q)) | 
                                                                                                                                                        
                                                        |  | @@ -1841,8 +1841,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1841 | 1841 |  				return false; | 
                                                                                                            
                                                            | 1842 | 1842 |  			} else { | 
                                                                                                            
                                                            | 1843 | 1843 |  				$q_array = explode(" ", $q); | 
                                                                                                            
                                                            | 1844 |  | -				foreach ($q_array as $q_item){ | 
                                                                                                            
                                                            | 1845 |  | -					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1844 | +				foreach ($q_array as $q_item) { | 
                                                                                                            
                                                            |  | 1845 | +					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1846 | 1846 |  					$additional_query .= " AND ("; | 
                                                                                                            
                                                            | 1847 | 1847 |  					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; | 
                                                                                                            
                                                            | 1848 | 1848 |  					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; | 
                                                                                                                                                        
                                                        |  | @@ -1854,42 +1854,42 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1854 | 1854 |  		} | 
                                                                                                            
                                                            | 1855 | 1855 |  		if ($callsign != "") | 
                                                                                                            
                                                            | 1856 | 1856 |  		{ | 
                                                                                                            
                                                            | 1857 |  | -			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1857 | +			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1858 | 1858 |  			if (!is_string($callsign)) | 
                                                                                                            
                                                            | 1859 | 1859 |  			{ | 
                                                                                                            
                                                            | 1860 | 1860 |  				return false; | 
                                                                                                            
                                                            | 1861 | 1861 |  			} else { | 
                                                                                                            
                                                            | 1862 | 1862 |  				$additional_query .= " AND marine_output.ident = :callsign"; | 
                                                                                                            
                                                            | 1863 |  | -				$query_values = array_merge($query_values,array(':callsign' => $callsign)); | 
                                                                                                            
                                                            |  | 1863 | +				$query_values = array_merge($query_values, array(':callsign' => $callsign)); | 
                                                                                                            
                                                            | 1864 | 1864 |  			} | 
                                                                                                            
                                                            | 1865 | 1865 |  		} | 
                                                                                                            
                                                            | 1866 | 1866 |  		if ($mmsi != "") | 
                                                                                                            
                                                            | 1867 | 1867 |  		{ | 
                                                                                                            
                                                            | 1868 |  | -			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1868 | +			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1869 | 1869 |  			if (!is_numeric($mmsi)) | 
                                                                                                            
                                                            | 1870 | 1870 |  			{ | 
                                                                                                            
                                                            | 1871 | 1871 |  				return false; | 
                                                                                                            
                                                            | 1872 | 1872 |  			} else { | 
                                                                                                            
                                                            | 1873 | 1873 |  				$additional_query .= " AND marine_output.mmsi = :mmsi"; | 
                                                                                                            
                                                            | 1874 |  | -				$query_values = array_merge($query_values,array(':mmsi' => $mmsi)); | 
                                                                                                            
                                                            |  | 1874 | +				$query_values = array_merge($query_values, array(':mmsi' => $mmsi)); | 
                                                                                                            
                                                            | 1875 | 1875 |  			} | 
                                                                                                            
                                                            | 1876 | 1876 |  		} | 
                                                                                                            
                                                            | 1877 | 1877 |  		if ($imo != "") | 
                                                                                                            
                                                            | 1878 | 1878 |  		{ | 
                                                                                                            
                                                            | 1879 |  | -			$imo = filter_var($imo,FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1879 | +			$imo = filter_var($imo, FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1880 | 1880 |  			if (!is_numeric($imo)) | 
                                                                                                            
                                                            | 1881 | 1881 |  			{ | 
                                                                                                            
                                                            | 1882 | 1882 |  				return false; | 
                                                                                                            
                                                            | 1883 | 1883 |  			} else { | 
                                                                                                            
                                                            | 1884 | 1884 |  				$additional_query .= " AND marine_output.imo = :imo"; | 
                                                                                                            
                                                            | 1885 |  | -				$query_values = array_merge($query_values,array(':imo' => $imo)); | 
                                                                                                            
                                                            |  | 1885 | +				$query_values = array_merge($query_values, array(':imo' => $imo)); | 
                                                                                                            
                                                            | 1886 | 1886 |  			} | 
                                                                                                            
                                                            | 1887 | 1887 |  		} | 
                                                                                                            
                                                            | 1888 | 1888 |  		if ($date_posted != "") | 
                                                                                                            
                                                            | 1889 | 1889 |  		{ | 
                                                                                                            
                                                            | 1890 | 1890 |  			$date_array = explode(",", $date_posted); | 
                                                                                                            
                                                            | 1891 |  | -			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1892 |  | -			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1891 | +			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            |  | 1892 | +			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); | 
                                                                                                            
                                                            | 1893 | 1893 |  			if ($globalTimezone != '') { | 
                                                                                                            
                                                            | 1894 | 1894 |  				date_default_timezone_set($globalTimezone); | 
                                                                                                            
                                                            | 1895 | 1895 |  				$datetime = new DateTime(); | 
                                                                                                                                                        
                                                        |  | @@ -1916,8 +1916,8 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1916 | 1916 |  		if ($limit != "") | 
                                                                                                            
                                                            | 1917 | 1917 |  		{ | 
                                                                                                            
                                                            | 1918 | 1918 |  			$limit_array = explode(",", $limit); | 
                                                                                                            
                                                            | 1919 |  | -			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 1920 |  | -			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 1919 | +			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            |  | 1920 | +			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); | 
                                                                                                            
                                                            | 1921 | 1921 |  			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
                                                                                                            
                                                            | 1922 | 1922 |  			{ | 
                                                                                                            
                                                            | 1923 | 1923 |  				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
                                                                                                                                                        
                                                        |  | @@ -1935,28 +1935,28 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 1935 | 1935 |  			} | 
                                                                                                            
                                                            | 1936 | 1936 |  		} | 
                                                                                                            
                                                            | 1937 | 1937 |  		if ($origLat != "" && $origLon != "" && $dist != "") { | 
                                                                                                            
                                                            | 1938 |  | -			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile | 
                                                                                                            
                                                            |  | 1938 | +			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile | 
                                                                                                            
                                                            | 1939 | 1939 |  			if ($globalDBdriver == 'mysql') { | 
                                                                                                            
                                                            | 1940 |  | -				$query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance  | 
                                                                                                            
                                                            |  | 1940 | +				$query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance  | 
                                                                                                            
                                                            | 1941 | 1941 |  				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
                                                                                                            
                                                            | 1942 | 1942 |  				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; | 
                                                                                                            
                                                            | 1943 | 1943 |  			} else { | 
                                                                                                            
                                                            | 1944 |  | -				$query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance  | 
                                                                                                            
                                                            |  | 1944 | +				$query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance  | 
                                                                                                            
                                                            | 1945 | 1945 |  				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
                                                                                                            
                                                            | 1946 | 1946 |  				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; | 
                                                                                                            
                                                            | 1947 | 1947 |  			} | 
                                                                                                            
                                                            | 1948 | 1948 |  		} else { | 
                                                                                                            
                                                            | 1949 |  | -			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> ''  | 
                                                                                                            
                                                            |  | 1949 | +			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> ''  | 
                                                                                                            
                                                            | 1950 | 1950 |  			    ".$additional_query." | 
                                                                                                            
                                                            | 1951 | 1951 |  			    ".$orderby_query; | 
                                                                                                            
                                                            | 1952 | 1952 |  		} | 
                                                                                                            
                                                            | 1953 |  | -		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query); | 
                                                                                                            
                                                            |  | 1953 | +		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
                                                                                                            
                                                            | 1954 | 1954 |  		return $marine_array; | 
                                                                                                            
                                                            | 1955 | 1955 |  	} | 
                                                                                                            
                                                            | 1956 | 1956 |   | 
                                                                                                            
                                                            | 1957 | 1957 |  	public function getOrderBy() | 
                                                                                                            
                                                            | 1958 | 1958 |  	{ | 
                                                                                                            
                                                            | 1959 |  | -		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type 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")); | 
                                                                                                            
                                                            |  | 1959 | +		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type 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")); | 
                                                                                                            
                                                            | 1960 | 1960 |  		 | 
                                                                                                            
                                                            | 1961 | 1961 |  		return $orderby; | 
                                                                                                            
                                                            | 1962 | 1962 |  		 |