@@ -14,7 +14,7 @@  | 
                                                    ||
| 14 | 14 | /**  | 
                                                        
| 15 | 15 | * Get SQL query part for filter used  | 
                                                        
| 16 | 16 | * @param Array $filter the filter  | 
                                                        
| 17 | - * @return Array the SQL part  | 
                                                        |
| 17 | + * @return string the SQL part  | 
                                                        |
| 18 | 18 | */  | 
                                                        
| 19 | 19 |  	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
@@ -9,10 +9,10 @@ discard block  | 
                                                    ||
| 9 | 9 | }  | 
                                                        
| 10 | 10 | |
| 11 | 11 | /**  | 
                                                        
| 12 | - * Get SQL query part for filter used  | 
                                                        |
| 13 | - * @param Array $filter the filter  | 
                                                        |
| 14 | - * @return Array the SQL part  | 
                                                        |
| 15 | - */  | 
                                                        |
| 12 | + * Get SQL query part for filter used  | 
                                                        |
| 13 | + * @param Array $filter the filter  | 
                                                        |
| 14 | + * @return Array the SQL part  | 
                                                        |
| 15 | + */  | 
                                                        |
| 16 | 16 |  	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        
| 17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
| 18 | 18 | $filters = array();  | 
                                                        
@@ -110,44 +110,44 @@ discard block  | 
                                                    ||
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |
| 112 | 112 | |
| 113 | - /**  | 
                                                        |
| 114 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 115 | - *  | 
                                                        |
| 116 | - * @return Array the spotter information  | 
                                                        |
| 117 | - *  | 
                                                        |
| 118 | - */  | 
                                                        |
| 119 | - public function getLastArchiveMarineDataByIdent($ident)  | 
                                                        |
| 120 | -        { | 
                                                        |
| 113 | + /**  | 
                                                        |
| 114 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 115 | + *  | 
                                                        |
| 116 | + * @return Array the spotter information  | 
                                                        |
| 117 | + *  | 
                                                        |
| 118 | + */  | 
                                                        |
| 119 | + public function getLastArchiveMarineDataByIdent($ident)  | 
                                                        |
| 120 | +		{ | 
                                                        |
| 121 | 121 | $Marine = new Marine($this->db);  | 
                                                        
| 122 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 122 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 123 | 123 | |
| 124 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 125 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 124 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 125 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 127 | 127 | |
| 128 | -                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); | 
                                                        |
| 128 | +				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); | 
                                                        |
| 129 | 129 | |
| 130 | - return $spotter_array;  | 
                                                        |
| 131 | - }  | 
                                                        |
| 130 | + return $spotter_array;  | 
                                                        |
| 131 | + }  | 
                                                        |
| 132 | 132 | |
| 133 | 133 | |
| 134 | - /**  | 
                                                        |
| 135 | - * Gets last the spotter information based on a particular id  | 
                                                        |
| 136 | - *  | 
                                                        |
| 137 | - * @return Array the spotter information  | 
                                                        |
| 138 | - *  | 
                                                        |
| 139 | - */  | 
                                                        |
| 140 | - public function getLastArchiveMarineDataById($id)  | 
                                                        |
| 141 | -        { | 
                                                        |
| 142 | - $Marine = new Marine($this->db);  | 
                                                        |
| 143 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 144 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 145 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 146 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 134 | + /**  | 
                                                        |
| 135 | + * Gets last the spotter information based on a particular id  | 
                                                        |
| 136 | + *  | 
                                                        |
| 137 | + * @return Array the spotter information  | 
                                                        |
| 138 | + *  | 
                                                        |
| 139 | + */  | 
                                                        |
| 140 | + public function getLastArchiveMarineDataById($id)  | 
                                                        |
| 141 | +		{ | 
                                                        |
| 142 | + $Marine = new Marine($this->db);  | 
                                                        |
| 143 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 144 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 145 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 146 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 148 | 148 | |
| 149 | 149 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 150 | - /*  | 
                                                        |
| 150 | + /*  | 
                                                        |
| 151 | 151 |                  try { | 
                                                        
| 152 | 152 | $Connection = new Connection();  | 
                                                        
| 153 | 153 | $sth = Connection->$db->prepare($query);  | 
                                                        
@@ -157,232 +157,232 @@ discard block  | 
                                                    ||
| 157 | 157 | }  | 
                                                        
| 158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);  | 
                                                        
| 159 | 159 | */  | 
                                                        
| 160 | -                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        |
| 161 | -  | 
                                                        |
| 162 | - return $spotter_array;  | 
                                                        |
| 163 | - }  | 
                                                        |
| 164 | -  | 
                                                        |
| 165 | - /**  | 
                                                        |
| 166 | - * Gets all the spotter information based on a particular id  | 
                                                        |
| 167 | - *  | 
                                                        |
| 168 | - * @return Array the spotter information  | 
                                                        |
| 169 | - *  | 
                                                        |
| 170 | - */  | 
                                                        |
| 171 | - public function getAllArchiveMarineDataById($id)  | 
                                                        |
| 160 | +				$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        |
| 161 | +  | 
                                                        |
| 162 | + return $spotter_array;  | 
                                                        |
| 163 | + }  | 
                                                        |
| 164 | +  | 
                                                        |
| 165 | + /**  | 
                                                        |
| 166 | + * Gets all the spotter information based on a particular id  | 
                                                        |
| 167 | + *  | 
                                                        |
| 168 | + * @return Array the spotter information  | 
                                                        |
| 169 | + *  | 
                                                        |
| 170 | + */  | 
                                                        |
| 171 | + public function getAllArchiveMarineDataById($id)  | 
                                                        |
| 172 | 172 |  	{ | 
                                                        
| 173 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 174 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 173 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 174 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 176 | 176 | |
| 177 | 177 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 178 | 178 | |
| 179 | -                try { | 
                                                        |
| 180 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 181 | -                        $sth->execute(array(':id' => $id)); | 
                                                        |
| 182 | -                } catch(PDOException $e) { | 
                                                        |
| 183 | - echo $e->getMessage();  | 
                                                        |
| 184 | - die;  | 
                                                        |
| 185 | - }  | 
                                                        |
| 186 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 187 | -  | 
                                                        |
| 188 | - return $spotter_array;  | 
                                                        |
| 189 | - }  | 
                                                        |
| 190 | -  | 
                                                        |
| 191 | - /**  | 
                                                        |
| 192 | - * Gets coordinate & time spotter information based on a particular id  | 
                                                        |
| 193 | - *  | 
                                                        |
| 194 | - * @return Array the spotter information  | 
                                                        |
| 195 | - *  | 
                                                        |
| 196 | - */  | 
                                                        |
| 197 | - public function getCoordArchiveMarineDataById($id)  | 
                                                        |
| 198 | -        { | 
                                                        |
| 199 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 200 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 179 | +				try { | 
                                                        |
| 180 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 181 | +						$sth->execute(array(':id' => $id)); | 
                                                        |
| 182 | +				} catch(PDOException $e) { | 
                                                        |
| 183 | + echo $e->getMessage();  | 
                                                        |
| 184 | + die;  | 
                                                        |
| 185 | + }  | 
                                                        |
| 186 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 187 | +  | 
                                                        |
| 188 | + return $spotter_array;  | 
                                                        |
| 189 | + }  | 
                                                        |
| 190 | +  | 
                                                        |
| 191 | + /**  | 
                                                        |
| 192 | + * Gets coordinate & time spotter information based on a particular id  | 
                                                        |
| 193 | + *  | 
                                                        |
| 194 | + * @return Array the spotter information  | 
                                                        |
| 195 | + *  | 
                                                        |
| 196 | + */  | 
                                                        |
| 197 | + public function getCoordArchiveMarineDataById($id)  | 
                                                        |
| 198 | +		{ | 
                                                        |
| 199 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 200 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 202 | 202 | |
| 203 | 203 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 204 | 204 | |
| 205 | -                try { | 
                                                        |
| 206 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 207 | -                        $sth->execute(array(':id' => $id)); | 
                                                        |
| 208 | -                } catch(PDOException $e) { | 
                                                        |
| 209 | - echo $e->getMessage();  | 
                                                        |
| 210 | - die;  | 
                                                        |
| 211 | - }  | 
                                                        |
| 212 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 205 | +				try { | 
                                                        |
| 206 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 207 | +						$sth->execute(array(':id' => $id)); | 
                                                        |
| 208 | +				} catch(PDOException $e) { | 
                                                        |
| 209 | + echo $e->getMessage();  | 
                                                        |
| 210 | + die;  | 
                                                        |
| 211 | + }  | 
                                                        |
| 212 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 213 | 213 | |
| 214 | - return $spotter_array;  | 
                                                        |
| 215 | - }  | 
                                                        |
| 214 | + return $spotter_array;  | 
                                                        |
| 215 | + }  | 
                                                        |
| 216 | 216 | |
| 217 | 217 | |
| 218 | - /**  | 
                                                        |
| 219 | - * Gets altitude information based on a particular callsign  | 
                                                        |
| 220 | - *  | 
                                                        |
| 221 | - * @return Array the spotter information  | 
                                                        |
| 222 | - *  | 
                                                        |
| 223 | - */  | 
                                                        |
| 224 | - public function getAltitudeArchiveMarineDataByIdent($ident)  | 
                                                        |
| 225 | -        { | 
                                                        |
| 218 | + /**  | 
                                                        |
| 219 | + * Gets altitude information based on a particular callsign  | 
                                                        |
| 220 | + *  | 
                                                        |
| 221 | + * @return Array the spotter information  | 
                                                        |
| 222 | + *  | 
                                                        |
| 223 | + */  | 
                                                        |
| 224 | + public function getAltitudeArchiveMarineDataByIdent($ident)  | 
                                                        |
| 225 | +		{ | 
                                                        |
| 226 | 226 | |
| 227 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 227 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 228 | 228 | |
| 229 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 229 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 231 | 231 | |
| 232 | -                try { | 
                                                        |
| 233 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 234 | -                        $sth->execute(array(':ident' => $ident)); | 
                                                        |
| 235 | -                } catch(PDOException $e) { | 
                                                        |
| 236 | - echo $e->getMessage();  | 
                                                        |
| 237 | - die;  | 
                                                        |
| 238 | - }  | 
                                                        |
| 239 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 232 | +				try { | 
                                                        |
| 233 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 234 | +						$sth->execute(array(':ident' => $ident)); | 
                                                        |
| 235 | +				} catch(PDOException $e) { | 
                                                        |
| 236 | + echo $e->getMessage();  | 
                                                        |
| 237 | + die;  | 
                                                        |
| 238 | + }  | 
                                                        |
| 239 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 240 | 240 | |
| 241 | - return $spotter_array;  | 
                                                        |
| 242 | - }  | 
                                                        |
| 241 | + return $spotter_array;  | 
                                                        |
| 242 | + }  | 
                                                        |
| 243 | 243 | |
| 244 | - /**  | 
                                                        |
| 245 | - * Gets altitude information based on a particular id  | 
                                                        |
| 246 | - *  | 
                                                        |
| 247 | - * @return Array the spotter information  | 
                                                        |
| 248 | - *  | 
                                                        |
| 249 | - */  | 
                                                        |
| 250 | - public function getAltitudeArchiveMarineDataById($id)  | 
                                                        |
| 251 | -        { | 
                                                        |
| 244 | + /**  | 
                                                        |
| 245 | + * Gets altitude information based on a particular id  | 
                                                        |
| 246 | + *  | 
                                                        |
| 247 | + * @return Array the spotter information  | 
                                                        |
| 248 | + *  | 
                                                        |
| 249 | + */  | 
                                                        |
| 250 | + public function getAltitudeArchiveMarineDataById($id)  | 
                                                        |
| 251 | +		{ | 
                                                        |
| 252 | 252 | |
| 253 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 253 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 254 | 254 | |
| 255 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 255 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 257 | 257 | |
| 258 | -                try { | 
                                                        |
| 259 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 260 | -                        $sth->execute(array(':id' => $id)); | 
                                                        |
| 261 | -                } catch(PDOException $e) { | 
                                                        |
| 262 | - echo $e->getMessage();  | 
                                                        |
| 263 | - die;  | 
                                                        |
| 264 | - }  | 
                                                        |
| 265 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 258 | +				try { | 
                                                        |
| 259 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 260 | +						$sth->execute(array(':id' => $id)); | 
                                                        |
| 261 | +				} catch(PDOException $e) { | 
                                                        |
| 262 | + echo $e->getMessage();  | 
                                                        |
| 263 | + die;  | 
                                                        |
| 264 | + }  | 
                                                        |
| 265 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 266 | 266 | |
| 267 | - return $spotter_array;  | 
                                                        |
| 268 | - }  | 
                                                        |
| 267 | + return $spotter_array;  | 
                                                        |
| 268 | + }  | 
                                                        |
| 269 | 269 | |
| 270 | - /**  | 
                                                        |
| 271 | - * Gets altitude & speed information based on a particular id  | 
                                                        |
| 272 | - *  | 
                                                        |
| 273 | - * @return Array the spotter information  | 
                                                        |
| 274 | - *  | 
                                                        |
| 275 | - */  | 
                                                        |
| 276 | - public function getAltitudeSpeedArchiveMarineDataById($id)  | 
                                                        |
| 277 | -        { | 
                                                        |
| 270 | + /**  | 
                                                        |
| 271 | + * Gets altitude & speed information based on a particular id  | 
                                                        |
| 272 | + *  | 
                                                        |
| 273 | + * @return Array the spotter information  | 
                                                        |
| 274 | + *  | 
                                                        |
| 275 | + */  | 
                                                        |
| 276 | + public function getAltitudeSpeedArchiveMarineDataById($id)  | 
                                                        |
| 277 | +		{ | 
                                                        |
| 278 | 278 | |
| 279 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 279 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 280 | 280 | |
| 281 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 281 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 283 | 283 | |
| 284 | -                try { | 
                                                        |
| 285 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 286 | -                        $sth->execute(array(':id' => $id)); | 
                                                        |
| 287 | -                } catch(PDOException $e) { | 
                                                        |
| 288 | - echo $e->getMessage();  | 
                                                        |
| 289 | - die;  | 
                                                        |
| 290 | - }  | 
                                                        |
| 291 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 284 | +				try { | 
                                                        |
| 285 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 286 | +						$sth->execute(array(':id' => $id)); | 
                                                        |
| 287 | +				} catch(PDOException $e) { | 
                                                        |
| 288 | + echo $e->getMessage();  | 
                                                        |
| 289 | + die;  | 
                                                        |
| 290 | + }  | 
                                                        |
| 291 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 292 | 292 | |
| 293 | - return $spotter_array;  | 
                                                        |
| 294 | - }  | 
                                                        |
| 293 | + return $spotter_array;  | 
                                                        |
| 294 | + }  | 
                                                        |
| 295 | 295 | |
| 296 | 296 | |
| 297 | - /**  | 
                                                        |
| 298 | - * Gets altitude information based on a particular callsign  | 
                                                        |
| 299 | - *  | 
                                                        |
| 300 | - * @return Array the spotter information  | 
                                                        |
| 301 | - *  | 
                                                        |
| 302 | - */  | 
                                                        |
| 303 | - public function getLastAltitudeArchiveMarineDataByIdent($ident)  | 
                                                        |
| 304 | -        { | 
                                                        |
| 297 | + /**  | 
                                                        |
| 298 | + * Gets altitude information based on a particular callsign  | 
                                                        |
| 299 | + *  | 
                                                        |
| 300 | + * @return Array the spotter information  | 
                                                        |
| 301 | + *  | 
                                                        |
| 302 | + */  | 
                                                        |
| 303 | + public function getLastAltitudeArchiveMarineDataByIdent($ident)  | 
                                                        |
| 304 | +		{ | 
                                                        |
| 305 | 305 | |
| 306 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 306 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 307 | 307 | |
| 308 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 308 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";  | 
                                                        
| 311 | 311 | |
| 312 | -                try { | 
                                                        |
| 313 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 314 | -                        $sth->execute(array(':ident' => $ident)); | 
                                                        |
| 315 | -                } catch(PDOException $e) { | 
                                                        |
| 316 | - echo $e->getMessage();  | 
                                                        |
| 317 | - die;  | 
                                                        |
| 318 | - }  | 
                                                        |
| 319 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 312 | +				try { | 
                                                        |
| 313 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 314 | +						$sth->execute(array(':ident' => $ident)); | 
                                                        |
| 315 | +				} catch(PDOException $e) { | 
                                                        |
| 316 | + echo $e->getMessage();  | 
                                                        |
| 317 | + die;  | 
                                                        |
| 318 | + }  | 
                                                        |
| 319 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 320 | 320 | |
| 321 | - return $spotter_array;  | 
                                                        |
| 322 | - }  | 
                                                        |
| 321 | + return $spotter_array;  | 
                                                        |
| 322 | + }  | 
                                                        |
| 323 | 323 | |
| 324 | 324 | |
| 325 | 325 | |
| 326 | - /**  | 
                                                        |
| 327 | - * Gets all the archive spotter information  | 
                                                        |
| 328 | - *  | 
                                                        |
| 329 | - * @return Array the spotter information  | 
                                                        |
| 330 | - *  | 
                                                        |
| 331 | - */  | 
                                                        |
| 332 | - public function getMarineArchiveData($ident,$fammarine_id,$date)  | 
                                                        |
| 333 | -        { | 
                                                        |
| 334 | - $Marine = new Marine($this->db);  | 
                                                        |
| 335 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 336 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";  | 
                                                        |
| 326 | + /**  | 
                                                        |
| 327 | + * Gets all the archive spotter information  | 
                                                        |
| 328 | + *  | 
                                                        |
| 329 | + * @return Array the spotter information  | 
                                                        |
| 330 | + *  | 
                                                        |
| 331 | + */  | 
                                                        |
| 332 | + public function getMarineArchiveData($ident,$fammarine_id,$date)  | 
                                                        |
| 333 | +		{ | 
                                                        |
| 334 | + $Marine = new Marine($this->db);  | 
                                                        |
| 335 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 336 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";  | 
                                                        |
| 337 | 337 | |
| 338 | -                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); | 
                                                        |
| 338 | +				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); | 
                                                        |
| 339 | 339 | |
| 340 | - return $spotter_array;  | 
                                                        |
| 341 | - }  | 
                                                        |
| 340 | + return $spotter_array;  | 
                                                        |
| 341 | + }  | 
                                                        |
| 342 | 342 | |
| 343 | - public function deleteMarineArchiveTrackData()  | 
                                                        |
| 344 | -        { | 
                                                        |
| 343 | + public function deleteMarineArchiveTrackData()  | 
                                                        |
| 344 | +		{ | 
                                                        |
| 345 | 345 | global $globalArchiveKeepTrackMonths;  | 
                                                        
| 346 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 346 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 347 | 347 | $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';  | 
                                                        
| 348 | -                try { | 
                                                        |
| 349 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 350 | - $sth->execute();  | 
                                                        |
| 351 | -                } catch(PDOException $e) { | 
                                                        |
| 352 | - echo $e->getMessage();  | 
                                                        |
| 353 | - die;  | 
                                                        |
| 354 | - }  | 
                                                        |
| 348 | +				try { | 
                                                        |
| 349 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 350 | + $sth->execute();  | 
                                                        |
| 351 | +				} catch(PDOException $e) { | 
                                                        |
| 352 | + echo $e->getMessage();  | 
                                                        |
| 353 | + die;  | 
                                                        |
| 354 | + }  | 
                                                        |
| 355 | 355 | }  | 
                                                        
| 356 | 356 | |
| 357 | 357 | /**  | 
                                                        
| 358 | - * Gets Minimal Live Marine data  | 
                                                        |
| 359 | - *  | 
                                                        |
| 360 | - * @return Array the spotter information  | 
                                                        |
| 361 | - *  | 
                                                        |
| 362 | - */  | 
                                                        |
| 363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array())  | 
                                                        |
| 364 | -        { | 
                                                        |
| 365 | - global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 366 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 367 | -  | 
                                                        |
| 368 | - $filter_query = '';  | 
                                                        |
| 369 | -                if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 370 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 371 | - }  | 
                                                        |
| 372 | - // Use spotter_output also ?  | 
                                                        |
| 373 | -                if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 374 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 375 | - }  | 
                                                        |
| 376 | -                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 377 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 378 | - }  | 
                                                        |
| 379 | -                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 380 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 381 | - }  | 
                                                        |
| 358 | + * Gets Minimal Live Marine data  | 
                                                        |
| 359 | + *  | 
                                                        |
| 360 | + * @return Array the spotter information  | 
                                                        |
| 361 | + *  | 
                                                        |
| 362 | + */  | 
                                                        |
| 363 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array())  | 
                                                        |
| 364 | +		{ | 
                                                        |
| 365 | + global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 366 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 367 | +  | 
                                                        |
| 368 | + $filter_query = '';  | 
                                                        |
| 369 | +				if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 370 | +						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 371 | + }  | 
                                                        |
| 372 | + // Use spotter_output also ?  | 
                                                        |
| 373 | +				if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 374 | +						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 375 | + }  | 
                                                        |
| 376 | +				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 377 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 378 | + }  | 
                                                        |
| 379 | +				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 380 | +						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 381 | + }  | 
                                                        |
| 382 | 382 | |
| 383 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 384 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 385 | - /*  | 
                                                        |
| 383 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 384 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 385 | + /*  | 
                                                        |
| 386 | 386 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk  | 
                                                        
| 387 | 387 | FROM marine_archive  | 
                                                        
| 388 | 388 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';  | 
                                                        
@@ -401,56 +401,56 @@ discard block  | 
                                                    ||
| 401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao  | 
                                                        
| 402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".'  | 
                                                        
| 403 | 403 | '.$filter_query.' ORDER BY fammarine_id';  | 
                                                        
| 404 | -                } else { | 
                                                        |
| 405 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';  | 
                                                        |
| 406 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 404 | +				} else { | 
                                                        |
| 405 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';  | 
                                                        |
| 406 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 407 | 407 | FROM marine_archive  | 
                                                        
| 408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao  | 
                                                        
| 409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'  | 
                                                        
| 410 | 410 | '.$filter_query.' ORDER BY fammarine_id';  | 
                                                        
| 411 | - }  | 
                                                        |
| 412 | - //echo $query;  | 
                                                        |
| 413 | -                try { | 
                                                        |
| 414 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 415 | - $sth->execute();  | 
                                                        |
| 416 | -                } catch(PDOException $e) { | 
                                                        |
| 417 | - echo $e->getMessage();  | 
                                                        |
| 418 | - die;  | 
                                                        |
| 419 | - }  | 
                                                        |
| 420 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 411 | + }  | 
                                                        |
| 412 | + //echo $query;  | 
                                                        |
| 413 | +				try { | 
                                                        |
| 414 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 415 | + $sth->execute();  | 
                                                        |
| 416 | +				} catch(PDOException $e) { | 
                                                        |
| 417 | + echo $e->getMessage();  | 
                                                        |
| 418 | + die;  | 
                                                        |
| 419 | + }  | 
                                                        |
| 420 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 421 | 421 | |
| 422 | - return $spotter_array;  | 
                                                        |
| 423 | - }  | 
                                                        |
| 422 | + return $spotter_array;  | 
                                                        |
| 423 | + }  | 
                                                        |
| 424 | 424 | |
| 425 | 425 | /**  | 
                                                        
| 426 | - * Gets Minimal Live Marine data  | 
                                                        |
| 427 | - *  | 
                                                        |
| 428 | - * @return Array the spotter information  | 
                                                        |
| 429 | - *  | 
                                                        |
| 430 | - */  | 
                                                        |
| 431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())  | 
                                                        |
| 432 | -        { | 
                                                        |
| 433 | - global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 434 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 435 | -  | 
                                                        |
| 436 | - $filter_query = '';  | 
                                                        |
| 437 | -                if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 438 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 439 | - }  | 
                                                        |
| 440 | - // Should use spotter_output also ?  | 
                                                        |
| 441 | -                if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 442 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 443 | - }  | 
                                                        |
| 444 | -                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 445 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 446 | - }  | 
                                                        |
| 447 | -                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 448 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 449 | - }  | 
                                                        |
| 426 | + * Gets Minimal Live Marine data  | 
                                                        |
| 427 | + *  | 
                                                        |
| 428 | + * @return Array the spotter information  | 
                                                        |
| 429 | + *  | 
                                                        |
| 430 | + */  | 
                                                        |
| 431 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())  | 
                                                        |
| 432 | +		{ | 
                                                        |
| 433 | + global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 434 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 435 | +  | 
                                                        |
| 436 | + $filter_query = '';  | 
                                                        |
| 437 | +				if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 438 | +						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 439 | + }  | 
                                                        |
| 440 | + // Should use spotter_output also ?  | 
                                                        |
| 441 | +				if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 442 | +						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 443 | + }  | 
                                                        |
| 444 | +				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 445 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 446 | + }  | 
                                                        |
| 447 | +				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 448 | +						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 449 | + }  | 
                                                        |
| 450 | 450 | |
| 451 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 452 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 453 | - /*  | 
                                                        |
| 451 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 452 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 453 | + /*  | 
                                                        |
| 454 | 454 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk  | 
                                                        
| 455 | 455 | FROM marine_archive  | 
                                                        
| 456 | 456 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';  | 
                                                        
@@ -461,95 +461,95 @@ discard block  | 
                                                    ||
| 461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".')  | 
                                                        
| 462 | 462 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';  | 
                                                        
| 463 | 463 | |
| 464 | -                } else { | 
                                                        |
| 465 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';  | 
                                                        |
| 466 | - /*  | 
                                                        |
| 464 | +				} else { | 
                                                        |
| 465 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';  | 
                                                        |
| 466 | + /*  | 
                                                        |
| 467 | 467 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        
| 468 | 468 | FROM marine_archive_output  | 
                                                        
| 469 | 469 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao  | 
                                                        
| 470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'  | 
                                                        
| 471 | 471 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';  | 
                                                        
| 472 | 472 | */  | 
                                                        
| 473 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        |
| 473 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        |
| 474 | 474 | FROM marine_archive_output  | 
                                                        
| 475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao  | 
                                                        
| 476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'  | 
                                                        
| 477 | 477 | '.$filter_query.' LIMIT 200 OFFSET 0';  | 
                                                        
| 478 | 478 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';  | 
                                                        
| 479 | 479 | |
| 480 | - }  | 
                                                        |
| 481 | - //echo $query;  | 
                                                        |
| 482 | -                try { | 
                                                        |
| 483 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 484 | - $sth->execute();  | 
                                                        |
| 485 | -                } catch(PDOException $e) { | 
                                                        |
| 486 | - echo $e->getMessage();  | 
                                                        |
| 487 | - die;  | 
                                                        |
| 488 | - }  | 
                                                        |
| 489 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 480 | + }  | 
                                                        |
| 481 | + //echo $query;  | 
                                                        |
| 482 | +				try { | 
                                                        |
| 483 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 484 | + $sth->execute();  | 
                                                        |
| 485 | +				} catch(PDOException $e) { | 
                                                        |
| 486 | + echo $e->getMessage();  | 
                                                        |
| 487 | + die;  | 
                                                        |
| 488 | + }  | 
                                                        |
| 489 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 490 | 490 | |
| 491 | - return $spotter_array;  | 
                                                        |
| 492 | - }  | 
                                                        |
| 491 | + return $spotter_array;  | 
                                                        |
| 492 | + }  | 
                                                        |
| 493 | 493 | |
| 494 | 494 | /**  | 
                                                        
| 495 | - * Gets count Live Marine data  | 
                                                        |
| 496 | - *  | 
                                                        |
| 497 | - * @return Array the spotter information  | 
                                                        |
| 498 | - *  | 
                                                        |
| 499 | - */  | 
                                                        |
| 500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array())  | 
                                                        |
| 501 | -        { | 
                                                        |
| 502 | - global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 503 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 504 | -  | 
                                                        |
| 505 | - $filter_query = '';  | 
                                                        |
| 506 | -                if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 507 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 508 | - }  | 
                                                        |
| 509 | -                if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 510 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 511 | - }  | 
                                                        |
| 512 | -                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 513 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 514 | - }  | 
                                                        |
| 515 | -                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 516 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 517 | - }  | 
                                                        |
| 495 | + * Gets count Live Marine data  | 
                                                        |
| 496 | + *  | 
                                                        |
| 497 | + * @return Array the spotter information  | 
                                                        |
| 498 | + *  | 
                                                        |
| 499 | + */  | 
                                                        |
| 500 | + public function getLiveMarineCount($begindate,$enddate,$filter = array())  | 
                                                        |
| 501 | +		{ | 
                                                        |
| 502 | + global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 503 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 518 | 504 | |
| 519 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 520 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 505 | + $filter_query = '';  | 
                                                        |
| 506 | +				if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 507 | +						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 508 | + }  | 
                                                        |
| 509 | +				if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 510 | +						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 511 | + }  | 
                                                        |
| 512 | +				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 513 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 514 | + }  | 
                                                        |
| 515 | +				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 516 | +						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 517 | + }  | 
                                                        |
| 518 | +  | 
                                                        |
| 519 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 520 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 521 | 521 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb  | 
                                                        
| 522 | 522 | FROM marine_archive l  | 
                                                        
| 523 | 523 |  			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; | 
                                                        
| 524 | -                } else { | 
                                                        |
| 524 | +				} else { | 
                                                        |
| 525 | 525 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;  | 
                                                        
| 526 | - }  | 
                                                        |
| 527 | - //echo $query;  | 
                                                        |
| 528 | -                try { | 
                                                        |
| 529 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 530 | - $sth->execute();  | 
                                                        |
| 531 | -                } catch(PDOException $e) { | 
                                                        |
| 532 | - echo $e->getMessage();  | 
                                                        |
| 533 | - die;  | 
                                                        |
| 534 | - }  | 
                                                        |
| 526 | + }  | 
                                                        |
| 527 | + //echo $query;  | 
                                                        |
| 528 | +				try { | 
                                                        |
| 529 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 530 | + $sth->execute();  | 
                                                        |
| 531 | +				} catch(PDOException $e) { | 
                                                        |
| 532 | + echo $e->getMessage();  | 
                                                        |
| 533 | + die;  | 
                                                        |
| 534 | + }  | 
                                                        |
| 535 | 535 | $result = $sth->fetch(PDO::FETCH_ASSOC);  | 
                                                        
| 536 | 536 | $sth->closeCursor();  | 
                                                        
| 537 | - return $result['nb'];  | 
                                                        |
| 537 | + return $result['nb'];  | 
                                                        |
| 538 | 538 | |
| 539 | - }  | 
                                                        |
| 539 | + }  | 
                                                        |
| 540 | 540 | |
| 541 | 541 | |
| 542 | 542 | |
| 543 | 543 | // marine_archive_output  | 
                                                        
| 544 | 544 | |
| 545 | - /**  | 
                                                        |
| 546 | - * Gets all the spotter information  | 
                                                        |
| 547 | - *  | 
                                                        |
| 548 | - * @return Array the spotter information  | 
                                                        |
| 549 | - *  | 
                                                        |
| 550 | - */  | 
                                                        |
| 551 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())  | 
                                                        |
| 552 | -    { | 
                                                        |
| 545 | + /**  | 
                                                        |
| 546 | + * Gets all the spotter information  | 
                                                        |
| 547 | + *  | 
                                                        |
| 548 | + * @return Array the spotter information  | 
                                                        |
| 549 | + *  | 
                                                        |
| 550 | + */  | 
                                                        |
| 551 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())  | 
                                                        |
| 552 | +	{ | 
                                                        |
| 553 | 553 | global $globalTimezone, $globalDBdriver;  | 
                                                        
| 554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php');  | 
                                                        
| 555 | 555 | $Translation = new Translation();  | 
                                                        
@@ -563,159 +563,159 @@ discard block  | 
                                                    ||
| 563 | 563 | $filter_query = $this->getFilter($filters);  | 
                                                        
| 564 | 564 | if ($q != "")  | 
                                                        
| 565 | 565 |  	{ | 
                                                        
| 566 | - if (!is_string($q))  | 
                                                        |
| 567 | -	    { | 
                                                        |
| 566 | + if (!is_string($q))  | 
                                                        |
| 567 | +		{ | 
                                                        |
| 568 | 568 | return false;  | 
                                                        
| 569 | -	    } else { | 
                                                        |
| 569 | +		} else { | 
                                                        |
| 570 | 570 | |
| 571 | 571 |  		$q_array = explode(" ", $q); | 
                                                        
| 572 | 572 | |
| 573 | 573 |  		foreach ($q_array as $q_item){ | 
                                                        
| 574 | -		    $additional_query .= " AND ("; | 
                                                        |
| 575 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";  | 
                                                        |
| 576 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 577 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";  | 
                                                        |
| 578 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";  | 
                                                        |
| 579 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 580 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";  | 
                                                        |
| 581 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";  | 
                                                        |
| 582 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 583 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";  | 
                                                        |
| 584 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";  | 
                                                        |
| 585 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";  | 
                                                        |
| 586 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 587 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";  | 
                                                        |
| 588 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";  | 
                                                        |
| 589 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";  | 
                                                        |
| 590 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";  | 
                                                        |
| 591 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";  | 
                                                        |
| 592 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";  | 
                                                        |
| 593 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";  | 
                                                        |
| 594 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";  | 
                                                        |
| 595 | - $translate = $Translation->ident2icao($q_item);  | 
                                                        |
| 596 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";  | 
                                                        |
| 597 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";  | 
                                                        |
| 598 | - $additional_query .= ")";  | 
                                                        |
| 574 | +			$additional_query .= " AND ("; | 
                                                        |
| 575 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";  | 
                                                        |
| 576 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 577 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";  | 
                                                        |
| 578 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";  | 
                                                        |
| 579 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 580 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";  | 
                                                        |
| 581 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";  | 
                                                        |
| 582 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 583 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";  | 
                                                        |
| 584 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";  | 
                                                        |
| 585 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";  | 
                                                        |
| 586 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 587 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";  | 
                                                        |
| 588 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";  | 
                                                        |
| 589 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";  | 
                                                        |
| 590 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";  | 
                                                        |
| 591 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";  | 
                                                        |
| 592 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";  | 
                                                        |
| 593 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";  | 
                                                        |
| 594 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";  | 
                                                        |
| 595 | + $translate = $Translation->ident2icao($q_item);  | 
                                                        |
| 596 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";  | 
                                                        |
| 597 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";  | 
                                                        |
| 598 | + $additional_query .= ")";  | 
                                                        |
| 599 | + }  | 
                                                        |
| 599 | 600 | }  | 
                                                        
| 600 | - }  | 
                                                        |
| 601 | 601 | }  | 
                                                        
| 602 | 602 | |
| 603 | 603 | if ($registration != "")  | 
                                                        
| 604 | 604 |  	{ | 
                                                        
| 605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING);  | 
                                                        |
| 606 | - if (!is_string($registration))  | 
                                                        |
| 607 | -	    { | 
                                                        |
| 605 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING);  | 
                                                        |
| 606 | + if (!is_string($registration))  | 
                                                        |
| 607 | +		{ | 
                                                        |
| 608 | 608 | return false;  | 
                                                        
| 609 | -	    } else { | 
                                                        |
| 609 | +		} else { | 
                                                        |
| 610 | 610 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')";  | 
                                                        
| 611 | - }  | 
                                                        |
| 611 | + }  | 
                                                        |
| 612 | 612 | }  | 
                                                        
| 613 | 613 | |
| 614 | 614 | if ($aircraft_icao != "")  | 
                                                        
| 615 | 615 |  	{ | 
                                                        
| 616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 617 | - if (!is_string($aircraft_icao))  | 
                                                        |
| 618 | -	    { | 
                                                        |
| 616 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 617 | + if (!is_string($aircraft_icao))  | 
                                                        |
| 618 | +		{ | 
                                                        |
| 619 | 619 | return false;  | 
                                                        
| 620 | -	    } else { | 
                                                        |
| 620 | +		} else { | 
                                                        |
| 621 | 621 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";  | 
                                                        
| 622 | - }  | 
                                                        |
| 622 | + }  | 
                                                        |
| 623 | 623 | }  | 
                                                        
| 624 | 624 | |
| 625 | 625 | if ($aircraft_manufacturer != "")  | 
                                                        
| 626 | 626 |  	{ | 
                                                        
| 627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);  | 
                                                        |
| 628 | - if (!is_string($aircraft_manufacturer))  | 
                                                        |
| 629 | -	    { | 
                                                        |
| 627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);  | 
                                                        |
| 628 | + if (!is_string($aircraft_manufacturer))  | 
                                                        |
| 629 | +		{ | 
                                                        |
| 630 | 630 | return false;  | 
                                                        
| 631 | -	    } else { | 
                                                        |
| 631 | +		} else { | 
                                                        |
| 632 | 632 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";  | 
                                                        
| 633 | - }  | 
                                                        |
| 633 | + }  | 
                                                        |
| 634 | 634 | }  | 
                                                        
| 635 | 635 | |
| 636 | 636 | if ($highlights == "true")  | 
                                                        
| 637 | 637 |  	{ | 
                                                        
| 638 | - if (!is_string($highlights))  | 
                                                        |
| 639 | -	    { | 
                                                        |
| 638 | + if (!is_string($highlights))  | 
                                                        |
| 639 | +		{ | 
                                                        |
| 640 | 640 | return false;  | 
                                                        
| 641 | -	    } else { | 
                                                        |
| 641 | +		} else { | 
                                                        |
| 642 | 642 | $additional_query .= " AND (marine_archive_output.highlight <> '')";  | 
                                                        
| 643 | - }  | 
                                                        |
| 643 | + }  | 
                                                        |
| 644 | 644 | }  | 
                                                        
| 645 | 645 | |
| 646 | 646 | if ($airline_icao != "")  | 
                                                        
| 647 | 647 |  	{ | 
                                                        
| 648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 649 | - if (!is_string($airline_icao))  | 
                                                        |
| 650 | -	    { | 
                                                        |
| 648 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 649 | + if (!is_string($airline_icao))  | 
                                                        |
| 650 | +		{ | 
                                                        |
| 651 | 651 | return false;  | 
                                                        
| 652 | -	    } else { | 
                                                        |
| 652 | +		} else { | 
                                                        |
| 653 | 653 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";  | 
                                                        
| 654 | - }  | 
                                                        |
| 654 | + }  | 
                                                        |
| 655 | 655 | }  | 
                                                        
| 656 | 656 | |
| 657 | 657 | if ($airline_country != "")  | 
                                                        
| 658 | 658 |  	{ | 
                                                        
| 659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 660 | - if (!is_string($airline_country))  | 
                                                        |
| 661 | -	    { | 
                                                        |
| 659 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 660 | + if (!is_string($airline_country))  | 
                                                        |
| 661 | +		{ | 
                                                        |
| 662 | 662 | return false;  | 
                                                        
| 663 | -	    } else { | 
                                                        |
| 663 | +		} else { | 
                                                        |
| 664 | 664 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";  | 
                                                        
| 665 | - }  | 
                                                        |
| 665 | + }  | 
                                                        |
| 666 | 666 | }  | 
                                                        
| 667 | 667 | |
| 668 | 668 | if ($airline_type != "")  | 
                                                        
| 669 | 669 |  	{ | 
                                                        
| 670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);  | 
                                                        |
| 671 | - if (!is_string($airline_type))  | 
                                                        |
| 672 | -	    { | 
                                                        |
| 670 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);  | 
                                                        |
| 671 | + if (!is_string($airline_type))  | 
                                                        |
| 672 | +		{ | 
                                                        |
| 673 | 673 | return false;  | 
                                                        
| 674 | -	    } else { | 
                                                        |
| 674 | +		} else { | 
                                                        |
| 675 | 675 | if ($airline_type == "passenger")  | 
                                                        
| 676 | 676 |  		{ | 
                                                        
| 677 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";  | 
                                                        |
| 677 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";  | 
                                                        |
| 678 | 678 | }  | 
                                                        
| 679 | 679 | if ($airline_type == "cargo")  | 
                                                        
| 680 | 680 |  		{ | 
                                                        
| 681 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";  | 
                                                        |
| 681 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";  | 
                                                        |
| 682 | 682 | }  | 
                                                        
| 683 | 683 | if ($airline_type == "military")  | 
                                                        
| 684 | 684 |  		{ | 
                                                        
| 685 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')";  | 
                                                        |
| 685 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')";  | 
                                                        |
| 686 | + }  | 
                                                        |
| 686 | 687 | }  | 
                                                        
| 687 | - }  | 
                                                        |
| 688 | 688 | }  | 
                                                        
| 689 | 689 | |
| 690 | 690 | if ($airport != "")  | 
                                                        
| 691 | 691 |  	{ | 
                                                        
| 692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING);  | 
                                                        |
| 693 | - if (!is_string($airport))  | 
                                                        |
| 694 | -	    { | 
                                                        |
| 692 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING);  | 
                                                        |
| 693 | + if (!is_string($airport))  | 
                                                        |
| 694 | +		{ | 
                                                        |
| 695 | 695 | return false;  | 
                                                        
| 696 | -	    } else { | 
                                                        |
| 696 | +		} else { | 
                                                        |
| 697 | 697 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";  | 
                                                        
| 698 | - }  | 
                                                        |
| 698 | + }  | 
                                                        |
| 699 | 699 | }  | 
                                                        
| 700 | 700 | |
| 701 | 701 | if ($airport_country != "")  | 
                                                        
| 702 | 702 |  	{ | 
                                                        
| 703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 704 | - if (!is_string($airport_country))  | 
                                                        |
| 705 | -	    { | 
                                                        |
| 703 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 704 | + if (!is_string($airport_country))  | 
                                                        |
| 705 | +		{ | 
                                                        |
| 706 | 706 | return false;  | 
                                                        
| 707 | -	    } else { | 
                                                        |
| 707 | +		} else { | 
                                                        |
| 708 | 708 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";  | 
                                                        
| 709 | - }  | 
                                                        |
| 709 | + }  | 
                                                        |
| 710 | 710 | }  | 
                                                        
| 711 | 711 | |
| 712 | 712 | if ($callsign != "")  | 
                                                        
| 713 | 713 |  	{ | 
                                                        
| 714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);  | 
                                                        |
| 715 | - if (!is_string($callsign))  | 
                                                        |
| 716 | -	    { | 
                                                        |
| 714 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);  | 
                                                        |
| 715 | + if (!is_string($callsign))  | 
                                                        |
| 716 | +		{ | 
                                                        |
| 717 | 717 | return false;  | 
                                                        
| 718 | -	    } else { | 
                                                        |
| 718 | +		} else { | 
                                                        |
| 719 | 719 | $translate = $Translation->ident2icao($callsign);  | 
                                                        
| 720 | 720 |  		if ($translate != $callsign) { | 
                                                        
| 721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";  | 
                                                        
@@ -723,99 +723,99 @@ discard block  | 
                                                    ||
| 723 | 723 |  		} else { | 
                                                        
| 724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";  | 
                                                        
| 725 | 725 | }  | 
                                                        
| 726 | - }  | 
                                                        |
| 726 | + }  | 
                                                        |
| 727 | 727 | }  | 
                                                        
| 728 | 728 | |
| 729 | 729 | if ($owner != "")  | 
                                                        
| 730 | 730 |  	{ | 
                                                        
| 731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING);  | 
                                                        |
| 732 | - if (!is_string($owner))  | 
                                                        |
| 733 | -	    { | 
                                                        |
| 731 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING);  | 
                                                        |
| 732 | + if (!is_string($owner))  | 
                                                        |
| 733 | +		{ | 
                                                        |
| 734 | 734 | return false;  | 
                                                        
| 735 | -	    } else { | 
                                                        |
| 735 | +		} else { | 
                                                        |
| 736 | 736 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";  | 
                                                        
| 737 | - }  | 
                                                        |
| 737 | + }  | 
                                                        |
| 738 | 738 | }  | 
                                                        
| 739 | 739 | |
| 740 | 740 | if ($pilot_name != "")  | 
                                                        
| 741 | 741 |  	{ | 
                                                        
| 742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);  | 
                                                        |
| 743 | - if (!is_string($pilot_name))  | 
                                                        |
| 744 | -	    { | 
                                                        |
| 742 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);  | 
                                                        |
| 743 | + if (!is_string($pilot_name))  | 
                                                        |
| 744 | +		{ | 
                                                        |
| 745 | 745 | return false;  | 
                                                        
| 746 | -	    } else { | 
                                                        |
| 746 | +		} else { | 
                                                        |
| 747 | 747 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";  | 
                                                        
| 748 | - }  | 
                                                        |
| 748 | + }  | 
                                                        |
| 749 | 749 | }  | 
                                                        
| 750 | 750 | |
| 751 | 751 | if ($pilot_id != "")  | 
                                                        
| 752 | 752 |  	{ | 
                                                        
| 753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 754 | - if (!is_string($pilot_id))  | 
                                                        |
| 755 | -	    { | 
                                                        |
| 753 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 754 | + if (!is_string($pilot_id))  | 
                                                        |
| 755 | +		{ | 
                                                        |
| 756 | 756 | return false;  | 
                                                        
| 757 | -	    } else { | 
                                                        |
| 757 | +		} else { | 
                                                        |
| 758 | 758 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";  | 
                                                        
| 759 | - }  | 
                                                        |
| 759 | + }  | 
                                                        |
| 760 | 760 | }  | 
                                                        
| 761 | 761 | |
| 762 | 762 | if ($departure_airport_route != "")  | 
                                                        
| 763 | 763 |  	{ | 
                                                        
| 764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 765 | - if (!is_string($departure_airport_route))  | 
                                                        |
| 766 | -	    { | 
                                                        |
| 764 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 765 | + if (!is_string($departure_airport_route))  | 
                                                        |
| 766 | +		{ | 
                                                        |
| 767 | 767 | return false;  | 
                                                        
| 768 | -	    } else { | 
                                                        |
| 768 | +		} else { | 
                                                        |
| 769 | 769 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";  | 
                                                        
| 770 | - }  | 
                                                        |
| 770 | + }  | 
                                                        |
| 771 | 771 | }  | 
                                                        
| 772 | 772 | |
| 773 | 773 | if ($arrival_airport_route != "")  | 
                                                        
| 774 | 774 |  	{ | 
                                                        
| 775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 776 | - if (!is_string($arrival_airport_route))  | 
                                                        |
| 777 | -	    { | 
                                                        |
| 775 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 776 | + if (!is_string($arrival_airport_route))  | 
                                                        |
| 777 | +		{ | 
                                                        |
| 778 | 778 | return false;  | 
                                                        
| 779 | -	    } else { | 
                                                        |
| 779 | +		} else { | 
                                                        |
| 780 | 780 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";  | 
                                                        
| 781 | - }  | 
                                                        |
| 781 | + }  | 
                                                        |
| 782 | 782 | }  | 
                                                        
| 783 | 783 | |
| 784 | 784 | if ($altitude != "")  | 
                                                        
| 785 | 785 |  	{ | 
                                                        
| 786 | -	    $altitude_array = explode(",", $altitude); | 
                                                        |
| 786 | +		$altitude_array = explode(",", $altitude); | 
                                                        |
| 787 | 787 | |
| 788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 788 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 789 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 790 | 790 | |
| 791 | 791 | |
| 792 | - if ($altitude_array[1] != "")  | 
                                                        |
| 793 | -	    {                 | 
                                                        |
| 792 | + if ($altitude_array[1] != "")  | 
                                                        |
| 793 | +		{                 | 
                                                        |
| 794 | 794 | $altitude_array[0] = substr($altitude_array[0], 0, -2);  | 
                                                        
| 795 | 795 | $altitude_array[1] = substr($altitude_array[1], 0, -2);  | 
                                                        
| 796 | 796 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";  | 
                                                        
| 797 | -	    } else { | 
                                                        |
| 797 | +		} else { | 
                                                        |
| 798 | 798 | $altitude_array[0] = substr($altitude_array[0], 0, -2);  | 
                                                        
| 799 | 799 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' ";  | 
                                                        
| 800 | - }  | 
                                                        |
| 800 | + }  | 
                                                        |
| 801 | 801 | }  | 
                                                        
| 802 | 802 | |
| 803 | 803 | if ($date_posted != "")  | 
                                                        
| 804 | 804 |  	{ | 
                                                        
| 805 | -	    $date_array = explode(",", $date_posted); | 
                                                        |
| 805 | +		$date_array = explode(",", $date_posted); | 
                                                        |
| 806 | 806 | |
| 807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);  | 
                                                        |
| 808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);  | 
                                                        |
| 807 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);  | 
                                                        |
| 808 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);  | 
                                                        |
| 809 | 809 | |
| 810 | -	    if ($globalTimezone != '') { | 
                                                        |
| 810 | +		if ($globalTimezone != '') { | 
                                                        |
| 811 | 811 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 812 | 812 | $datetime = new DateTime();  | 
                                                        
| 813 | 813 |  		$offset = $datetime->format('P'); | 
                                                        
| 814 | - } else $offset = '+00:00';  | 
                                                        |
| 814 | + } else $offset = '+00:00';  | 
                                                        |
| 815 | 815 | |
| 816 | 816 | |
| 817 | - if ($date_array[1] != "")  | 
                                                        |
| 818 | -	    {                 | 
                                                        |
| 817 | + if ($date_array[1] != "")  | 
                                                        |
| 818 | +		{                 | 
                                                        |
| 819 | 819 |  		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); | 
                                                        
| 820 | 820 |  		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); | 
                                                        
| 821 | 821 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -823,28 +823,28 @@ discard block  | 
                                                    ||
| 823 | 823 |  		} else { | 
                                                        
| 824 | 824 |  			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; | 
                                                        
| 825 | 825 | }  | 
                                                        
| 826 | -	    } else { | 
                                                        |
| 826 | +		} else { | 
                                                        |
| 827 | 827 |  		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); | 
                                                        
| 828 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 828 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 829 | 829 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";  | 
                                                        
| 830 | 830 |  		} else { | 
                                                        
| 831 | 831 |  			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; | 
                                                        
| 832 | 832 | }  | 
                                                        
| 833 | - }  | 
                                                        |
| 833 | + }  | 
                                                        |
| 834 | 834 | }  | 
                                                        
| 835 | 835 | |
| 836 | 836 | if ($limit != "")  | 
                                                        
| 837 | 837 |  	{ | 
                                                        
| 838 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 838 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 839 | 839 | |
| 840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 840 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 841 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 842 | 842 | |
| 843 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 844 | -	    { | 
                                                        |
| 843 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 844 | +		{ | 
                                                        |
| 845 | 845 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 846 | 846 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 847 | - }  | 
                                                        |
| 847 | + }  | 
                                                        |
| 848 | 848 | }  | 
                                                        
| 849 | 849 | |
| 850 | 850 | |
@@ -875,33 +875,33 @@ discard block  | 
                                                    ||
| 875 | 875 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);  | 
                                                        
| 876 | 876 | |
| 877 | 877 | return $spotter_array;  | 
                                                        
| 878 | - }  | 
                                                        |
| 878 | + }  | 
                                                        |
| 879 | 879 | |
| 880 | - public function deleteMarineArchiveData()  | 
                                                        |
| 881 | -    { | 
                                                        |
| 880 | + public function deleteMarineArchiveData()  | 
                                                        |
| 881 | +	{ | 
                                                        |
| 882 | 882 | global $globalArchiveKeepMonths, $globalDBdriver;  | 
                                                        
| 883 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 884 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 883 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 884 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 885 | 885 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';  | 
                                                        
| 886 | 886 |  		} else { | 
                                                        
| 887 | 887 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";  | 
                                                        
| 888 | 888 | }  | 
                                                        
| 889 | -                try { | 
                                                        |
| 890 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 891 | - $sth->execute();  | 
                                                        |
| 892 | -                } catch(PDOException $e) { | 
                                                        |
| 893 | - return "error";  | 
                                                        |
| 894 | - }  | 
                                                        |
| 889 | +				try { | 
                                                        |
| 890 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 891 | + $sth->execute();  | 
                                                        |
| 892 | +				} catch(PDOException $e) { | 
                                                        |
| 893 | + return "error";  | 
                                                        |
| 894 | + }  | 
                                                        |
| 895 | 895 | }  | 
                                                        
| 896 | 896 | |
| 897 | - /**  | 
                                                        |
| 898 | - * Gets all the spotter information based on the callsign  | 
                                                        |
| 899 | - *  | 
                                                        |
| 900 | - * @return Array the spotter information  | 
                                                        |
| 901 | - *  | 
                                                        |
| 902 | - */  | 
                                                        |
| 903 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')  | 
                                                        |
| 904 | -    { | 
                                                        |
| 897 | + /**  | 
                                                        |
| 898 | + * Gets all the spotter information based on the callsign  | 
                                                        |
| 899 | + *  | 
                                                        |
| 900 | + * @return Array the spotter information  | 
                                                        |
| 901 | + *  | 
                                                        |
| 902 | + */  | 
                                                        |
| 903 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')  | 
                                                        |
| 904 | +	{ | 
                                                        |
| 905 | 905 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output";  | 
                                                        
| 906 | 906 | |
| 907 | 907 |  	date_default_timezone_set('UTC'); | 
                                                        
@@ -913,35 +913,35 @@ discard block  | 
                                                    ||
| 913 | 913 | |
| 914 | 914 | if ($ident != "")  | 
                                                        
| 915 | 915 |  	{ | 
                                                        
| 916 | - if (!is_string($ident))  | 
                                                        |
| 917 | -	    { | 
                                                        |
| 916 | + if (!is_string($ident))  | 
                                                        |
| 917 | +		{ | 
                                                        |
| 918 | 918 | return false;  | 
                                                        
| 919 | -	    } else { | 
                                                        |
| 919 | +		} else { | 
                                                        |
| 920 | 920 | $additional_query = " AND (marine_archive_output.ident = :ident)";  | 
                                                        
| 921 | 921 |  		$query_values = array(':ident' => $ident); | 
                                                        
| 922 | - }  | 
                                                        |
| 922 | + }  | 
                                                        |
| 923 | 923 | }  | 
                                                        
| 924 | 924 | |
| 925 | 925 | if ($limit != "")  | 
                                                        
| 926 | 926 |  	{ | 
                                                        
| 927 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 927 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 928 | 928 | |
| 929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 929 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 930 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 931 | 931 | |
| 932 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 933 | -	    { | 
                                                        |
| 932 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 933 | +		{ | 
                                                        |
| 934 | 934 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 935 | 935 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 936 | - }  | 
                                                        |
| 936 | + }  | 
                                                        |
| 937 | 937 | }  | 
                                                        
| 938 | 938 | |
| 939 | 939 | if ($sort != "")  | 
                                                        
| 940 | 940 |  	{ | 
                                                        
| 941 | - $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 942 | - $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 941 | + $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 942 | + $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 943 | 943 |  	} else { | 
                                                        
| 944 | - $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 944 | + $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 945 | 945 | }  | 
                                                        
| 946 | 946 | |
| 947 | 947 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;  | 
                                                        
@@ -949,17 +949,17 @@ discard block  | 
                                                    ||
| 949 | 949 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        
| 950 | 950 | |
| 951 | 951 | return $spotter_array;  | 
                                                        
| 952 | - }  | 
                                                        |
| 952 | + }  | 
                                                        |
| 953 | 953 | |
| 954 | 954 | |
| 955 | - /**  | 
                                                        |
| 956 | - * Gets all the spotter information based on the owner  | 
                                                        |
| 957 | - *  | 
                                                        |
| 958 | - * @return Array the spotter information  | 
                                                        |
| 959 | - *  | 
                                                        |
| 960 | - */  | 
                                                        |
| 961 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())  | 
                                                        |
| 962 | -    { | 
                                                        |
| 955 | + /**  | 
                                                        |
| 956 | + * Gets all the spotter information based on the owner  | 
                                                        |
| 957 | + *  | 
                                                        |
| 958 | + * @return Array the spotter information  | 
                                                        |
| 959 | + *  | 
                                                        |
| 960 | + */  | 
                                                        |
| 961 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())  | 
                                                        |
| 962 | +	{ | 
                                                        |
| 963 | 963 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output";  | 
                                                        
| 964 | 964 | |
| 965 | 965 |  	date_default_timezone_set('UTC'); | 
                                                        
@@ -972,35 +972,35 @@ discard block  | 
                                                    ||
| 972 | 972 | |
| 973 | 973 | if ($owner != "")  | 
                                                        
| 974 | 974 |  	{ | 
                                                        
| 975 | - if (!is_string($owner))  | 
                                                        |
| 976 | -	    { | 
                                                        |
| 975 | + if (!is_string($owner))  | 
                                                        |
| 976 | +		{ | 
                                                        |
| 977 | 977 | return false;  | 
                                                        
| 978 | -	    } else { | 
                                                        |
| 978 | +		} else { | 
                                                        |
| 979 | 979 | $additional_query = " AND (marine_archive_output.owner_name = :owner)";  | 
                                                        
| 980 | 980 |  		$query_values = array(':owner' => $owner); | 
                                                        
| 981 | - }  | 
                                                        |
| 981 | + }  | 
                                                        |
| 982 | 982 | }  | 
                                                        
| 983 | 983 | |
| 984 | 984 | if ($limit != "")  | 
                                                        
| 985 | 985 |  	{ | 
                                                        
| 986 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 986 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 987 | 987 | |
| 988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 988 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 989 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 990 | 990 | |
| 991 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 992 | -	    { | 
                                                        |
| 991 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 992 | +		{ | 
                                                        |
| 993 | 993 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 994 | 994 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 995 | - }  | 
                                                        |
| 995 | + }  | 
                                                        |
| 996 | 996 | }  | 
                                                        
| 997 | 997 | |
| 998 | 998 | if ($sort != "")  | 
                                                        
| 999 | 999 |  	{ | 
                                                        
| 1000 | - $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1001 | - $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1000 | + $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1001 | + $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1002 | 1002 |  	} else { | 
                                                        
| 1003 | - $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1003 | + $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1004 | 1004 | }  | 
                                                        
| 1005 | 1005 | |
| 1006 | 1006 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;  | 
                                                        
@@ -1008,16 +1008,16 @@ discard block  | 
                                                    ||
| 1008 | 1008 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        
| 1009 | 1009 | |
| 1010 | 1010 | return $spotter_array;  | 
                                                        
| 1011 | - }  | 
                                                        |
| 1012 | -  | 
                                                        |
| 1013 | - /**  | 
                                                        |
| 1014 | - * Gets all the spotter information based on the pilot  | 
                                                        |
| 1015 | - *  | 
                                                        |
| 1016 | - * @return Array the spotter information  | 
                                                        |
| 1017 | - *  | 
                                                        |
| 1018 | - */  | 
                                                        |
| 1019 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())  | 
                                                        |
| 1020 | -    { | 
                                                        |
| 1011 | + }  | 
                                                        |
| 1012 | +  | 
                                                        |
| 1013 | + /**  | 
                                                        |
| 1014 | + * Gets all the spotter information based on the pilot  | 
                                                        |
| 1015 | + *  | 
                                                        |
| 1016 | + * @return Array the spotter information  | 
                                                        |
| 1017 | + *  | 
                                                        |
| 1018 | + */  | 
                                                        |
| 1019 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())  | 
                                                        |
| 1020 | +	{ | 
                                                        |
| 1021 | 1021 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output";  | 
                                                        
| 1022 | 1022 | |
| 1023 | 1023 |  	date_default_timezone_set('UTC'); | 
                                                        
@@ -1036,24 +1036,24 @@ discard block  | 
                                                    ||
| 1036 | 1036 | |
| 1037 | 1037 | if ($limit != "")  | 
                                                        
| 1038 | 1038 |  	{ | 
                                                        
| 1039 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 1039 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 1040 | 1040 | |
| 1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1041 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1042 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1043 | 1043 | |
| 1044 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1045 | -	    { | 
                                                        |
| 1044 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1045 | +		{ | 
                                                        |
| 1046 | 1046 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 1047 | 1047 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 1048 | - }  | 
                                                        |
| 1048 | + }  | 
                                                        |
| 1049 | 1049 | }  | 
                                                        
| 1050 | 1050 | |
| 1051 | 1051 | if ($sort != "")  | 
                                                        
| 1052 | 1052 |  	{ | 
                                                        
| 1053 | - $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1054 | - $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1053 | + $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1054 | + $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1055 | 1055 |  	} else { | 
                                                        
| 1056 | - $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1056 | + $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1057 | 1057 | }  | 
                                                        
| 1058 | 1058 | |
| 1059 | 1059 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;  | 
                                                        
@@ -1061,16 +1061,16 @@ discard block  | 
                                                    ||
| 1061 | 1061 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        
| 1062 | 1062 | |
| 1063 | 1063 | return $spotter_array;  | 
                                                        
| 1064 | - }  | 
                                                        |
| 1065 | -  | 
                                                        |
| 1066 | - /**  | 
                                                        |
| 1067 | - * Gets all number of flight over countries  | 
                                                        |
| 1068 | - *  | 
                                                        |
| 1069 | - * @return Array the airline country list  | 
                                                        |
| 1070 | - *  | 
                                                        |
| 1071 | - */  | 
                                                        |
| 1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1073 | -    { | 
                                                        |
| 1064 | + }  | 
                                                        |
| 1065 | +  | 
                                                        |
| 1066 | + /**  | 
                                                        |
| 1067 | + * Gets all number of flight over countries  | 
                                                        |
| 1068 | + *  | 
                                                        |
| 1069 | + * @return Array the airline country list  | 
                                                        |
| 1070 | + *  | 
                                                        |
| 1071 | + */  | 
                                                        |
| 1072 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1073 | +	{ | 
                                                        |
| 1074 | 1074 | global $globalDBdriver;  | 
                                                        
| 1075 | 1075 | /*  | 
                                                        
| 1076 | 1076 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb  | 
                                                        
@@ -1080,14 +1080,14 @@ discard block  | 
                                                    ||
| 1080 | 1080 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb  | 
                                                        
| 1081 | 1081 | FROM countries c, marine_archive s  | 
                                                        
| 1082 | 1082 | WHERE c.iso2 = s.over_country ";  | 
                                                        
| 1083 | -                if ($olderthanmonths > 0) { | 
                                                        |
| 1084 | -            		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 1083 | +				if ($olderthanmonths > 0) { | 
                                                        |
| 1084 | +					if ($globalDBdriver == 'mysql') { | 
                                                        |
| 1085 | 1085 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';  | 
                                                        
| 1086 | 1086 |  			} else { | 
                                                        
| 1087 | 1087 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        
| 1088 | 1088 | }  | 
                                                        
| 1089 | 1089 | }  | 
                                                        
| 1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";  | 
                                                        |
| 1090 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";  | 
                                                        |
| 1091 | 1091 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";  | 
                                                        
| 1092 | 1092 | if ($limit) $query .= " LIMIT 0,10";  | 
                                                        
| 1093 | 1093 | |
@@ -1100,23 +1100,23 @@ discard block  | 
                                                    ||
| 1100 | 1100 | |
| 1101 | 1101 | while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        
| 1102 | 1102 |  	{ | 
                                                        
| 1103 | - $temp_array['flight_count'] = $row['nb'];  | 
                                                        |
| 1104 | - $temp_array['flight_country'] = $row['name'];  | 
                                                        |
| 1105 | - $temp_array['flight_country_iso3'] = $row['iso3'];  | 
                                                        |
| 1106 | - $temp_array['flight_country_iso2'] = $row['iso2'];  | 
                                                        |
| 1107 | - $flight_array[] = $temp_array;  | 
                                                        |
| 1103 | + $temp_array['flight_count'] = $row['nb'];  | 
                                                        |
| 1104 | + $temp_array['flight_country'] = $row['name'];  | 
                                                        |
| 1105 | + $temp_array['flight_country_iso3'] = $row['iso3'];  | 
                                                        |
| 1106 | + $temp_array['flight_country_iso2'] = $row['iso2'];  | 
                                                        |
| 1107 | + $flight_array[] = $temp_array;  | 
                                                        |
| 1108 | 1108 | }  | 
                                                        
| 1109 | 1109 | return $flight_array;  | 
                                                        
| 1110 | - }  | 
                                                        |
| 1111 | -  | 
                                                        |
| 1112 | - /**  | 
                                                        |
| 1113 | - * Gets all number of flight over countries  | 
                                                        |
| 1114 | - *  | 
                                                        |
| 1115 | - * @return Array the airline country list  | 
                                                        |
| 1116 | - *  | 
                                                        |
| 1117 | - */  | 
                                                        |
| 1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1119 | -    { | 
                                                        |
| 1110 | + }  | 
                                                        |
| 1111 | +  | 
                                                        |
| 1112 | + /**  | 
                                                        |
| 1113 | + * Gets all number of flight over countries  | 
                                                        |
| 1114 | + *  | 
                                                        |
| 1115 | + * @return Array the airline country list  | 
                                                        |
| 1116 | + *  | 
                                                        |
| 1117 | + */  | 
                                                        |
| 1118 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1119 | +	{ | 
                                                        |
| 1120 | 1120 | global $globalDBdriver;  | 
                                                        
| 1121 | 1121 | /*  | 
                                                        
| 1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb  | 
                                                        
@@ -1126,14 +1126,14 @@ discard block  | 
                                                    ||
| 1126 | 1126 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb  | 
                                                        
| 1127 | 1127 | FROM countries c, marine_archive s, spotter_output o  | 
                                                        
| 1128 | 1128 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";  | 
                                                        
| 1129 | -                if ($olderthanmonths > 0) { | 
                                                        |
| 1130 | -            		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 1129 | +				if ($olderthanmonths > 0) { | 
                                                        |
| 1130 | +					if ($globalDBdriver == 'mysql') { | 
                                                        |
| 1131 | 1131 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';  | 
                                                        
| 1132 | 1132 |  			} else { | 
                                                        
| 1133 | 1133 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        
| 1134 | 1134 | }  | 
                                                        
| 1135 | 1135 | }  | 
                                                        
| 1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";  | 
                                                        |
| 1136 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";  | 
                                                        |
| 1137 | 1137 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";  | 
                                                        
| 1138 | 1138 | if ($limit) $query .= " LIMIT 0,10";  | 
                                                        
| 1139 | 1139 | |
@@ -1146,24 +1146,24 @@ discard block  | 
                                                    ||
| 1146 | 1146 | |
| 1147 | 1147 | while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        
| 1148 | 1148 |  	{ | 
                                                        
| 1149 | - $temp_array['airline_icao'] = $row['airline_icao'];  | 
                                                        |
| 1150 | - $temp_array['flight_count'] = $row['nb'];  | 
                                                        |
| 1151 | - $temp_array['flight_country'] = $row['name'];  | 
                                                        |
| 1152 | - $temp_array['flight_country_iso3'] = $row['iso3'];  | 
                                                        |
| 1153 | - $temp_array['flight_country_iso2'] = $row['iso2'];  | 
                                                        |
| 1154 | - $flight_array[] = $temp_array;  | 
                                                        |
| 1149 | + $temp_array['airline_icao'] = $row['airline_icao'];  | 
                                                        |
| 1150 | + $temp_array['flight_count'] = $row['nb'];  | 
                                                        |
| 1151 | + $temp_array['flight_country'] = $row['name'];  | 
                                                        |
| 1152 | + $temp_array['flight_country_iso3'] = $row['iso3'];  | 
                                                        |
| 1153 | + $temp_array['flight_country_iso2'] = $row['iso2'];  | 
                                                        |
| 1154 | + $flight_array[] = $temp_array;  | 
                                                        |
| 1155 | 1155 | }  | 
                                                        
| 1156 | 1156 | return $flight_array;  | 
                                                        
| 1157 | - }  | 
                                                        |
| 1158 | -  | 
                                                        |
| 1159 | - /**  | 
                                                        |
| 1160 | - * Gets last spotter information based on a particular callsign  | 
                                                        |
| 1161 | - *  | 
                                                        |
| 1162 | - * @return Array the spotter information  | 
                                                        |
| 1163 | - *  | 
                                                        |
| 1164 | - */  | 
                                                        |
| 1165 | - public function getDateArchiveMarineDataById($id,$date)  | 
                                                        |
| 1166 | -    { | 
                                                        |
| 1157 | + }  | 
                                                        |
| 1158 | +  | 
                                                        |
| 1159 | + /**  | 
                                                        |
| 1160 | + * Gets last spotter information based on a particular callsign  | 
                                                        |
| 1161 | + *  | 
                                                        |
| 1162 | + * @return Array the spotter information  | 
                                                        |
| 1163 | + *  | 
                                                        |
| 1164 | + */  | 
                                                        |
| 1165 | + public function getDateArchiveMarineDataById($id,$date)  | 
                                                        |
| 1166 | +	{ | 
                                                        |
| 1167 | 1167 | $Marine = new Marine($this->db);  | 
                                                        
| 1168 | 1168 |  	date_default_timezone_set('UTC'); | 
                                                        
| 1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
@@ -1171,16 +1171,16 @@ discard block  | 
                                                    ||
| 1171 | 1171 |  	$date = date('c',$date); | 
                                                        
| 1172 | 1172 |  	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); | 
                                                        
| 1173 | 1173 | return $spotter_array;  | 
                                                        
| 1174 | - }  | 
                                                        |
| 1175 | -  | 
                                                        |
| 1176 | - /**  | 
                                                        |
| 1177 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 1178 | - *  | 
                                                        |
| 1179 | - * @return Array the spotter information  | 
                                                        |
| 1180 | - *  | 
                                                        |
| 1181 | - */  | 
                                                        |
| 1182 | - public function getDateArchiveMarineDataByIdent($ident,$date)  | 
                                                        |
| 1183 | -    { | 
                                                        |
| 1174 | + }  | 
                                                        |
| 1175 | +  | 
                                                        |
| 1176 | + /**  | 
                                                        |
| 1177 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 1178 | + *  | 
                                                        |
| 1179 | + * @return Array the spotter information  | 
                                                        |
| 1180 | + *  | 
                                                        |
| 1181 | + */  | 
                                                        |
| 1182 | + public function getDateArchiveMarineDataByIdent($ident,$date)  | 
                                                        |
| 1183 | +	{ | 
                                                        |
| 1184 | 1184 | $Marine = new Marine($this->db);  | 
                                                        
| 1185 | 1185 |  	date_default_timezone_set('UTC'); | 
                                                        
| 1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
@@ -1188,16 +1188,16 @@ discard block  | 
                                                    ||
| 1188 | 1188 |  	$date = date('c',$date); | 
                                                        
| 1189 | 1189 |  	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); | 
                                                        
| 1190 | 1190 | return $spotter_array;  | 
                                                        
| 1191 | - }  | 
                                                        |
| 1192 | -  | 
                                                        |
| 1193 | - /**  | 
                                                        |
| 1194 | - * Gets all the spotter information based on the airport  | 
                                                        |
| 1195 | - *  | 
                                                        |
| 1196 | - * @return Array the spotter information  | 
                                                        |
| 1197 | - *  | 
                                                        |
| 1198 | - */  | 
                                                        |
| 1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())  | 
                                                        |
| 1200 | -    { | 
                                                        |
| 1191 | + }  | 
                                                        |
| 1192 | +  | 
                                                        |
| 1193 | + /**  | 
                                                        |
| 1194 | + * Gets all the spotter information based on the airport  | 
                                                        |
| 1195 | + *  | 
                                                        |
| 1196 | + * @return Array the spotter information  | 
                                                        |
| 1197 | + *  | 
                                                        |
| 1198 | + */  | 
                                                        |
| 1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())  | 
                                                        |
| 1200 | +	{ | 
                                                        |
| 1201 | 1201 | global $global_query;  | 
                                                        
| 1202 | 1202 | $Marine = new Marine();  | 
                                                        
| 1203 | 1203 |  	date_default_timezone_set('UTC'); | 
                                                        
@@ -1208,35 +1208,35 @@ discard block  | 
                                                    ||
| 1208 | 1208 | |
| 1209 | 1209 | if ($airport != "")  | 
                                                        
| 1210 | 1210 |  	{ | 
                                                        
| 1211 | - if (!is_string($airport))  | 
                                                        |
| 1212 | -	    { | 
                                                        |
| 1211 | + if (!is_string($airport))  | 
                                                        |
| 1212 | +		{ | 
                                                        |
| 1213 | 1213 | return false;  | 
                                                        
| 1214 | -	    } else { | 
                                                        |
| 1214 | +		} else { | 
                                                        |
| 1215 | 1215 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";  | 
                                                        
| 1216 | 1216 |  		$query_values = array(':airport' => $airport); | 
                                                        
| 1217 | - }  | 
                                                        |
| 1217 | + }  | 
                                                        |
| 1218 | 1218 | }  | 
                                                        
| 1219 | 1219 | |
| 1220 | 1220 | if ($limit != "")  | 
                                                        
| 1221 | 1221 |  	{ | 
                                                        
| 1222 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 1222 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 1223 | 1223 | |
| 1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1224 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1225 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1226 | 1226 | |
| 1227 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1228 | -	    { | 
                                                        |
| 1227 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1228 | +		{ | 
                                                        |
| 1229 | 1229 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 1230 | 1230 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 1231 | - }  | 
                                                        |
| 1231 | + }  | 
                                                        |
| 1232 | 1232 | }  | 
                                                        
| 1233 | 1233 | |
| 1234 | 1234 | if ($sort != "")  | 
                                                        
| 1235 | 1235 |  	{ | 
                                                        
| 1236 | - $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1237 | - $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1236 | + $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1237 | + $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1238 | 1238 |  	} else { | 
                                                        
| 1239 | - $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1239 | + $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1240 | 1240 | }  | 
                                                        
| 1241 | 1241 | |
| 1242 | 1242 | $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;  | 
                                                        
@@ -1244,6 +1244,6 @@ discard block  | 
                                                    ||
| 1244 | 1244 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        
| 1245 | 1245 | |
| 1246 | 1246 | return $spotter_array;  | 
                                                        
| 1247 | - }  | 
                                                        |
| 1247 | + }  | 
                                                        |
| 1248 | 1248 | }  | 
                                                        
| 1249 | 1249 | ?>  | 
                                                        
| 1250 | 1250 | \ No newline at end of file  | 
                                                        
@@ -13,33 +13,33 @@ discard block  | 
                                                    ||
| 13 | 13 | * @param Array $filter the filter  | 
                                                        
| 14 | 14 | * @return Array the SQL part  | 
                                                        
| 15 | 15 | */  | 
                                                        
| 16 | -	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        |
| 16 | +	public function getFilter($filter = array(), $where = false, $and = false) { | 
                                                        |
| 17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
| 18 | 18 | $filters = array();  | 
                                                        
| 19 | 19 |  		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { | 
                                                        
| 20 | 20 |  			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { | 
                                                        
| 21 | 21 | $filters = $globalStatsFilters[$globalFilterName];  | 
                                                        
| 22 | 22 |  			} else { | 
                                                        
| 23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);  | 
                                                        |
| 23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);  | 
                                                        |
| 24 | 24 | }  | 
                                                        
| 25 | 25 | }  | 
                                                        
| 26 | 26 |  		if (isset($filter[0]['source'])) { | 
                                                        
| 27 | - $filters = array_merge($filters,$filter);  | 
                                                        |
| 27 | + $filters = array_merge($filters, $filter);  | 
                                                        |
| 28 | 28 | }  | 
                                                        
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);  | 
                                                        |
| 30 | 30 | $filter_query_join = '';  | 
                                                        
| 31 | 31 | $filter_query_where = '';  | 
                                                        
| 32 | -		foreach($filters as $flt) { | 
                                                        |
| 32 | +		foreach ($filters as $flt) { | 
                                                        |
| 33 | 33 |  			if (isset($flt['idents']) && !empty($flt['idents'])) { | 
                                                        
| 34 | 34 |  				if (isset($flt['source'])) { | 
                                                        
| 35 | -					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; | 
                                                        |
| 35 | +					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; | 
                                                        |
| 36 | 36 |  				} else { | 
                                                        
| 37 | -					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; | 
                                                        |
| 37 | +					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; | 
                                                        |
| 38 | 38 | }  | 
                                                        
| 39 | 39 | }  | 
                                                        
| 40 | 40 | }  | 
                                                        
| 41 | 41 |  		if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        
| 42 | -			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; | 
                                                        |
| 42 | +			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; | 
                                                        |
| 43 | 43 | }  | 
                                                        
| 44 | 44 |  		if (isset($filter['ident']) && !empty($filter['ident'])) { | 
                                                        
| 45 | 45 | $filter_query_where .= " AND ident = '".$filter['ident']."'";  | 
                                                        
@@ -67,22 +67,22 @@ discard block  | 
                                                    ||
| 67 | 67 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'";  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | -			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; | 
                                                        |
| 70 | +			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; | 
                                                        |
| 71 | 71 | }  | 
                                                        
| 72 | 72 |  		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 73 | -			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 73 | +			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; | 
                                                        |
| 74 | 74 | }  | 
                                                        
| 75 | 75 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';  | 
                                                        
| 76 | 76 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';  | 
                                                        
| 77 | 77 |  		if ($filter_query_where != '') { | 
                                                        
| 78 | -			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                        |
| 78 | +			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); | 
                                                        |
| 79 | 79 | }  | 
                                                        
| 80 | 80 | $filter_query = $filter_query_join.$filter_query_where;  | 
                                                        
| 81 | 81 | return $filter_query;  | 
                                                        
| 82 | 82 | }  | 
                                                        
| 83 | 83 | |
| 84 | 84 | // marine_archive  | 
                                                        
| 85 | -	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { | 
                                                        |
| 85 | +	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { | 
                                                        |
| 86 | 86 | /*  | 
                                                        
| 87 | 87 | require_once(dirname(__FILE__).'/class.Marine.php');  | 
                                                        
| 88 | 88 |  		if ($over_country == '') { | 
                                                        
@@ -94,16 +94,16 @@ discard block  | 
                                                    ||
| 94 | 94 | */  | 
                                                        
| 95 | 95 | $country = $over_country;  | 
                                                        
| 96 | 96 | // Route is not added in marine_archive  | 
                                                        
| 97 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date)  | 
                                                        |
| 97 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date)  | 
                                                        |
| 98 | 98 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';  | 
                                                        
| 99 | 99 | |
| 100 | -		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); | 
                                                        |
| 100 | +		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); | 
                                                        |
| 101 | 101 | |
| 102 | 102 |  		try { | 
                                                        
| 103 | 103 | $sth = $this->db->prepare($query);  | 
                                                        
| 104 | 104 | $sth->execute($query_values);  | 
                                                        
| 105 | 105 | $sth->closeCursor();  | 
                                                        
| 106 | -		} catch(PDOException $e) { | 
                                                        |
| 106 | +		} catch (PDOException $e) { | 
                                                        |
| 107 | 107 | return "error : ".$e->getMessage();  | 
                                                        
| 108 | 108 | }  | 
                                                        
| 109 | 109 | return "success";  | 
                                                        
@@ -123,9 +123,9 @@ discard block  | 
                                                    ||
| 123 | 123 | |
| 124 | 124 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 125 | 125 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        
| 126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 127 | 127 | |
| 128 | -                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); | 
                                                        |
| 128 | +                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); | 
                                                        |
| 129 | 129 | |
| 130 | 130 | return $spotter_array;  | 
                                                        
| 131 | 131 | }  | 
                                                        
@@ -144,7 +144,7 @@ discard block  | 
                                                    ||
| 144 | 144 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 145 | 145 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";  | 
                                                        
| 146 | 146 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        
| 147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 148 | 148 | |
| 149 | 149 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 150 | 150 | /*  | 
                                                        
@@ -157,7 +157,7 @@ discard block  | 
                                                    ||
| 157 | 157 | }  | 
                                                        
| 158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);  | 
                                                        
| 159 | 159 | */  | 
                                                        
| 160 | -                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        |
| 160 | +                $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); | 
                                                        |
| 161 | 161 | |
| 162 | 162 | return $spotter_array;  | 
                                                        
| 163 | 163 | }  | 
                                                        
@@ -172,14 +172,14 @@ discard block  | 
                                                    ||
| 172 | 172 |  	{ | 
                                                        
| 173 | 173 |                  date_default_timezone_set('UTC'); | 
                                                        
| 174 | 174 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 176 | 176 | |
| 177 | 177 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 178 | 178 | |
| 179 | 179 |                  try { | 
                                                        
| 180 | 180 | $sth = $this->db->prepare($query);  | 
                                                        
| 181 | 181 |                          $sth->execute(array(':id' => $id)); | 
                                                        
| 182 | -                } catch(PDOException $e) { | 
                                                        |
| 182 | +                } catch (PDOException $e) { | 
                                                        |
| 183 | 183 | echo $e->getMessage();  | 
                                                        
| 184 | 184 | die;  | 
                                                        
| 185 | 185 | }  | 
                                                        
@@ -198,14 +198,14 @@ discard block  | 
                                                    ||
| 198 | 198 |          { | 
                                                        
| 199 | 199 |                  date_default_timezone_set('UTC'); | 
                                                        
| 200 | 200 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 202 | 202 | |
| 203 | 203 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 204 | 204 | |
| 205 | 205 |                  try { | 
                                                        
| 206 | 206 | $sth = $this->db->prepare($query);  | 
                                                        
| 207 | 207 |                          $sth->execute(array(':id' => $id)); | 
                                                        
| 208 | -                } catch(PDOException $e) { | 
                                                        |
| 208 | +                } catch (PDOException $e) { | 
                                                        |
| 209 | 209 | echo $e->getMessage();  | 
                                                        
| 210 | 210 | die;  | 
                                                        
| 211 | 211 | }  | 
                                                        
@@ -227,12 +227,12 @@ discard block  | 
                                                    ||
| 227 | 227 |                  date_default_timezone_set('UTC'); | 
                                                        
| 228 | 228 | |
| 229 | 229 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 231 | 231 | |
| 232 | 232 |                  try { | 
                                                        
| 233 | 233 | $sth = $this->db->prepare($query);  | 
                                                        
| 234 | 234 |                          $sth->execute(array(':ident' => $ident)); | 
                                                        
| 235 | -                } catch(PDOException $e) { | 
                                                        |
| 235 | +                } catch (PDOException $e) { | 
                                                        |
| 236 | 236 | echo $e->getMessage();  | 
                                                        
| 237 | 237 | die;  | 
                                                        
| 238 | 238 | }  | 
                                                        
@@ -253,12 +253,12 @@ discard block  | 
                                                    ||
| 253 | 253 |                  date_default_timezone_set('UTC'); | 
                                                        
| 254 | 254 | |
| 255 | 255 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 257 | 257 | |
| 258 | 258 |                  try { | 
                                                        
| 259 | 259 | $sth = $this->db->prepare($query);  | 
                                                        
| 260 | 260 |                          $sth->execute(array(':id' => $id)); | 
                                                        
| 261 | -                } catch(PDOException $e) { | 
                                                        |
| 261 | +                } catch (PDOException $e) { | 
                                                        |
| 262 | 262 | echo $e->getMessage();  | 
                                                        
| 263 | 263 | die;  | 
                                                        
| 264 | 264 | }  | 
                                                        
@@ -279,12 +279,12 @@ discard block  | 
                                                    ||
| 279 | 279 |                  date_default_timezone_set('UTC'); | 
                                                        
| 280 | 280 | |
| 281 | 281 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 283 | 283 | |
| 284 | 284 |                  try { | 
                                                        
| 285 | 285 | $sth = $this->db->prepare($query);  | 
                                                        
| 286 | 286 |                          $sth->execute(array(':id' => $id)); | 
                                                        
| 287 | -                } catch(PDOException $e) { | 
                                                        |
| 287 | +                } catch (PDOException $e) { | 
                                                        |
| 288 | 288 | echo $e->getMessage();  | 
                                                        
| 289 | 289 | die;  | 
                                                        
| 290 | 290 | }  | 
                                                        
@@ -306,13 +306,13 @@ discard block  | 
                                                    ||
| 306 | 306 |                  date_default_timezone_set('UTC'); | 
                                                        
| 307 | 307 | |
| 308 | 308 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";  | 
                                                        
| 311 | 311 | |
| 312 | 312 |                  try { | 
                                                        
| 313 | 313 | $sth = $this->db->prepare($query);  | 
                                                        
| 314 | 314 |                          $sth->execute(array(':ident' => $ident)); | 
                                                        
| 315 | -                } catch(PDOException $e) { | 
                                                        |
| 315 | +                } catch (PDOException $e) { | 
                                                        |
| 316 | 316 | echo $e->getMessage();  | 
                                                        
| 317 | 317 | die;  | 
                                                        
| 318 | 318 | }  | 
                                                        
@@ -329,13 +329,13 @@ discard block  | 
                                                    ||
| 329 | 329 | * @return Array the spotter information  | 
                                                        
| 330 | 330 | *  | 
                                                        
| 331 | 331 | */  | 
                                                        
| 332 | - public function getMarineArchiveData($ident,$fammarine_id,$date)  | 
                                                        |
| 332 | + public function getMarineArchiveData($ident, $fammarine_id, $date)  | 
                                                        |
| 333 | 333 |          { | 
                                                        
| 334 | 334 | $Marine = new Marine($this->db);  | 
                                                        
| 335 | 335 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 336 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";  | 
                                                        |
| 336 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";  | 
                                                        |
| 337 | 337 | |
| 338 | -                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); | 
                                                        |
| 338 | +                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); | 
                                                        |
| 339 | 339 | |
| 340 | 340 | return $spotter_array;  | 
                                                        
| 341 | 341 | }  | 
                                                        
@@ -348,7 +348,7 @@ discard block  | 
                                                    ||
| 348 | 348 |                  try { | 
                                                        
| 349 | 349 | $sth = $this->db->prepare($query);  | 
                                                        
| 350 | 350 | $sth->execute();  | 
                                                        
| 351 | -                } catch(PDOException $e) { | 
                                                        |
| 351 | +                } catch (PDOException $e) { | 
                                                        |
| 352 | 352 | echo $e->getMessage();  | 
                                                        
| 353 | 353 | die;  | 
                                                        
| 354 | 354 | }  | 
                                                        
@@ -360,24 +360,24 @@ discard block  | 
                                                    ||
| 360 | 360 | * @return Array the spotter information  | 
                                                        
| 361 | 361 | *  | 
                                                        
| 362 | 362 | */  | 
                                                        
| 363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array())  | 
                                                        |
| 363 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array())  | 
                                                        |
| 364 | 364 |          { | 
                                                        
| 365 | 365 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 366 | 366 |                  date_default_timezone_set('UTC'); | 
                                                        
| 367 | 367 | |
| 368 | 368 | $filter_query = '';  | 
                                                        
| 369 | 369 |                  if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        
| 370 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 370 | +                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; | 
                                                        |
| 371 | 371 | }  | 
                                                        
| 372 | 372 | // Use spotter_output also ?  | 
                                                        
| 373 | 373 |                  if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        
| 374 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 374 | +                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 375 | 375 | }  | 
                                                        
| 376 | 376 |                  if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        
| 377 | 377 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        
| 378 | 378 | }  | 
                                                        
| 379 | 379 |                  if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 380 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 380 | +                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; | 
                                                        |
| 381 | 381 | }  | 
                                                        
| 382 | 382 | |
| 383 | 383 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
@@ -396,14 +396,14 @@ discard block  | 
                                                    ||
| 396 | 396 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id  | 
                                                        
| 397 | 397 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';  | 
                                                        
| 398 | 398 | */  | 
                                                        
| 399 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 399 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 400 | 400 | FROM marine_archive  | 
                                                        
| 401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao  | 
                                                        
| 402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".'  | 
                                                        
| 403 | 403 | '.$filter_query.' ORDER BY fammarine_id';  | 
                                                        
| 404 | 404 |                  } else { | 
                                                        
| 405 | 405 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';  | 
                                                        
| 406 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 406 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 407 | 407 | FROM marine_archive  | 
                                                        
| 408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao  | 
                                                        
| 409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'  | 
                                                        
@@ -413,7 +413,7 @@ discard block  | 
                                                    ||
| 413 | 413 |                  try { | 
                                                        
| 414 | 414 | $sth = $this->db->prepare($query);  | 
                                                        
| 415 | 415 | $sth->execute();  | 
                                                        
| 416 | -                } catch(PDOException $e) { | 
                                                        |
| 416 | +                } catch (PDOException $e) { | 
                                                        |
| 417 | 417 | echo $e->getMessage();  | 
                                                        
| 418 | 418 | die;  | 
                                                        
| 419 | 419 | }  | 
                                                        
@@ -428,24 +428,24 @@ discard block  | 
                                                    ||
| 428 | 428 | * @return Array the spotter information  | 
                                                        
| 429 | 429 | *  | 
                                                        
| 430 | 430 | */  | 
                                                        
| 431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())  | 
                                                        |
| 431 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array())  | 
                                                        |
| 432 | 432 |          { | 
                                                        
| 433 | 433 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 434 | 434 |                  date_default_timezone_set('UTC'); | 
                                                        
| 435 | 435 | |
| 436 | 436 | $filter_query = '';  | 
                                                        
| 437 | 437 |                  if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        
| 438 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 438 | +                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; | 
                                                        |
| 439 | 439 | }  | 
                                                        
| 440 | 440 | // Should use spotter_output also ?  | 
                                                        
| 441 | 441 |                  if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        
| 442 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 442 | +                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 443 | 443 | }  | 
                                                        
| 444 | 444 |                  if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        
| 445 | 445 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        
| 446 | 446 | }  | 
                                                        
| 447 | 447 |                  if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 448 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 448 | +                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; | 
                                                        |
| 449 | 449 | }  | 
                                                        
| 450 | 450 | |
| 451 | 451 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
@@ -455,7 +455,7 @@ discard block  | 
                                                    ||
| 455 | 455 | FROM marine_archive  | 
                                                        
| 456 | 456 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';  | 
                                                        
| 457 | 457 | */  | 
                                                        
| 458 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk  | 
                                                        |
| 458 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk  | 
                                                        |
| 459 | 459 | FROM marine_archive_output  | 
                                                        
| 460 | 460 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao  | 
                                                        
| 461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".')  | 
                                                        
@@ -470,7 +470,7 @@ discard block  | 
                                                    ||
| 470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'  | 
                                                        
| 471 | 471 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';  | 
                                                        
| 472 | 472 | */  | 
                                                        
| 473 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        |
| 473 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        |
| 474 | 474 | FROM marine_archive_output  | 
                                                        
| 475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao  | 
                                                        
| 476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'  | 
                                                        
@@ -482,7 +482,7 @@ discard block  | 
                                                    ||
| 482 | 482 |                  try { | 
                                                        
| 483 | 483 | $sth = $this->db->prepare($query);  | 
                                                        
| 484 | 484 | $sth->execute();  | 
                                                        
| 485 | -                } catch(PDOException $e) { | 
                                                        |
| 485 | +                } catch (PDOException $e) { | 
                                                        |
| 486 | 486 | echo $e->getMessage();  | 
                                                        
| 487 | 487 | die;  | 
                                                        
| 488 | 488 | }  | 
                                                        
@@ -497,23 +497,23 @@ discard block  | 
                                                    ||
| 497 | 497 | * @return Array the spotter information  | 
                                                        
| 498 | 498 | *  | 
                                                        
| 499 | 499 | */  | 
                                                        
| 500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array())  | 
                                                        |
| 500 | + public function getLiveMarineCount($begindate, $enddate, $filter = array())  | 
                                                        |
| 501 | 501 |          { | 
                                                        
| 502 | 502 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 503 | 503 |                  date_default_timezone_set('UTC'); | 
                                                        
| 504 | 504 | |
| 505 | 505 | $filter_query = '';  | 
                                                        
| 506 | 506 |                  if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        
| 507 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 507 | +                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; | 
                                                        |
| 508 | 508 | }  | 
                                                        
| 509 | 509 |                  if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        
| 510 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 510 | +                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 511 | 511 | }  | 
                                                        
| 512 | 512 |                  if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        
| 513 | 513 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        
| 514 | 514 | }  | 
                                                        
| 515 | 515 |                  if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 516 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 516 | +                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; | 
                                                        |
| 517 | 517 | }  | 
                                                        
| 518 | 518 | |
| 519 | 519 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
@@ -528,7 +528,7 @@ discard block  | 
                                                    ||
| 528 | 528 |                  try { | 
                                                        
| 529 | 529 | $sth = $this->db->prepare($query);  | 
                                                        
| 530 | 530 | $sth->execute();  | 
                                                        
| 531 | -                } catch(PDOException $e) { | 
                                                        |
| 531 | +                } catch (PDOException $e) { | 
                                                        |
| 532 | 532 | echo $e->getMessage();  | 
                                                        
| 533 | 533 | die;  | 
                                                        
| 534 | 534 | }  | 
                                                        
@@ -548,7 +548,7 @@ discard block  | 
                                                    ||
| 548 | 548 | * @return Array the spotter information  | 
                                                        
| 549 | 549 | *  | 
                                                        
| 550 | 550 | */  | 
                                                        
| 551 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())  | 
                                                        |
| 551 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())  | 
                                                        |
| 552 | 552 |      { | 
                                                        
| 553 | 553 | global $globalTimezone, $globalDBdriver;  | 
                                                        
| 554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php');  | 
                                                        
@@ -570,7 +570,7 @@ discard block  | 
                                                    ||
| 570 | 570 | |
| 571 | 571 |  		$q_array = explode(" ", $q); | 
                                                        
| 572 | 572 | |
| 573 | -		foreach ($q_array as $q_item){ | 
                                                        |
| 573 | +		foreach ($q_array as $q_item) { | 
                                                        |
| 574 | 574 |  		    $additional_query .= " AND ("; | 
                                                        
| 575 | 575 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";  | 
                                                        
| 576 | 576 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";  | 
                                                        
@@ -602,7 +602,7 @@ discard block  | 
                                                    ||
| 602 | 602 | |
| 603 | 603 | if ($registration != "")  | 
                                                        
| 604 | 604 |  	{ | 
                                                        
| 605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING);  | 
                                                        |
| 605 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING);  | 
                                                        |
| 606 | 606 | if (!is_string($registration))  | 
                                                        
| 607 | 607 |  	    { | 
                                                        
| 608 | 608 | return false;  | 
                                                        
@@ -613,7 +613,7 @@ discard block  | 
                                                    ||
| 613 | 613 | |
| 614 | 614 | if ($aircraft_icao != "")  | 
                                                        
| 615 | 615 |  	{ | 
                                                        
| 616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 616 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);  | 
                                                        |
| 617 | 617 | if (!is_string($aircraft_icao))  | 
                                                        
| 618 | 618 |  	    { | 
                                                        
| 619 | 619 | return false;  | 
                                                        
@@ -624,7 +624,7 @@ discard block  | 
                                                    ||
| 624 | 624 | |
| 625 | 625 | if ($aircraft_manufacturer != "")  | 
                                                        
| 626 | 626 |  	{ | 
                                                        
| 627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);  | 
                                                        |
| 627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);  | 
                                                        |
| 628 | 628 | if (!is_string($aircraft_manufacturer))  | 
                                                        
| 629 | 629 |  	    { | 
                                                        
| 630 | 630 | return false;  | 
                                                        
@@ -645,7 +645,7 @@ discard block  | 
                                                    ||
| 645 | 645 | |
| 646 | 646 | if ($airline_icao != "")  | 
                                                        
| 647 | 647 |  	{ | 
                                                        
| 648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 648 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);  | 
                                                        |
| 649 | 649 | if (!is_string($airline_icao))  | 
                                                        
| 650 | 650 |  	    { | 
                                                        
| 651 | 651 | return false;  | 
                                                        
@@ -656,7 +656,7 @@ discard block  | 
                                                    ||
| 656 | 656 | |
| 657 | 657 | if ($airline_country != "")  | 
                                                        
| 658 | 658 |  	{ | 
                                                        
| 659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 659 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);  | 
                                                        |
| 660 | 660 | if (!is_string($airline_country))  | 
                                                        
| 661 | 661 |  	    { | 
                                                        
| 662 | 662 | return false;  | 
                                                        
@@ -667,7 +667,7 @@ discard block  | 
                                                    ||
| 667 | 667 | |
| 668 | 668 | if ($airline_type != "")  | 
                                                        
| 669 | 669 |  	{ | 
                                                        
| 670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);  | 
                                                        |
| 670 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);  | 
                                                        |
| 671 | 671 | if (!is_string($airline_type))  | 
                                                        
| 672 | 672 |  	    { | 
                                                        
| 673 | 673 | return false;  | 
                                                        
@@ -689,7 +689,7 @@ discard block  | 
                                                    ||
| 689 | 689 | |
| 690 | 690 | if ($airport != "")  | 
                                                        
| 691 | 691 |  	{ | 
                                                        
| 692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING);  | 
                                                        |
| 692 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING);  | 
                                                        |
| 693 | 693 | if (!is_string($airport))  | 
                                                        
| 694 | 694 |  	    { | 
                                                        
| 695 | 695 | return false;  | 
                                                        
@@ -700,7 +700,7 @@ discard block  | 
                                                    ||
| 700 | 700 | |
| 701 | 701 | if ($airport_country != "")  | 
                                                        
| 702 | 702 |  	{ | 
                                                        
| 703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 703 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);  | 
                                                        |
| 704 | 704 | if (!is_string($airport_country))  | 
                                                        
| 705 | 705 |  	    { | 
                                                        
| 706 | 706 | return false;  | 
                                                        
@@ -711,7 +711,7 @@ discard block  | 
                                                    ||
| 711 | 711 | |
| 712 | 712 | if ($callsign != "")  | 
                                                        
| 713 | 713 |  	{ | 
                                                        
| 714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);  | 
                                                        |
| 714 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);  | 
                                                        |
| 715 | 715 | if (!is_string($callsign))  | 
                                                        
| 716 | 716 |  	    { | 
                                                        
| 717 | 717 | return false;  | 
                                                        
@@ -719,7 +719,7 @@ discard block  | 
                                                    ||
| 719 | 719 | $translate = $Translation->ident2icao($callsign);  | 
                                                        
| 720 | 720 |  		if ($translate != $callsign) { | 
                                                        
| 721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";  | 
                                                        
| 722 | -			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); | 
                                                        |
| 722 | +			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); | 
                                                        |
| 723 | 723 |  		} else { | 
                                                        
| 724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";  | 
                                                        
| 725 | 725 | }  | 
                                                        
@@ -728,7 +728,7 @@ discard block  | 
                                                    ||
| 728 | 728 | |
| 729 | 729 | if ($owner != "")  | 
                                                        
| 730 | 730 |  	{ | 
                                                        
| 731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING);  | 
                                                        |
| 731 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING);  | 
                                                        |
| 732 | 732 | if (!is_string($owner))  | 
                                                        
| 733 | 733 |  	    { | 
                                                        
| 734 | 734 | return false;  | 
                                                        
@@ -739,7 +739,7 @@ discard block  | 
                                                    ||
| 739 | 739 | |
| 740 | 740 | if ($pilot_name != "")  | 
                                                        
| 741 | 741 |  	{ | 
                                                        
| 742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);  | 
                                                        |
| 742 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);  | 
                                                        |
| 743 | 743 | if (!is_string($pilot_name))  | 
                                                        
| 744 | 744 |  	    { | 
                                                        
| 745 | 745 | return false;  | 
                                                        
@@ -750,7 +750,7 @@ discard block  | 
                                                    ||
| 750 | 750 | |
| 751 | 751 | if ($pilot_id != "")  | 
                                                        
| 752 | 752 |  	{ | 
                                                        
| 753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 753 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 754 | 754 | if (!is_string($pilot_id))  | 
                                                        
| 755 | 755 |  	    { | 
                                                        
| 756 | 756 | return false;  | 
                                                        
@@ -761,7 +761,7 @@ discard block  | 
                                                    ||
| 761 | 761 | |
| 762 | 762 | if ($departure_airport_route != "")  | 
                                                        
| 763 | 763 |  	{ | 
                                                        
| 764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 764 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);  | 
                                                        |
| 765 | 765 | if (!is_string($departure_airport_route))  | 
                                                        
| 766 | 766 |  	    { | 
                                                        
| 767 | 767 | return false;  | 
                                                        
@@ -772,7 +772,7 @@ discard block  | 
                                                    ||
| 772 | 772 | |
| 773 | 773 | if ($arrival_airport_route != "")  | 
                                                        
| 774 | 774 |  	{ | 
                                                        
| 775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 775 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);  | 
                                                        |
| 776 | 776 | if (!is_string($arrival_airport_route))  | 
                                                        
| 777 | 777 |  	    { | 
                                                        
| 778 | 778 | return false;  | 
                                                        
@@ -785,8 +785,8 @@ discard block  | 
                                                    ||
| 785 | 785 |  	{ | 
                                                        
| 786 | 786 |  	    $altitude_array = explode(",", $altitude); | 
                                                        
| 787 | 787 | |
| 788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 788 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 789 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 790 | 790 | |
| 791 | 791 | |
| 792 | 792 | if ($altitude_array[1] != "")  | 
                                                        
@@ -804,8 +804,8 @@ discard block  | 
                                                    ||
| 804 | 804 |  	{ | 
                                                        
| 805 | 805 |  	    $date_array = explode(",", $date_posted); | 
                                                        
| 806 | 806 | |
| 807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);  | 
                                                        |
| 808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);  | 
                                                        |
| 807 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);  | 
                                                        |
| 808 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);  | 
                                                        |
| 809 | 809 | |
| 810 | 810 |  	    if ($globalTimezone != '') { | 
                                                        
| 811 | 811 | date_default_timezone_set($globalTimezone);  | 
                                                        
@@ -837,8 +837,8 @@ discard block  | 
                                                    ||
| 837 | 837 |  	{ | 
                                                        
| 838 | 838 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 839 | 839 | |
| 840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 840 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 841 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 842 | 842 | |
| 843 | 843 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 844 | 844 |  	    { | 
                                                        
@@ -849,8 +849,8 @@ discard block  | 
                                                    ||
| 849 | 849 | |
| 850 | 850 | |
| 851 | 851 |  	if ($origLat != "" && $origLon != "" && $dist != "") { | 
                                                        
| 852 | - $dist = number_format($dist*0.621371,2,'.','');  | 
                                                        |
| 853 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance  | 
                                                        |
| 852 | + $dist = number_format($dist*0.621371, 2, '.', '');  | 
                                                        |
| 853 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance  | 
                                                        |
| 854 | 854 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
                                                        
| 855 | 855 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";  | 
                                                        
| 856 | 856 |  	} else { | 
                                                        
@@ -867,12 +867,12 @@ discard block  | 
                                                    ||
| 867 | 867 | $additional_query .= " AND (marine_archive_output.waypoints <> '')";  | 
                                                        
| 868 | 868 | }  | 
                                                        
| 869 | 869 | |
| 870 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output  | 
                                                        |
| 870 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output  | 
                                                        |
| 871 | 871 | WHERE marine_archive_output.ident <> ''  | 
                                                        
| 872 | 872 | ".$additional_query."  | 
                                                        
| 873 | 873 | ".$filter_query.$orderby_query;  | 
                                                        
| 874 | 874 | }  | 
                                                        
| 875 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);  | 
                                                        |
| 875 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        |
| 876 | 876 | |
| 877 | 877 | return $spotter_array;  | 
                                                        
| 878 | 878 | }  | 
                                                        
@@ -889,7 +889,7 @@ discard block  | 
                                                    ||
| 889 | 889 |                  try { | 
                                                        
| 890 | 890 | $sth = $this->db->prepare($query);  | 
                                                        
| 891 | 891 | $sth->execute();  | 
                                                        
| 892 | -                } catch(PDOException $e) { | 
                                                        |
| 892 | +                } catch (PDOException $e) { | 
                                                        |
| 893 | 893 | return "error";  | 
                                                        
| 894 | 894 | }  | 
                                                        
| 895 | 895 | }  | 
                                                        
@@ -926,8 +926,8 @@ discard block  | 
                                                    ||
| 926 | 926 |  	{ | 
                                                        
| 927 | 927 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 928 | 928 | |
| 929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 929 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 930 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 931 | 931 | |
| 932 | 932 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 933 | 933 |  	    { | 
                                                        
@@ -968,7 +968,7 @@ discard block  | 
                                                    ||
| 968 | 968 | $query_values = array();  | 
                                                        
| 969 | 969 | $limit_query = '';  | 
                                                        
| 970 | 970 | $additional_query = '';  | 
                                                        
| 971 | - $filter_query = $this->getFilter($filter,true,true);  | 
                                                        |
| 971 | + $filter_query = $this->getFilter($filter, true, true);  | 
                                                        |
| 972 | 972 | |
| 973 | 973 | if ($owner != "")  | 
                                                        
| 974 | 974 |  	{ | 
                                                        
@@ -985,8 +985,8 @@ discard block  | 
                                                    ||
| 985 | 985 |  	{ | 
                                                        
| 986 | 986 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 987 | 987 | |
| 988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 988 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 989 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 990 | 990 | |
| 991 | 991 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 992 | 992 |  	    { | 
                                                        
@@ -1026,7 +1026,7 @@ discard block  | 
                                                    ||
| 1026 | 1026 | $query_values = array();  | 
                                                        
| 1027 | 1027 | $limit_query = '';  | 
                                                        
| 1028 | 1028 | $additional_query = '';  | 
                                                        
| 1029 | - $filter_query = $this->getFilter($filter,true,true);  | 
                                                        |
| 1029 | + $filter_query = $this->getFilter($filter, true, true);  | 
                                                        |
| 1030 | 1030 | |
| 1031 | 1031 | if ($pilot != "")  | 
                                                        
| 1032 | 1032 |  	{ | 
                                                        
@@ -1038,8 +1038,8 @@ discard block  | 
                                                    ||
| 1038 | 1038 |  	{ | 
                                                        
| 1039 | 1039 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 1040 | 1040 | |
| 1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1041 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1042 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1043 | 1043 | |
| 1044 | 1044 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 1045 | 1045 |  	    { | 
                                                        
@@ -1069,7 +1069,7 @@ discard block  | 
                                                    ||
| 1069 | 1069 | * @return Array the airline country list  | 
                                                        
| 1070 | 1070 | *  | 
                                                        
| 1071 | 1071 | */  | 
                                                        
| 1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1072 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')  | 
                                                        |
| 1073 | 1073 |      { | 
                                                        
| 1074 | 1074 | global $globalDBdriver;  | 
                                                        
| 1075 | 1075 | /*  | 
                                                        
@@ -1098,7 +1098,7 @@ discard block  | 
                                                    ||
| 1098 | 1098 | $flight_array = array();  | 
                                                        
| 1099 | 1099 | $temp_array = array();  | 
                                                        
| 1100 | 1100 | |
| 1101 | - while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 1101 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 1102 | 1102 |  	{ | 
                                                        
| 1103 | 1103 | $temp_array['flight_count'] = $row['nb'];  | 
                                                        
| 1104 | 1104 | $temp_array['flight_country'] = $row['name'];  | 
                                                        
@@ -1115,7 +1115,7 @@ discard block  | 
                                                    ||
| 1115 | 1115 | * @return Array the airline country list  | 
                                                        
| 1116 | 1116 | *  | 
                                                        
| 1117 | 1117 | */  | 
                                                        
| 1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1118 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')  | 
                                                        |
| 1119 | 1119 |      { | 
                                                        
| 1120 | 1120 | global $globalDBdriver;  | 
                                                        
| 1121 | 1121 | /*  | 
                                                        
@@ -1144,7 +1144,7 @@ discard block  | 
                                                    ||
| 1144 | 1144 | $flight_array = array();  | 
                                                        
| 1145 | 1145 | $temp_array = array();  | 
                                                        
| 1146 | 1146 | |
| 1147 | - while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 1147 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 1148 | 1148 |  	{ | 
                                                        
| 1149 | 1149 | $temp_array['airline_icao'] = $row['airline_icao'];  | 
                                                        
| 1150 | 1150 | $temp_array['flight_count'] = $row['nb'];  | 
                                                        
@@ -1162,14 +1162,14 @@ discard block  | 
                                                    ||
| 1162 | 1162 | * @return Array the spotter information  | 
                                                        
| 1163 | 1163 | *  | 
                                                        
| 1164 | 1164 | */  | 
                                                        
| 1165 | - public function getDateArchiveMarineDataById($id,$date)  | 
                                                        |
| 1165 | + public function getDateArchiveMarineDataById($id, $date)  | 
                                                        |
| 1166 | 1166 |      { | 
                                                        
| 1167 | 1167 | $Marine = new Marine($this->db);  | 
                                                        
| 1168 | 1168 |  	date_default_timezone_set('UTC'); | 
                                                        
| 1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 1170 | 1170 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';  | 
                                                        
| 1171 | -	$date = date('c',$date); | 
                                                        |
| 1172 | -	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); | 
                                                        |
| 1171 | +	$date = date('c', $date); | 
                                                        |
| 1172 | +	$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); | 
                                                        |
| 1173 | 1173 | return $spotter_array;  | 
                                                        
| 1174 | 1174 | }  | 
                                                        
| 1175 | 1175 | |
@@ -1179,14 +1179,14 @@ discard block  | 
                                                    ||
| 1179 | 1179 | * @return Array the spotter information  | 
                                                        
| 1180 | 1180 | *  | 
                                                        
| 1181 | 1181 | */  | 
                                                        
| 1182 | - public function getDateArchiveMarineDataByIdent($ident,$date)  | 
                                                        |
| 1182 | + public function getDateArchiveMarineDataByIdent($ident, $date)  | 
                                                        |
| 1183 | 1183 |      { | 
                                                        
| 1184 | 1184 | $Marine = new Marine($this->db);  | 
                                                        
| 1185 | 1185 |  	date_default_timezone_set('UTC'); | 
                                                        
| 1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 1187 | 1187 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';  | 
                                                        
| 1188 | -	$date = date('c',$date); | 
                                                        |
| 1189 | -	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); | 
                                                        |
| 1188 | +	$date = date('c', $date); | 
                                                        |
| 1189 | +	$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); | 
                                                        |
| 1190 | 1190 | return $spotter_array;  | 
                                                        
| 1191 | 1191 | }  | 
                                                        
| 1192 | 1192 | |
@@ -1196,7 +1196,7 @@ discard block  | 
                                                    ||
| 1196 | 1196 | * @return Array the spotter information  | 
                                                        
| 1197 | 1197 | *  | 
                                                        
| 1198 | 1198 | */  | 
                                                        
| 1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())  | 
                                                        |
| 1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())  | 
                                                        |
| 1200 | 1200 |      { | 
                                                        
| 1201 | 1201 | global $global_query;  | 
                                                        
| 1202 | 1202 | $Marine = new Marine();  | 
                                                        
@@ -1204,7 +1204,7 @@ discard block  | 
                                                    ||
| 1204 | 1204 | $query_values = array();  | 
                                                        
| 1205 | 1205 | $limit_query = '';  | 
                                                        
| 1206 | 1206 | $additional_query = '';  | 
                                                        
| 1207 | - $filter_query = $this->getFilter($filters,true,true);  | 
                                                        |
| 1207 | + $filter_query = $this->getFilter($filters, true, true);  | 
                                                        |
| 1208 | 1208 | |
| 1209 | 1209 | if ($airport != "")  | 
                                                        
| 1210 | 1210 |  	{ | 
                                                        
@@ -1221,8 +1221,8 @@ discard block  | 
                                                    ||
| 1221 | 1221 |  	{ | 
                                                        
| 1222 | 1222 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 1223 | 1223 | |
| 1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1224 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1225 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1226 | 1226 | |
| 1227 | 1227 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 1228 | 1228 |  	    { | 
                                                        
@@ -26,7 +26,9 @@ discard block  | 
                                                    ||
| 26 | 26 |  		if (isset($filter[0]['source'])) { | 
                                                        
| 27 | 27 | $filters = array_merge($filters,$filter);  | 
                                                        
| 28 | 28 | }  | 
                                                        
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 29 | +		if (is_array($globalFilter)) { | 
                                                        |
| 30 | + $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 31 | + }  | 
                                                        |
| 30 | 32 | $filter_query_join = '';  | 
                                                        
| 31 | 33 | $filter_query_where = '';  | 
                                                        
| 32 | 34 |  		foreach($filters as $flt) { | 
                                                        
@@ -72,8 +74,11 @@ discard block  | 
                                                    ||
| 72 | 74 |  		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 73 | 75 |  			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        
| 74 | 76 | }  | 
                                                        
| 75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';  | 
                                                        |
| 76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';  | 
                                                        |
| 77 | +		if ($filter_query_where == '' && $where) { | 
                                                        |
| 78 | + $filter_query_where = ' WHERE';  | 
                                                        |
| 79 | +		} elseif ($filter_query_where != '' && $and) { | 
                                                        |
| 80 | + $filter_query_where .= ' AND';  | 
                                                        |
| 81 | + }  | 
                                                        |
| 77 | 82 |  		if ($filter_query_where != '') { | 
                                                        
| 78 | 83 |  			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                        
| 79 | 84 | }  | 
                                                        
@@ -593,7 +598,9 @@ discard block  | 
                                                    ||
| 593 | 598 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";  | 
                                                        
| 594 | 599 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";  | 
                                                        
| 595 | 600 | $translate = $Translation->ident2icao($q_item);  | 
                                                        
| 596 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";  | 
                                                        |
| 601 | +		    if ($translate != $q_item) { | 
                                                        |
| 602 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";  | 
                                                        |
| 603 | + }  | 
                                                        |
| 597 | 604 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";  | 
                                                        
| 598 | 605 | $additional_query .= ")";  | 
                                                        
| 599 | 606 | }  | 
                                                        
@@ -811,7 +818,9 @@ discard block  | 
                                                    ||
| 811 | 818 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 812 | 819 | $datetime = new DateTime();  | 
                                                        
| 813 | 820 |  		$offset = $datetime->format('P'); | 
                                                        
| 814 | - } else $offset = '+00:00';  | 
                                                        |
| 821 | +	    } else { | 
                                                        |
| 822 | + $offset = '+00:00';  | 
                                                        |
| 823 | + }  | 
                                                        |
| 815 | 824 | |
| 816 | 825 | |
| 817 | 826 | if ($date_array[1] != "")  | 
                                                        
@@ -1087,9 +1096,13 @@ discard block  | 
                                                    ||
| 1087 | 1096 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        
| 1088 | 1097 | }  | 
                                                        
| 1089 | 1098 | }  | 
                                                        
| 1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";  | 
                                                        |
| 1099 | +                if ($sincedate != '') { | 
                                                        |
| 1100 | + $query .= "AND date > '".$sincedate."' ";  | 
                                                        |
| 1101 | + }  | 
                                                        |
| 1091 | 1102 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";  | 
                                                        
| 1092 | - if ($limit) $query .= " LIMIT 0,10";  | 
                                                        |
| 1103 | +	if ($limit) { | 
                                                        |
| 1104 | + $query .= " LIMIT 0,10";  | 
                                                        |
| 1105 | + }  | 
                                                        |
| 1093 | 1106 | |
| 1094 | 1107 | |
| 1095 | 1108 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -1133,9 +1146,13 @@ discard block  | 
                                                    ||
| 1133 | 1146 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        
| 1134 | 1147 | }  | 
                                                        
| 1135 | 1148 | }  | 
                                                        
| 1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";  | 
                                                        |
| 1149 | +                if ($sincedate != '') { | 
                                                        |
| 1150 | + $query .= "AND s.date > '".$sincedate."' ";  | 
                                                        |
| 1151 | + }  | 
                                                        |
| 1137 | 1152 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";  | 
                                                        
| 1138 | - if ($limit) $query .= " LIMIT 0,10";  | 
                                                        |
| 1153 | +	if ($limit) { | 
                                                        |
| 1154 | + $query .= " LIMIT 0,10";  | 
                                                        |
| 1155 | + }  | 
                                                        |
| 1139 | 1156 | |
| 1140 | 1157 | |
| 1141 | 1158 | $sth = $this->db->prepare($query);  |