@@ -6,6 +6,9 @@ discard block |
||
| 6 | 6 | public $dbs = array(); |
| 7 | 7 | public $latest_schema = 38; |
| 8 | 8 | |
| 9 | + /** |
|
| 10 | + * @param string $dbname |
|
| 11 | + */ |
|
| 9 | 12 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
| 10 | 13 | global $globalDBdriver, $globalNoDB; |
| 11 | 14 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
@@ -141,6 +144,9 @@ discard block |
||
| 141 | 144 | return true; |
| 142 | 145 | } |
| 143 | 146 | |
| 147 | + /** |
|
| 148 | + * @param string $table |
|
| 149 | + */ |
|
| 144 | 150 | public function tableExists($table) |
| 145 | 151 | { |
| 146 | 152 | global $globalDBdriver, $globalDBname; |
@@ -190,6 +196,11 @@ discard block |
||
| 190 | 196 | /* |
| 191 | 197 | * Check if index exist |
| 192 | 198 | */ |
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * @param string $table |
|
| 202 | + * @param string $index |
|
| 203 | + */ |
|
| 193 | 204 | public function indexExists($table,$index) |
| 194 | 205 | { |
| 195 | 206 | global $globalDBdriver, $globalDBname; |
@@ -232,6 +243,10 @@ discard block |
||
| 232 | 243 | return $columns; |
| 233 | 244 | } |
| 234 | 245 | |
| 246 | + /** |
|
| 247 | + * @param string $table |
|
| 248 | + * @param string $column |
|
| 249 | + */ |
|
| 235 | 250 | public function getColumnType($table,$column) { |
| 236 | 251 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 237 | 252 | $tomet = $select->getColumnMeta(0); |
@@ -242,6 +257,11 @@ discard block |
||
| 242 | 257 | * Check if a column name exist in a table |
| 243 | 258 | * @return Boolean column exist or not |
| 244 | 259 | */ |
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * @param string $table |
|
| 263 | + * @param string $name |
|
| 264 | + */ |
|
| 245 | 265 | public function checkColumnName($table,$name) |
| 246 | 266 | { |
| 247 | 267 | global $globalDBdriver, $globalDBname; |
@@ -7,35 +7,35 @@ discard block |
||
| 7 | 7 | public $latest_schema = 38; |
| 8 | 8 | |
| 9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
| 10 | - global $globalDBdriver, $globalNoDB; |
|
| 11 | - if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
| 10 | + global $globalDBdriver, $globalNoDB; |
|
| 11 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
| 12 | 12 | $this->db = null; |
| 13 | - } else { |
|
| 13 | + } else { |
|
| 14 | 14 | if ($dbc === null) { |
| 15 | - if ($this->db === null && $dbname === null) { |
|
| 15 | + if ($this->db === null && $dbname === null) { |
|
| 16 | 16 | if ($user === null && $pass === null) { |
| 17 | - $this->createDBConnection(); |
|
| 17 | + $this->createDBConnection(); |
|
| 18 | 18 | } else { |
| 19 | - $this->createDBConnection(null,$user,$pass); |
|
| 19 | + $this->createDBConnection(null,$user,$pass); |
|
| 20 | 20 | } |
| 21 | - } else { |
|
| 21 | + } else { |
|
| 22 | 22 | $this->createDBConnection($dbname); |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | } elseif ($dbname === null || $dbname === 'default') { |
| 25 | - $this->db = $dbc; |
|
| 26 | - if ($this->connectionExists() === false) { |
|
| 25 | + $this->db = $dbc; |
|
| 26 | + if ($this->connectionExists() === false) { |
|
| 27 | 27 | /* |
| 28 | 28 | echo 'Restart Connection !!!'."\n"; |
| 29 | 29 | $e = new \Exception; |
| 30 | 30 | var_dump($e->getTraceAsString()); |
| 31 | 31 | */ |
| 32 | 32 | $this->createDBConnection(); |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | } else { |
| 35 | - //$this->connectionExists(); |
|
| 36 | - $this->dbs[$dbname] = $dbc; |
|
| 35 | + //$this->connectionExists(); |
|
| 36 | + $this->dbs[$dbname] = $dbc; |
|
| 37 | + } |
|
| 37 | 38 | } |
| 38 | - } |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function db() { |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * Creates the database connection |
|
| 60 | - * |
|
| 61 | - * @return Boolean of the database connection |
|
| 62 | - * |
|
| 63 | - */ |
|
| 59 | + * Creates the database connection |
|
| 60 | + * |
|
| 61 | + * @return Boolean of the database connection |
|
| 62 | + * |
|
| 63 | + */ |
|
| 64 | 64 | |
| 65 | 65 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
| 66 | 66 | { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | 159 | if($results->rowCount()>0) { |
| 160 | - return true; |
|
| 160 | + return true; |
|
| 161 | 161 | } |
| 162 | 162 | else return false; |
| 163 | 163 | } |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | $sum = $sum->fetchColumn(0); |
| 175 | 175 | } else $sum = 0; |
| 176 | 176 | if (intval($sum) !== 2) { |
| 177 | - return false; |
|
| 177 | + return false; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | } catch(PDOException $e) { |
| 181 | 181 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
| 182 | - throw $e; |
|
| 183 | - } |
|
| 184 | - //echo 'error ! '.$e->getMessage(); |
|
| 182 | + throw $e; |
|
| 183 | + } |
|
| 184 | + //echo 'error ! '.$e->getMessage(); |
|
| 185 | 185 | return false; |
| 186 | 186 | } |
| 187 | 187 | return true; |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | $version = 0; |
| 286 | 286 | if ($this->tableExists('aircraft')) { |
| 287 | 287 | if (!$this->tableExists('config')) { |
| 288 | - $version = '1'; |
|
| 289 | - return $version; |
|
| 288 | + $version = '1'; |
|
| 289 | + return $version; |
|
| 290 | 290 | } else { |
| 291 | 291 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
| 292 | 292 | try { |
@@ -307,10 +307,10 @@ discard block |
||
| 307 | 307 | * @return Boolean if latest version or not |
| 308 | 308 | */ |
| 309 | 309 | public function latest() { |
| 310 | - global $globalNoDB; |
|
| 311 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 312 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 313 | - else return false; |
|
| 310 | + global $globalNoDB; |
|
| 311 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 312 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 313 | + else return false; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | } |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
| 3 | 3 | |
| 4 | -class Connection{ |
|
| 4 | +class Connection { |
|
| 5 | 5 | public $db = null; |
| 6 | 6 | public $dbs = array(); |
| 7 | 7 | public $latest_schema = 38; |
| 8 | 8 | |
| 9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
| 9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
| 10 | 10 | global $globalDBdriver, $globalNoDB; |
| 11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
| 12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | if ($user === null && $pass === null) { |
| 17 | 17 | $this->createDBConnection(); |
| 18 | 18 | } else { |
| 19 | - $this->createDBConnection(null,$user,$pass); |
|
| 19 | + $this->createDBConnection(null, $user, $pass); |
|
| 20 | 20 | } |
| 21 | 21 | } else { |
| 22 | 22 | $this->createDBConnection($dbname); |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | while (true) { |
| 101 | 101 | try { |
| 102 | 102 | if ($globalDBSdriver == 'mysql') { |
| 103 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 103 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
| 108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -117,19 +117,19 @@ discard block |
||
| 117 | 117 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
| 118 | 118 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
| 119 | 119 | } else { |
| 120 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 120 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
| 125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 129 | 129 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
| 130 | 130 | } |
| 131 | 131 | break; |
| 132 | - } catch(PDOException $e) { |
|
| 132 | + } catch (PDOException $e) { |
|
| 133 | 133 | $i++; |
| 134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
| 135 | 135 | //exit; |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | try { |
| 154 | 154 | //$Connection = new Connection(); |
| 155 | 155 | $results = $this->db->query($query); |
| 156 | - } catch(PDOException $e) { |
|
| 156 | + } catch (PDOException $e) { |
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | - if($results->rowCount()>0) { |
|
| 159 | + if ($results->rowCount() > 0) { |
|
| 160 | 160 | return true; |
| 161 | 161 | } |
| 162 | 162 | else return false; |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - } catch(PDOException $e) { |
|
| 181 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 180 | + } catch (PDOException $e) { |
|
| 181 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 182 | 182 | throw $e; |
| 183 | 183 | } |
| 184 | 184 | //echo 'error ! '.$e->getMessage(); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | /* |
| 191 | 191 | * Check if index exist |
| 192 | 192 | */ |
| 193 | - public function indexExists($table,$index) |
|
| 193 | + public function indexExists($table, $index) |
|
| 194 | 194 | { |
| 195 | 195 | global $globalDBdriver, $globalDBname; |
| 196 | 196 | if ($globalDBdriver == 'mysql') { |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | try { |
| 202 | 202 | //$Connection = new Connection(); |
| 203 | 203 | $results = $this->db->query($query); |
| 204 | - } catch(PDOException $e) { |
|
| 204 | + } catch (PDOException $e) { |
|
| 205 | 205 | return false; |
| 206 | 206 | } |
| 207 | 207 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
| 208 | - if($nb[0]['nb'] > 0) { |
|
| 208 | + if ($nb[0]['nb'] > 0) { |
|
| 209 | 209 | return true; |
| 210 | 210 | } |
| 211 | 211 | else return false; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 221 | 221 | try { |
| 222 | 222 | $results = $this->db->query($query); |
| 223 | - } catch(PDOException $e) { |
|
| 223 | + } catch (PDOException $e) { |
|
| 224 | 224 | return "error : ".$e->getMessage()."\n"; |
| 225 | 225 | } |
| 226 | 226 | $columns = array(); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | return $columns; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - public function getColumnType($table,$column) { |
|
| 235 | + public function getColumnType($table, $column) { |
|
| 236 | 236 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 237 | 237 | $tomet = $select->getColumnMeta(0); |
| 238 | 238 | return $tomet['native_type']; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * Check if a column name exist in a table |
| 243 | 243 | * @return Boolean column exist or not |
| 244 | 244 | */ |
| 245 | - public function checkColumnName($table,$name) |
|
| 245 | + public function checkColumnName($table, $name) |
|
| 246 | 246 | { |
| 247 | 247 | global $globalDBdriver, $globalDBname; |
| 248 | 248 | if ($globalDBdriver == 'mysql') { |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | try { |
| 254 | 254 | $sth = $this->db()->prepare($query); |
| 255 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
| 256 | - } catch(PDOException $e) { |
|
| 255 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
| 256 | + } catch (PDOException $e) { |
|
| 257 | 257 | echo "error : ".$e->getMessage()."\n"; |
| 258 | 258 | } |
| 259 | 259 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | try { |
| 293 | 293 | $sth = $this->db->prepare($query); |
| 294 | 294 | $sth->execute(); |
| 295 | - } catch(PDOException $e) { |
|
| 295 | + } catch (PDOException $e) { |
|
| 296 | 296 | return "error : ".$e->getMessage()."\n"; |
| 297 | 297 | } |
| 298 | 298 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -254,6 +254,7 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @param String $aircraft_registration the registration of the aircraft |
| 256 | 256 | * @param String $aircraft_name type of the aircraft |
| 257 | + * @param string $type |
|
| 257 | 258 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 258 | 259 | * |
| 259 | 260 | */ |
@@ -287,6 +288,7 @@ discard block |
||
| 287 | 288 | * |
| 288 | 289 | * @param String $registration the registration of the aircraft |
| 289 | 290 | * @param String $name type of the aircraft |
| 291 | + * @param string $type |
|
| 290 | 292 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 291 | 293 | * |
| 292 | 294 | */ |
@@ -325,6 +327,7 @@ discard block |
||
| 325 | 327 | * |
| 326 | 328 | * @param String $aircraft_registration the registration of the aircraft |
| 327 | 329 | * @param String $aircraft_name type of the aircraft |
| 330 | + * @param string $type |
|
| 328 | 331 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 329 | 332 | * |
| 330 | 333 | */ |
@@ -367,6 +370,7 @@ discard block |
||
| 367 | 370 | * |
| 368 | 371 | * @param String $aircraft_registration the registration of the aircraft |
| 369 | 372 | * @param String $aircraft_name type of the aircraft |
| 373 | + * @param string $type |
|
| 370 | 374 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 371 | 375 | * |
| 372 | 376 | */ |
@@ -401,6 +405,7 @@ discard block |
||
| 401 | 405 | * |
| 402 | 406 | * @param String $registration the registration of the aircraft |
| 403 | 407 | * @param String $name type of the aircraft |
| 408 | + * @param string $type |
|
| 404 | 409 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 405 | 410 | * |
| 406 | 411 | */ |
@@ -429,6 +434,10 @@ discard block |
||
| 429 | 434 | return false; |
| 430 | 435 | } |
| 431 | 436 | |
| 437 | + /** |
|
| 438 | + * @param string $type |
|
| 439 | + * @param string $aircraft_icao |
|
| 440 | + */ |
|
| 432 | 441 | public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
| 433 | 442 | $Common = new Common(); |
| 434 | 443 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
@@ -450,6 +459,7 @@ discard block |
||
| 450 | 459 | * |
| 451 | 460 | * @param String $aircraft_registration the registration of the aircraft |
| 452 | 461 | * @param String $aircraft_name type of the aircraft |
| 462 | + * @param string $type |
|
| 453 | 463 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 454 | 464 | * |
| 455 | 465 | */ |
@@ -482,6 +492,7 @@ discard block |
||
| 482 | 492 | * |
| 483 | 493 | * @param String $aircraft_registration the registration of the aircraft |
| 484 | 494 | * @param String $aircraft_name type of the aircraft |
| 495 | + * @param string $type |
|
| 485 | 496 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 486 | 497 | * |
| 487 | 498 | */ |
@@ -507,6 +518,7 @@ discard block |
||
| 507 | 518 | * |
| 508 | 519 | * @param String $registration the registration of the aircraft/mmsi |
| 509 | 520 | * @param String $name name |
| 521 | + * @param string $type |
|
| 510 | 522 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 511 | 523 | * |
| 512 | 524 | */ |
@@ -568,6 +580,7 @@ discard block |
||
| 568 | 580 | * |
| 569 | 581 | * @param String $aircraft_registration the registration of the aircraft |
| 570 | 582 | * @param String $aircraft_name type of the aircraft |
| 583 | + * @param string $type |
|
| 571 | 584 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 572 | 585 | * |
| 573 | 586 | */ |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Gets the images based on the aircraft registration |
|
| 16 | - * |
|
| 17 | - * @return Array the images list |
|
| 18 | - * |
|
| 19 | - */ |
|
| 15 | + * Gets the images based on the aircraft registration |
|
| 16 | + * |
|
| 17 | + * @return Array the images list |
|
| 18 | + * |
|
| 19 | + */ |
|
| 20 | 20 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 21 | 21 | { |
| 22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * Gets the images based on the ship name |
|
| 41 | - * |
|
| 42 | - * @return Array the images list |
|
| 43 | - * |
|
| 44 | - */ |
|
| 40 | + * Gets the images based on the ship name |
|
| 41 | + * |
|
| 42 | + * @return Array the images list |
|
| 43 | + * |
|
| 44 | + */ |
|
| 45 | 45 | public function getMarineImage($mmsi,$imo = '',$name = '') |
| 46 | 46 | { |
| 47 | 47 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Gets the image copyright based on the Exif data |
|
| 72 | - * |
|
| 73 | - * @return String image copyright |
|
| 74 | - * |
|
| 75 | - */ |
|
| 71 | + * Gets the image copyright based on the Exif data |
|
| 72 | + * |
|
| 73 | + * @return String image copyright |
|
| 74 | + * |
|
| 75 | + */ |
|
| 76 | 76 | public function getExifCopyright($url) { |
| 77 | 77 | $exif = exif_read_data($url); |
| 78 | 78 | $copyright = ''; |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * Adds the images based on the aircraft registration |
|
| 91 | - * |
|
| 92 | - * @return String either success or error |
|
| 93 | - * |
|
| 94 | - */ |
|
| 90 | + * Adds the images based on the aircraft registration |
|
| 91 | + * |
|
| 92 | + * @return String either success or error |
|
| 93 | + * |
|
| 94 | + */ |
|
| 95 | 95 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 96 | 96 | { |
| 97 | 97 | global $globalDebug,$globalAircraftImageFetch; |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * Adds the images based on the marine name |
|
| 123 | - * |
|
| 124 | - * @return String either success or error |
|
| 125 | - * |
|
| 126 | - */ |
|
| 122 | + * Adds the images based on the marine name |
|
| 123 | + * |
|
| 124 | + * @return String either success or error |
|
| 125 | + * |
|
| 126 | + */ |
|
| 127 | 127 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 128 | 128 | { |
| 129 | 129 | global $globalDebug,$globalMarineImageFetch; |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | - * Gets the aircraft image |
|
| 164 | - * |
|
| 165 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 166 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 167 | - * |
|
| 168 | - */ |
|
| 163 | + * Gets the aircraft image |
|
| 164 | + * |
|
| 165 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 166 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 167 | + * |
|
| 168 | + */ |
|
| 169 | 169 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
| 170 | 170 | { |
| 171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO; |
@@ -209,14 +209,14 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
| 212 | - * Gets the vessel image |
|
| 213 | - * |
|
| 214 | - * @param String $mmsi the vessel mmsi |
|
| 215 | - * @param String $imo the vessel imo |
|
| 216 | - * @param String $name the vessel name |
|
| 217 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 218 | - * |
|
| 219 | - */ |
|
| 212 | + * Gets the vessel image |
|
| 213 | + * |
|
| 214 | + * @param String $mmsi the vessel mmsi |
|
| 215 | + * @param String $imo the vessel imo |
|
| 216 | + * @param String $name the vessel name |
|
| 217 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 218 | + * |
|
| 219 | + */ |
|
| 220 | 220 | public function findMarineImage($mmsi,$imo = '',$name = '') |
| 221 | 221 | { |
| 222 | 222 | global $globalMarineSources; |
@@ -250,13 +250,13 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * Gets the aircraft image from Planespotters |
|
| 254 | - * |
|
| 255 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 256 | - * @param String $aircraft_name type of the aircraft |
|
| 257 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 258 | - * |
|
| 259 | - */ |
|
| 253 | + * Gets the aircraft image from Planespotters |
|
| 254 | + * |
|
| 255 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 256 | + * @param String $aircraft_name type of the aircraft |
|
| 257 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 258 | + * |
|
| 259 | + */ |
|
| 260 | 260 | public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
| 261 | 261 | $Common = new Common(); |
| 262 | 262 | // If aircraft registration is only number, also check with aircraft model |
@@ -283,13 +283,13 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | - * Gets the aircraft image from Deviantart |
|
| 287 | - * |
|
| 288 | - * @param String $registration the registration of the aircraft |
|
| 289 | - * @param String $name type of the aircraft |
|
| 290 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 291 | - * |
|
| 292 | - */ |
|
| 286 | + * Gets the aircraft image from Deviantart |
|
| 287 | + * |
|
| 288 | + * @param String $registration the registration of the aircraft |
|
| 289 | + * @param String $name type of the aircraft |
|
| 290 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 291 | + * |
|
| 292 | + */ |
|
| 293 | 293 | public function fromDeviantart($type,$registration, $name='') { |
| 294 | 294 | $Common = new Common(); |
| 295 | 295 | if ($type == 'aircraft') { |
@@ -321,13 +321,13 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
| 324 | - * Gets the aircraft image from JetPhotos |
|
| 325 | - * |
|
| 326 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 327 | - * @param String $aircraft_name type of the aircraft |
|
| 328 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 329 | - * |
|
| 330 | - */ |
|
| 324 | + * Gets the aircraft image from JetPhotos |
|
| 325 | + * |
|
| 326 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 327 | + * @param String $aircraft_name type of the aircraft |
|
| 328 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 329 | + * |
|
| 330 | + */ |
|
| 331 | 331 | public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
| 332 | 332 | $Common = new Common(); |
| 333 | 333 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -363,13 +363,13 @@ discard block |
||
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | - * Gets the aircraft image from PlanePictures |
|
| 367 | - * |
|
| 368 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 369 | - * @param String $aircraft_name type of the aircraft |
|
| 370 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 371 | - * |
|
| 372 | - */ |
|
| 366 | + * Gets the aircraft image from PlanePictures |
|
| 367 | + * |
|
| 368 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 369 | + * @param String $aircraft_name type of the aircraft |
|
| 370 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 371 | + * |
|
| 372 | + */ |
|
| 373 | 373 | public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
| 374 | 374 | $Common = new Common(); |
| 375 | 375 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -397,13 +397,13 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
| 400 | - * Gets the aircraft image from Flickr |
|
| 401 | - * |
|
| 402 | - * @param String $registration the registration of the aircraft |
|
| 403 | - * @param String $name type of the aircraft |
|
| 404 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 405 | - * |
|
| 406 | - */ |
|
| 400 | + * Gets the aircraft image from Flickr |
|
| 401 | + * |
|
| 402 | + * @param String $registration the registration of the aircraft |
|
| 403 | + * @param String $name type of the aircraft |
|
| 404 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 405 | + * |
|
| 406 | + */ |
|
| 407 | 407 | public function fromFlickr($type,$registration,$name='') { |
| 408 | 408 | $Common = new Common(); |
| 409 | 409 | if ($type == 'aircraft') { |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | - * Gets the aircraft image from Bing |
|
| 450 | - * |
|
| 451 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 452 | - * @param String $aircraft_name type of the aircraft |
|
| 453 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 454 | - * |
|
| 455 | - */ |
|
| 449 | + * Gets the aircraft image from Bing |
|
| 450 | + * |
|
| 451 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 452 | + * @param String $aircraft_name type of the aircraft |
|
| 453 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 454 | + * |
|
| 455 | + */ |
|
| 456 | 456 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 457 | 457 | global $globalImageBingKey; |
| 458 | 458 | $Common = new Common(); |
@@ -478,13 +478,13 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
| 481 | - * Gets the aircraft image from airport-data |
|
| 482 | - * |
|
| 483 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 484 | - * @param String $aircraft_name type of the aircraft |
|
| 485 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 486 | - * |
|
| 487 | - */ |
|
| 481 | + * Gets the aircraft image from airport-data |
|
| 482 | + * |
|
| 483 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 484 | + * @param String $aircraft_name type of the aircraft |
|
| 485 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 486 | + * |
|
| 487 | + */ |
|
| 488 | 488 | public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
| 489 | 489 | $Common = new Common(); |
| 490 | 490 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
@@ -503,13 +503,13 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | /** |
| 506 | - * Gets image from WikiMedia |
|
| 507 | - * |
|
| 508 | - * @param String $registration the registration of the aircraft/mmsi |
|
| 509 | - * @param String $name name |
|
| 510 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 511 | - * |
|
| 512 | - */ |
|
| 506 | + * Gets image from WikiMedia |
|
| 507 | + * |
|
| 508 | + * @param String $registration the registration of the aircraft/mmsi |
|
| 509 | + * @param String $name name |
|
| 510 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 511 | + * |
|
| 512 | + */ |
|
| 513 | 513 | public function fromWikimedia($type,$registration,$name='') { |
| 514 | 514 | $Common = new Common(); |
| 515 | 515 | if ($type == 'aircraft') { |
@@ -564,13 +564,13 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /** |
| 567 | - * Gets the aircraft image from custom url |
|
| 568 | - * |
|
| 569 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 570 | - * @param String $aircraft_name type of the aircraft |
|
| 571 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 572 | - * |
|
| 573 | - */ |
|
| 567 | + * Gets the aircraft image from custom url |
|
| 568 | + * |
|
| 569 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 570 | + * @param String $aircraft_name type of the aircraft |
|
| 571 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 572 | + * |
|
| 573 | + */ |
|
| 574 | 574 | public function fromCustomSource($type,$aircraft_registration,$aircraft_name='') { |
| 575 | 575 | global $globalAircraftImageCustomSources, $globalDebug; |
| 576 | 576 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | * @return Array the images list |
| 18 | 18 | * |
| 19 | 19 | */ |
| 20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 21 | 21 | { |
| 22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 25 | 25 | $reg = $registration; |
| 26 | 26 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
| 27 | 27 | $reg = trim($reg); |
| 28 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
| 28 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
| 29 | 29 | FROM spotter_image |
| 30 | 30 | WHERE spotter_image.registration = :registration LIMIT 1"; |
| 31 | 31 | $sth = $this->db->prepare($query); |
| 32 | 32 | $sth->execute(array(':registration' => $reg)); |
| 33 | 33 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 34 | 34 | if (!empty($result)) return $result; |
| 35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 35 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
| 36 | 36 | else return array(); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | * @return Array the images list |
| 43 | 43 | * |
| 44 | 44 | */ |
| 45 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
| 45 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
| 46 | 46 | { |
| 47 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 48 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 49 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 47 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 48 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 49 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 50 | 50 | $name = trim($name); |
| 51 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 51 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 52 | 52 | FROM marine_image |
| 53 | 53 | WHERE marine_image.mmsi = :mmsi"; |
| 54 | 54 | $query_data = array(':mmsi' => $mmsi); |
| 55 | 55 | if ($imo != '') { |
| 56 | 56 | $query .= " AND marine_image.imo = :imo"; |
| 57 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
| 57 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
| 58 | 58 | } |
| 59 | 59 | if ($name != '') { |
| 60 | 60 | $query .= " AND marine_image.name = :name"; |
| 61 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
| 61 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
| 62 | 62 | } |
| 63 | 63 | $query .= " LIMIT 1"; |
| 64 | 64 | $sth = $this->db->prepare($query); |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
| 80 | 80 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
| 81 | 81 | if ($copyright != '') { |
| 82 | - $copyright = str_replace('Copyright ','',$copyright); |
|
| 83 | - $copyright = str_replace('© ','',$copyright); |
|
| 84 | - $copyright = str_replace('(c) ','',$copyright); |
|
| 82 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
| 83 | + $copyright = str_replace('© ', '', $copyright); |
|
| 84 | + $copyright = str_replace('(c) ', '', $copyright); |
|
| 85 | 85 | } |
| 86 | 86 | return $copyright; |
| 87 | 87 | } |
@@ -92,25 +92,25 @@ discard block |
||
| 92 | 92 | * @return String either success or error |
| 93 | 93 | * |
| 94 | 94 | */ |
| 95 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 95 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 96 | 96 | { |
| 97 | - global $globalDebug,$globalAircraftImageFetch; |
|
| 97 | + global $globalDebug, $globalAircraftImageFetch; |
|
| 98 | 98 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
| 99 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 99 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 100 | 100 | $registration = trim($registration); |
| 101 | 101 | //getting the aircraft image |
| 102 | 102 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
| 103 | 103 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
| 104 | 104 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
| 105 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
| 105 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
| 106 | 106 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
| 107 | 107 | if ($image_url['original'] != '') { |
| 108 | 108 | if ($globalDebug) echo 'Found !'."\n"; |
| 109 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 109 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 110 | 110 | try { |
| 111 | 111 | $sth = $this->db->prepare($query); |
| 112 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 113 | - } catch(PDOException $e) { |
|
| 112 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 113 | + } catch (PDOException $e) { |
|
| 114 | 114 | echo $e->getMessage()."\n"; |
| 115 | 115 | return "error"; |
| 116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | * @return String either success or error |
| 125 | 125 | * |
| 126 | 126 | */ |
| 127 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
| 127 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
| 128 | 128 | { |
| 129 | - global $globalDebug,$globalMarineImageFetch; |
|
| 129 | + global $globalDebug, $globalMarineImageFetch; |
|
| 130 | 130 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
| 131 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 132 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 133 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 131 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 132 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 133 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 134 | 134 | $name = trim($name); |
| 135 | 135 | $Marine = new Marine($this->db); |
| 136 | 136 | if ($imo == '' || $name == '') { |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | //getting the aircraft image |
| 146 | 146 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
| 147 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
| 147 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
| 148 | 148 | if ($image_url['original'] != '') { |
| 149 | 149 | if ($globalDebug) echo 'Found !'."\n"; |
| 150 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 150 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 151 | 151 | try { |
| 152 | 152 | $sth = $this->db->prepare($query); |
| 153 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 154 | - } catch(PDOException $e) { |
|
| 153 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 154 | + } catch (PDOException $e) { |
|
| 155 | 155 | echo $e->getMessage()."\n"; |
| 156 | 156 | return "error"; |
| 157 | 157 | } |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO; |
| 172 | 172 | $Spotter = new Spotter($this->db); |
| 173 | 173 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
| 174 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
| 174 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
| 175 | 175 | if ($aircraft_registration != '') { |
| 176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 176 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 177 | 177 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 178 | 178 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 179 | 179 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -187,25 +187,25 @@ discard block |
||
| 187 | 187 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
| 188 | 188 | else $aircraft_name = ''; |
| 189 | 189 | $aircraft_registration = $aircraft_icao; |
| 190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 190 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 191 | 191 | unset($Spotter); |
| 192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 192 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
| 193 | 193 | foreach ($globalAircraftImageSources as $source) { |
| 194 | 194 | $source = strtolower($source); |
| 195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 195 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
| 196 | + if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
| 197 | + if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
| 198 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
| 199 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
| 200 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
| 201 | + if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
| 202 | + if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
| 203 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
| 204 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
| 205 | 205 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 206 | 206 | } |
| 207 | 207 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
| 208 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 208 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 218 | 218 | * |
| 219 | 219 | */ |
| 220 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
| 220 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
| 221 | 221 | { |
| 222 | 222 | global $globalMarineSources; |
| 223 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 224 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 225 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 223 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 224 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 225 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 226 | 226 | $name = trim($name); |
| 227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 227 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 228 | 228 | /* |
| 229 | 229 | $Marine = new Marine($this->db); |
| 230 | 230 | if ($imo == '' || $name == '') { |
@@ -236,17 +236,17 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | unset($Marine); |
| 238 | 238 | */ |
| 239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 239 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
| 240 | 240 | foreach ($globalMarineImageSources as $source) { |
| 241 | 241 | $source = strtolower($source); |
| 242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 242 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
| 243 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
| 244 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
| 245 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
| 246 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
| 247 | 247 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 248 | 248 | } |
| 249 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 249 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -257,24 +257,24 @@ discard block |
||
| 257 | 257 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 258 | 258 | * |
| 259 | 259 | */ |
| 260 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
| 260 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
| 261 | 261 | $Common = new Common(); |
| 262 | 262 | // If aircraft registration is only number, also check with aircraft model |
| 263 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 264 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 263 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 264 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 265 | 265 | } else { |
| 266 | 266 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
| 267 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 267 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 268 | 268 | } |
| 269 | 269 | $data = $Common->getData($url); |
| 270 | 270 | if ($xml = simplexml_load_string($data)) { |
| 271 | 271 | if (isset($xml->channel->item)) { |
| 272 | 272 | $image_url = array(); |
| 273 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 273 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 274 | 274 | $image_url['thumbnail'] = $thumbnail_url; |
| 275 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
| 276 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 277 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 275 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
| 276 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 277 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 278 | 278 | $image_url['source'] = 'planespotters'; |
| 279 | 279 | return $image_url; |
| 280 | 280 | } |
@@ -290,29 +290,29 @@ discard block |
||
| 290 | 290 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 291 | 291 | * |
| 292 | 292 | */ |
| 293 | - public function fromDeviantart($type,$registration, $name='') { |
|
| 293 | + public function fromDeviantart($type, $registration, $name = '') { |
|
| 294 | 294 | $Common = new Common(); |
| 295 | 295 | if ($type == 'aircraft') { |
| 296 | 296 | // If aircraft registration is only number, also check with aircraft model |
| 297 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
| 298 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 297 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
| 298 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 299 | 299 | } else { |
| 300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 301 | 301 | } |
| 302 | 302 | } elseif ($type == 'marine') { |
| 303 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
| 303 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $data = $Common->getData($url); |
| 307 | 307 | if ($xml = simplexml_load_string($data)) { |
| 308 | 308 | if (isset($xml->channel->item->link)) { |
| 309 | 309 | $image_url = array(); |
| 310 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 310 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 311 | 311 | $image_url['thumbnail'] = $thumbnail_url; |
| 312 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 312 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 313 | 313 | $image_url['original'] = $original_url; |
| 314 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 315 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 314 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 315 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 316 | 316 | $image_url['source'] = 'deviantart'; |
| 317 | 317 | return $image_url; |
| 318 | 318 | } |
@@ -328,32 +328,32 @@ discard block |
||
| 328 | 328 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 329 | 329 | * |
| 330 | 330 | */ |
| 331 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
| 331 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
| 332 | 332 | $Common = new Common(); |
| 333 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 333 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 334 | 334 | $data = $Common->getData($url); |
| 335 | 335 | $dom = new DOMDocument(); |
| 336 | 336 | @$dom->loadHTML($data); |
| 337 | 337 | $all_pics = array(); |
| 338 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 338 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 339 | 339 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
| 340 | 340 | $all_pics[] = $image->getAttribute('src'); |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | $all_authors = array(); |
| 344 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
| 344 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
| 345 | 345 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
| 346 | 346 | $all_authors[] = $author->getAttribute('content'); |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | $all_ref = array(); |
| 350 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 350 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 351 | 351 | $all_ref[] = $link->getAttribute('href'); |
| 352 | 352 | } |
| 353 | 353 | if (isset($all_pics[0])) { |
| 354 | 354 | $image_url = array(); |
| 355 | 355 | $image_url['thumbnail'] = $all_pics[0]; |
| 356 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
| 356 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
| 357 | 357 | $image_url['copyright'] = $all_authors[0]; |
| 358 | 358 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
| 359 | 359 | $image_url['source'] = 'JetPhotos'; |
@@ -370,24 +370,24 @@ discard block |
||
| 370 | 370 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 371 | 371 | * |
| 372 | 372 | */ |
| 373 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
| 373 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
| 374 | 374 | $Common = new Common(); |
| 375 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 375 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 376 | 376 | $data = $Common->getData($url); |
| 377 | 377 | $dom = new DOMDocument(); |
| 378 | 378 | @$dom->loadHTML($data); |
| 379 | 379 | $all_pics = array(); |
| 380 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 380 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 381 | 381 | $all_pics[] = $image->getAttribute('src'); |
| 382 | 382 | } |
| 383 | 383 | $all_links = array(); |
| 384 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 385 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
| 384 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 385 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
| 386 | 386 | } |
| 387 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
| 387 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
| 388 | 388 | $image_url = array(); |
| 389 | 389 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
| 390 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
| 390 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
| 391 | 391 | $image_url['copyright'] = $all_links[6]['text']; |
| 392 | 392 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
| 393 | 393 | $image_url['source'] = 'PlanePictures'; |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 405 | 405 | * |
| 406 | 406 | */ |
| 407 | - public function fromFlickr($type,$registration,$name='') { |
|
| 407 | + public function fromFlickr($type, $registration, $name = '') { |
|
| 408 | 408 | $Common = new Common(); |
| 409 | 409 | if ($type == 'aircraft') { |
| 410 | 410 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -416,12 +416,12 @@ discard block |
||
| 416 | 416 | $data = $Common->getData($url); |
| 417 | 417 | if ($xml = simplexml_load_string($data)) { |
| 418 | 418 | if (isset($xml->channel->item)) { |
| 419 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
| 419 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
| 420 | 420 | $image_url = array(); |
| 421 | 421 | $image_url['thumbnail'] = $original_url; |
| 422 | 422 | $image_url['original'] = $original_url; |
| 423 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 424 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 423 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 424 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 425 | 425 | $image_url['source'] = 'flickr'; |
| 426 | 426 | return $image_url; |
| 427 | 427 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | return false; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
| 432 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
| 433 | 433 | $Common = new Common(); |
| 434 | 434 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
| 435 | 435 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -453,14 +453,14 @@ discard block |
||
| 453 | 453 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 454 | 454 | * |
| 455 | 455 | */ |
| 456 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
| 456 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
| 457 | 457 | global $globalImageBingKey; |
| 458 | 458 | $Common = new Common(); |
| 459 | 459 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
| 460 | 460 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
| 461 | 461 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
| 462 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
| 463 | - $data = $Common->getData($url,'get','',$headers); |
|
| 462 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
| 463 | + $data = $Common->getData($url, 'get', '', $headers); |
|
| 464 | 464 | $result = json_decode($data); |
| 465 | 465 | if (isset($result->d->results[0]->MediaUrl)) { |
| 466 | 466 | $image_url = array(); |
@@ -485,14 +485,14 @@ discard block |
||
| 485 | 485 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 486 | 486 | * |
| 487 | 487 | */ |
| 488 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
| 488 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
| 489 | 489 | $Common = new Common(); |
| 490 | 490 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
| 491 | 491 | $data = $Common->getData($url); |
| 492 | 492 | $result = json_decode($data); |
| 493 | 493 | if (isset($result->count) && $result->count > 0) { |
| 494 | 494 | $image_url = array(); |
| 495 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
| 495 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
| 496 | 496 | $image_url['source_website'] = $result->data[0]->link; |
| 497 | 497 | $image_url['thumbnail'] = $result->data[0]->image; |
| 498 | 498 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 511 | 511 | * |
| 512 | 512 | */ |
| 513 | - public function fromWikimedia($type,$registration,$name='') { |
|
| 513 | + public function fromWikimedia($type, $registration, $name = '') { |
|
| 514 | 514 | $Common = new Common(); |
| 515 | 515 | if ($type == 'aircraft') { |
| 516 | 516 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | $result = json_decode($data); |
| 524 | 524 | if (isset($result->query->search[0]->title)) { |
| 525 | 525 | $fileo = $result->query->search[0]->title; |
| 526 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 526 | + if (substr($fileo, -3) == 'pdf') return false; |
|
| 527 | 527 | $file = urlencode($fileo); |
| 528 | 528 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 529 | 529 | $data2 = $Common->getData($url2); |
@@ -548,11 +548,11 @@ discard block |
||
| 548 | 548 | if (isset($result2->query->pages)) { |
| 549 | 549 | foreach ($result2->query->pages as $page) { |
| 550 | 550 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
| 551 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 551 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 552 | 552 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
| 553 | 553 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
| 554 | 554 | } |
| 555 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
| 555 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
| 556 | 556 | return $image_url; |
| 557 | 557 | } |
| 558 | 558 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 572 | 572 | * |
| 573 | 573 | */ |
| 574 | - public function fromCustomSource($type,$aircraft_registration,$aircraft_name='') { |
|
| 574 | + public function fromCustomSource($type, $aircraft_registration, $aircraft_name = '') { |
|
| 575 | 575 | global $globalAircraftImageCustomSources, $globalDebug; |
| 576 | 576 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 577 | 577 | if (!empty($globalAircraftImageCustomSources)) { |
@@ -588,15 +588,15 @@ discard block |
||
| 588 | 588 | print_r($source); |
| 589 | 589 | print_r($customsources); |
| 590 | 590 | } |
| 591 | - $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
|
| 592 | - $url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['thumbnail']); |
|
| 591 | + $url = str_replace('{registration}', $aircraft_registration, $source['original']); |
|
| 592 | + $url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['thumbnail']); |
|
| 593 | 593 | if ($Common->urlexist($url)) { |
| 594 | 594 | $image_url = array(); |
| 595 | 595 | $image_url['thumbnail'] = $url_thumbnail; |
| 596 | 596 | $image_url['original'] = $url; |
| 597 | 597 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 598 | 598 | else $exifCopyright = ''; |
| 599 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 599 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 600 | 600 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 601 | 601 | else $image_url['copyright'] = $source['source_website']; |
| 602 | 602 | $image_url['source_website'] = $source['source_website']; |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
| 24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 25 | 25 | $reg = $registration; |
| 26 | - if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
| 26 | + if ($reg == '' && $aircraft_icao != '') { |
|
| 27 | + $reg = $aircraft_icao.$airline_icao; |
|
| 28 | + } |
|
| 27 | 29 | $reg = trim($reg); |
| 28 | 30 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
| 29 | 31 | FROM spotter_image |
@@ -31,9 +33,13 @@ discard block |
||
| 31 | 33 | $sth = $this->db->prepare($query); |
| 32 | 34 | $sth->execute(array(':registration' => $reg)); |
| 33 | 35 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 34 | - if (!empty($result)) return $result; |
|
| 35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 36 | - else return array(); |
|
| 36 | + if (!empty($result)) { |
|
| 37 | + return $result; |
|
| 38 | + } elseif ($registration != '') { |
|
| 39 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 40 | + } else { |
|
| 41 | + return array(); |
|
| 42 | + } |
|
| 37 | 43 | } |
| 38 | 44 | |
| 39 | 45 | /** |
@@ -76,8 +82,11 @@ discard block |
||
| 76 | 82 | public function getExifCopyright($url) { |
| 77 | 83 | $exif = exif_read_data($url); |
| 78 | 84 | $copyright = ''; |
| 79 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
| 80 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
| 85 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
| 86 | + $copyright = $exif['COMPUTED']['copyright']; |
|
| 87 | + } elseif (isset($exif['copyright'])) { |
|
| 88 | + $copyright = $exif['copyright']; |
|
| 89 | + } |
|
| 81 | 90 | if ($copyright != '') { |
| 82 | 91 | $copyright = str_replace('Copyright ','',$copyright); |
| 83 | 92 | $copyright = str_replace('© ','',$copyright); |
@@ -95,17 +104,27 @@ discard block |
||
| 95 | 104 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 96 | 105 | { |
| 97 | 106 | global $globalDebug,$globalAircraftImageFetch; |
| 98 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
| 107 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
| 108 | + return ''; |
|
| 109 | + } |
|
| 99 | 110 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 100 | 111 | $registration = trim($registration); |
| 101 | 112 | //getting the aircraft image |
| 102 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 103 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 104 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 113 | + if ($globalDebug && $registration != '') { |
|
| 114 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 115 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
| 116 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 117 | + } elseif ($globalDebug && $airline_icao != '') { |
|
| 118 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 119 | + } |
|
| 105 | 120 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
| 106 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 121 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 122 | + $registration = $aircraft_icao.$airline_icao; |
|
| 123 | + } |
|
| 107 | 124 | if ($image_url['original'] != '') { |
| 108 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 125 | + if ($globalDebug) { |
|
| 126 | + echo 'Found !'."\n"; |
|
| 127 | + } |
|
| 109 | 128 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 110 | 129 | try { |
| 111 | 130 | $sth = $this->db->prepare($query); |
@@ -114,7 +133,9 @@ discard block |
||
| 114 | 133 | echo $e->getMessage()."\n"; |
| 115 | 134 | return "error"; |
| 116 | 135 | } |
| 117 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 136 | + } elseif ($globalDebug) { |
|
| 137 | + echo "Not found :'(\n"; |
|
| 138 | + } |
|
| 118 | 139 | return "success"; |
| 119 | 140 | } |
| 120 | 141 | |
@@ -127,7 +148,9 @@ discard block |
||
| 127 | 148 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 128 | 149 | { |
| 129 | 150 | global $globalDebug,$globalMarineImageFetch; |
| 130 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
| 151 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
| 152 | + return ''; |
|
| 153 | + } |
|
| 131 | 154 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
| 132 | 155 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 133 | 156 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -137,16 +160,22 @@ discard block |
||
| 137 | 160 | $identity = $Marine->getIdentity($mmsi); |
| 138 | 161 | if (isset($identity[0]['mmsi'])) { |
| 139 | 162 | $imo = $identity[0]['imo']; |
| 140 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
| 163 | + if ($identity[0]['ship_name'] != '') { |
|
| 164 | + $name = $identity[0]['ship_name']; |
|
| 165 | + } |
|
| 141 | 166 | } |
| 142 | 167 | } |
| 143 | 168 | unset($Marine); |
| 144 | 169 | |
| 145 | 170 | //getting the aircraft image |
| 146 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
| 171 | + if ($globalDebug && $name != '') { |
|
| 172 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
| 173 | + } |
|
| 147 | 174 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
| 148 | 175 | if ($image_url['original'] != '') { |
| 149 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 176 | + if ($globalDebug) { |
|
| 177 | + echo 'Found !'."\n"; |
|
| 178 | + } |
|
| 150 | 179 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 151 | 180 | try { |
| 152 | 181 | $sth = $this->db->prepare($query); |
@@ -155,7 +184,9 @@ discard block |
||
| 155 | 184 | echo $e->getMessage()."\n"; |
| 156 | 185 | return "error"; |
| 157 | 186 | } |
| 158 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 187 | + } elseif ($globalDebug) { |
|
| 188 | + echo "Not found :'(\n"; |
|
| 189 | + } |
|
| 159 | 190 | return "success"; |
| 160 | 191 | } |
| 161 | 192 | |
@@ -170,41 +201,85 @@ discard block |
||
| 170 | 201 | { |
| 171 | 202 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO; |
| 172 | 203 | $Spotter = new Spotter($this->db); |
| 173 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 204 | + if (!isset($globalIVAO)) { |
|
| 205 | + $globalIVAO = FALSE; |
|
| 206 | + } |
|
| 174 | 207 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
| 175 | 208 | if ($aircraft_registration != '') { |
| 176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 209 | + if (strpos($aircraft_registration,'/') !== false) { |
|
| 210 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 211 | + } |
|
| 177 | 212 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 178 | 213 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 179 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 180 | - else $aircraft_name = ''; |
|
| 181 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 182 | - else $aircraft_icao = ''; |
|
| 183 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 184 | - else $airline_icao = ''; |
|
| 214 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
| 215 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 216 | + } else { |
|
| 217 | + $aircraft_name = ''; |
|
| 218 | + } |
|
| 219 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
| 220 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 221 | + } else { |
|
| 222 | + $aircraft_icao = ''; |
|
| 223 | + } |
|
| 224 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
| 225 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 226 | + } else { |
|
| 227 | + $airline_icao = ''; |
|
| 228 | + } |
|
| 185 | 229 | } elseif ($aircraft_icao != '') { |
| 186 | 230 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
| 187 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
| 188 | - else $aircraft_name = ''; |
|
| 231 | + if (isset($aircraft_info[0]['type'])) { |
|
| 232 | + $aircraft_name = $aircraft_info[0]['type']; |
|
| 233 | + } else { |
|
| 234 | + $aircraft_name = ''; |
|
| 235 | + } |
|
| 189 | 236 | $aircraft_registration = $aircraft_icao; |
| 190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 237 | + } else { |
|
| 238 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 239 | + } |
|
| 191 | 240 | unset($Spotter); |
| 192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 241 | + if (!isset($globalAircraftImageSources)) { |
|
| 242 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 243 | + } |
|
| 193 | 244 | foreach ($globalAircraftImageSources as $source) { |
| 194 | 245 | $source = strtolower($source); |
| 195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 205 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 206 | - } |
|
| 207 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
| 246 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 247 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 248 | + } |
|
| 249 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
| 250 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 251 | + } |
|
| 252 | + if ($source == 'flickr') { |
|
| 253 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 254 | + } |
|
| 255 | + if ($source == 'bing') { |
|
| 256 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 257 | + } |
|
| 258 | + if ($source == 'deviantart') { |
|
| 259 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 260 | + } |
|
| 261 | + if ($source == 'wikimedia') { |
|
| 262 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 263 | + } |
|
| 264 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
| 265 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 266 | + } |
|
| 267 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
| 268 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 269 | + } |
|
| 270 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 271 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 272 | + } |
|
| 273 | + if ($source == 'customsources') { |
|
| 274 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 275 | + } |
|
| 276 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 277 | + return $images_array; |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
| 281 | + return $this->findAircraftImage($aircraft_icao); |
|
| 282 | + } |
|
| 208 | 283 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 209 | 284 | } |
| 210 | 285 | |
@@ -224,7 +299,9 @@ discard block |
||
| 224 | 299 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 225 | 300 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
| 226 | 301 | $name = trim($name); |
| 227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 302 | + if (strlen($name) < 4) { |
|
| 303 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 304 | + } |
|
| 228 | 305 | /* |
| 229 | 306 | $Marine = new Marine($this->db); |
| 230 | 307 | if ($imo == '' || $name == '') { |
@@ -236,15 +313,29 @@ discard block |
||
| 236 | 313 | } |
| 237 | 314 | unset($Marine); |
| 238 | 315 | */ |
| 239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 316 | + if (!isset($globalMarineImageSources)) { |
|
| 317 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 318 | + } |
|
| 240 | 319 | foreach ($globalMarineImageSources as $source) { |
| 241 | 320 | $source = strtolower($source); |
| 242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 247 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 321 | + if ($source == 'flickr') { |
|
| 322 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 323 | + } |
|
| 324 | + if ($source == 'bing') { |
|
| 325 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 326 | + } |
|
| 327 | + if ($source == 'deviantart') { |
|
| 328 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 329 | + } |
|
| 330 | + if ($source == 'wikimedia') { |
|
| 331 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 332 | + } |
|
| 333 | + if ($source == 'customsources') { |
|
| 334 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 335 | + } |
|
| 336 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 337 | + return $images_array; |
|
| 338 | + } |
|
| 248 | 339 | } |
| 249 | 340 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 250 | 341 | } |
@@ -407,11 +498,17 @@ discard block |
||
| 407 | 498 | public function fromFlickr($type,$registration,$name='') { |
| 408 | 499 | $Common = new Common(); |
| 409 | 500 | if ($type == 'aircraft') { |
| 410 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
| 411 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
| 501 | + if ($name != '') { |
|
| 502 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
| 503 | + } else { |
|
| 504 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
| 505 | + } |
|
| 412 | 506 | } elseif ($type == 'marine') { |
| 413 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.urlencode($name); |
|
| 414 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',vessel'; |
|
| 507 | + if ($name != '') { |
|
| 508 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.urlencode($name); |
|
| 509 | + } else { |
|
| 510 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',vessel'; |
|
| 511 | + } |
|
| 415 | 512 | } |
| 416 | 513 | $data = $Common->getData($url); |
| 417 | 514 | if ($xml = simplexml_load_string($data)) { |
@@ -456,9 +553,14 @@ discard block |
||
| 456 | 553 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 457 | 554 | global $globalImageBingKey; |
| 458 | 555 | $Common = new Common(); |
| 459 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
| 460 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 461 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 556 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 557 | + return false; |
|
| 558 | + } |
|
| 559 | + if ($aircraft_name != '') { |
|
| 560 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 561 | + } else { |
|
| 562 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 563 | + } |
|
| 462 | 564 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 463 | 565 | $data = $Common->getData($url,'get','',$headers); |
| 464 | 566 | $result = json_decode($data); |
@@ -513,17 +615,25 @@ discard block |
||
| 513 | 615 | public function fromWikimedia($type,$registration,$name='') { |
| 514 | 616 | $Common = new Common(); |
| 515 | 617 | if ($type == 'aircraft') { |
| 516 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 517 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 618 | + if ($name != '') { |
|
| 619 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 620 | + } else { |
|
| 621 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 622 | + } |
|
| 518 | 623 | } elseif ($type == 'marine') { |
| 519 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'"'; |
|
| 520 | - else return false; |
|
| 624 | + if ($name != '') { |
|
| 625 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'"'; |
|
| 626 | + } else { |
|
| 627 | + return false; |
|
| 628 | + } |
|
| 521 | 629 | } |
| 522 | 630 | $data = $Common->getData($url); |
| 523 | 631 | $result = json_decode($data); |
| 524 | 632 | if (isset($result->query->search[0]->title)) { |
| 525 | 633 | $fileo = $result->query->search[0]->title; |
| 526 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 634 | + if (substr($fileo,-3) == 'pdf') { |
|
| 635 | + return false; |
|
| 636 | + } |
|
| 527 | 637 | $file = urlencode($fileo); |
| 528 | 638 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 529 | 639 | $data2 = $Common->getData($url2); |
@@ -594,18 +704,27 @@ discard block |
||
| 594 | 704 | $image_url = array(); |
| 595 | 705 | $image_url['thumbnail'] = $url_thumbnail; |
| 596 | 706 | $image_url['original'] = $url; |
| 597 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 598 | - else $exifCopyright = ''; |
|
| 599 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 600 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 601 | - else $image_url['copyright'] = $source['source_website']; |
|
| 707 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 708 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 709 | + } else { |
|
| 710 | + $exifCopyright = ''; |
|
| 711 | + } |
|
| 712 | + if ($exifCopyright != '') { |
|
| 713 | + $image_url['copyright'] = $exifCopyright; |
|
| 714 | + } elseif (isset($source['copyright'])) { |
|
| 715 | + $image_url['copyright'] = $source['copyright']; |
|
| 716 | + } else { |
|
| 717 | + $image_url['copyright'] = $source['source_website']; |
|
| 718 | + } |
|
| 602 | 719 | $image_url['source_website'] = $source['source_website']; |
| 603 | 720 | $image_url['source'] = $source['source']; |
| 604 | 721 | return $image_url; |
| 605 | 722 | } |
| 606 | 723 | } |
| 607 | 724 | return false; |
| 608 | - } else return false; |
|
| 725 | + } else { |
|
| 726 | + return false; |
|
| 727 | + } |
|
| 609 | 728 | } |
| 610 | 729 | } |
| 611 | 730 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | <div id="showdetails" class="showdetails"></div> |
| 37 | 37 | <div id="infobox" class="infobox"><h4><?php echo _("Aircrafts detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div> |
| 38 | 38 | <?php |
| 39 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
| 39 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
| 40 | 40 | |
| 41 | 41 | ?> |
| 42 | 42 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
| 57 | 57 | <?php |
| 58 | 58 | } |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | ?> |
| 61 | 61 | <div id="dialog" title="<?php echo _("Session has timed-out"); ?>"> |
| 62 | 62 | <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p> |
@@ -70,34 +70,34 @@ discard block |
||
| 70 | 70 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
| 71 | 71 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
| 72 | 72 | <?php |
| 73 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 73 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 74 | 74 | if (isset($globalArchive) && $globalArchive == TRUE) { |
| 75 | 75 | ?> |
| 76 | 76 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
| 77 | 77 | <?php |
| 78 | 78 | } |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | ?> |
| 81 | 81 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
| 82 | 82 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
| 83 | 83 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
| 84 | 84 | <?php |
| 85 | - if (isset($globalMap3D) && $globalMap3D) { |
|
| 85 | + if (isset($globalMap3D) && $globalMap3D) { |
|
| 86 | 86 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
| 87 | 87 | ?> |
| 88 | 88 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
| 89 | 89 | <?php |
| 90 | - } else { |
|
| 91 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
| 90 | + } else { |
|
| 91 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
| 92 | 92 | ?> |
| 93 | 93 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
| 94 | 94 | <?php |
| 95 | - } |
|
| 95 | + } |
|
| 96 | 96 | ?> |
| 97 | 97 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
| 98 | 98 | <?php |
| 99 | 99 | } |
| 100 | - } |
|
| 100 | + } |
|
| 101 | 101 | ?> |
| 102 | 102 | </ul> |
| 103 | 103 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | ?> |
| 172 | 172 | </div> |
| 173 | 173 | <?php |
| 174 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
| 174 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
| 175 | 175 | ?> |
| 176 | 176 | <div class="sidebar-pane" id="archive"> |
| 177 | 177 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | </form> |
| 232 | 232 | </div> |
| 233 | 233 | <?php |
| 234 | - } |
|
| 234 | + } |
|
| 235 | 235 | ?> |
| 236 | 236 | <div class="sidebar-pane" id="settings"> |
| 237 | 237 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -242,56 +242,56 @@ discard block |
||
| 242 | 242 | <?php |
| 243 | 243 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
| 244 | 244 | else $MapType = $_COOKIE['MapType']; |
| 245 | - ?> |
|
| 245 | + ?> |
|
| 246 | 246 | <?php |
| 247 | 247 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
| 248 | - ?> |
|
| 248 | + ?> |
|
| 249 | 249 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
| 250 | 250 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
| 251 | 251 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
| 252 | 252 | <?php |
| 253 | 253 | } |
| 254 | - ?> |
|
| 254 | + ?> |
|
| 255 | 255 | <?php |
| 256 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
| 257 | - ?> |
|
| 256 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
| 257 | + ?> |
|
| 258 | 258 | <?php |
| 259 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
| 260 | - ?> |
|
| 259 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
| 260 | + ?> |
|
| 261 | 261 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
| 262 | 262 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
| 263 | 263 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
| 264 | 264 | <?php |
| 265 | - } |
|
| 266 | - ?> |
|
| 265 | + } |
|
| 266 | + ?> |
|
| 267 | 267 | <?php |
| 268 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
| 269 | - ?> |
|
| 268 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
| 269 | + ?> |
|
| 270 | 270 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
| 271 | 271 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
| 272 | 272 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
| 273 | 273 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
| 274 | 274 | <?php |
| 275 | - } |
|
| 276 | - ?> |
|
| 275 | + } |
|
| 276 | + ?> |
|
| 277 | 277 | <?php |
| 278 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
| 279 | - ?> |
|
| 278 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
| 279 | + ?> |
|
| 280 | 280 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
| 281 | 281 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
| 282 | 282 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
| 283 | 283 | <?php |
| 284 | - } |
|
| 285 | - ?> |
|
| 284 | + } |
|
| 285 | + ?> |
|
| 286 | 286 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
| 287 | 287 | <?php |
| 288 | 288 | } |
| 289 | - ?> |
|
| 289 | + ?> |
|
| 290 | 290 | <?php |
| 291 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
| 291 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
| 292 | 292 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
| 293 | 293 | else $MapBoxId = $_COOKIE['MapTypeId']; |
| 294 | - ?> |
|
| 294 | + ?> |
|
| 295 | 295 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
| 296 | 296 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
| 297 | 297 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -305,13 +305,13 @@ discard block |
||
| 305 | 305 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
| 306 | 306 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
| 307 | 307 | <?php |
| 308 | - } |
|
| 309 | - ?> |
|
| 308 | + } |
|
| 309 | + ?> |
|
| 310 | 310 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
| 311 | 311 | </select> |
| 312 | 312 | </li> |
| 313 | 313 | <?php |
| 314 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 314 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 315 | 315 | ?> |
| 316 | 316 | <li><?php echo _("Type of Terrain:"); ?> |
| 317 | 317 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | </select> |
| 322 | 322 | </li> |
| 323 | 323 | <?php |
| 324 | - } |
|
| 324 | + } |
|
| 325 | 325 | ?> |
| 326 | 326 | <?php |
| 327 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
| 327 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
| 328 | 328 | ?> |
| 329 | 329 | |
| 330 | 330 | <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
@@ -332,68 +332,68 @@ discard block |
||
| 332 | 332 | <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
| 333 | 333 | <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
| 334 | 334 | <?php |
| 335 | - } |
|
| 335 | + } |
|
| 336 | 336 | ?> |
| 337 | 337 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
| 338 | 338 | <?php |
| 339 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 339 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 340 | 340 | ?> |
| 341 | 341 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
| 342 | 342 | <?php |
| 343 | - } |
|
| 344 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
| 343 | + } |
|
| 344 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
| 345 | 345 | ?> |
| 346 | 346 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
| 347 | 347 | <?php |
| 348 | - } |
|
| 348 | + } |
|
| 349 | 349 | ?> |
| 350 | 350 | |
| 351 | 351 | <?php |
| 352 | 352 | if (function_exists('array_column')) { |
| 353 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
| 354 | - ?> |
|
| 353 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
| 354 | + ?> |
|
| 355 | 355 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
| 356 | 356 | <?php |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | } elseif (isset($globalSources)) { |
| 359 | - $dispolar = false; |
|
| 360 | - foreach ($globalSources as $testsource) { |
|
| 361 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
| 362 | - } |
|
| 363 | - if ($dispolar) { |
|
| 364 | - ?> |
|
| 359 | + $dispolar = false; |
|
| 360 | + foreach ($globalSources as $testsource) { |
|
| 361 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
| 362 | + } |
|
| 363 | + if ($dispolar) { |
|
| 364 | + ?> |
|
| 365 | 365 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
| 366 | 366 | <?php |
| 367 | - } |
|
| 368 | - } |
|
| 369 | - ?> |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + ?> |
|
| 370 | 370 | <?php |
| 371 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
| 371 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
| 372 | 372 | ?> |
| 373 | 373 | |
| 374 | 374 | <?php |
| 375 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 376 | - ?> |
|
| 375 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 376 | + ?> |
|
| 377 | 377 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
| 378 | 378 | <?php |
| 379 | 379 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
| 380 | - ?> |
|
| 380 | + ?> |
|
| 381 | 381 | <li><?php echo _("Aircraft icon color:"); ?> |
| 382 | 382 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
| 383 | 383 | </li> |
| 384 | 384 | <?php |
| 385 | - } |
|
| 386 | - } |
|
| 387 | - ?> |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + ?> |
|
| 388 | 388 | <?php |
| 389 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 390 | - ?> |
|
| 389 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 390 | + ?> |
|
| 391 | 391 | <li><?php echo _("Marine icon color:"); ?> |
| 392 | 392 | <input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>"> |
| 393 | 393 | </li> |
| 394 | 394 | <?php |
| 395 | - } |
|
| 396 | - ?> |
|
| 395 | + } |
|
| 396 | + ?> |
|
| 397 | 397 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
| 398 | 398 | <div class="range"> |
| 399 | 399 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | </div> |
| 402 | 402 | </li> |
| 403 | 403 | <?php |
| 404 | - } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
| 404 | + } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
| 405 | 405 | ?> |
| 406 | 406 | <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li> |
| 407 | 407 | <li><?php echo _("Aircraft icon color:"); ?> |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | </li> |
| 417 | 417 | <?php |
| 418 | 418 | } |
| 419 | - } |
|
| 419 | + } |
|
| 420 | 420 | ?> |
| 421 | 421 | <li><?php echo _("Distance unit:"); ?> |
| 422 | 422 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -449,16 +449,16 @@ discard block |
||
| 449 | 449 | <ul> |
| 450 | 450 | <?php |
| 451 | 451 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
| 452 | - ?> |
|
| 452 | + ?> |
|
| 453 | 453 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
| 454 | 454 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
| 455 | 455 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
| 456 | 456 | <?php |
| 457 | 457 | } |
| 458 | - ?> |
|
| 458 | + ?> |
|
| 459 | 459 | <?php |
| 460 | 460 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
| 461 | - ?> |
|
| 461 | + ?> |
|
| 462 | 462 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
| 463 | 463 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
| 464 | 464 | <?php } ?> |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | <?php } ?> |
| 468 | 468 | <?php |
| 469 | 469 | } |
| 470 | - ?> |
|
| 470 | + ?> |
|
| 471 | 471 | <li><?php echo _("Display airlines:"); ?> |
| 472 | 472 | <br/> |
| 473 | 473 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -487,14 +487,14 @@ discard block |
||
| 487 | 487 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | - ?> |
|
| 490 | + ?> |
|
| 491 | 491 | </select> |
| 492 | 492 | </li> |
| 493 | 493 | <?php |
| 494 | 494 | $Spotter = new Spotter(); |
| 495 | 495 | $allalliancenames = $Spotter->getAllAllianceNames(); |
| 496 | 496 | if (!empty($allalliancenames)) { |
| 497 | - ?> |
|
| 497 | + ?> |
|
| 498 | 498 | <li><?php echo _("Display alliance:"); ?> |
| 499 | 499 | <br/> |
| 500 | 500 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -508,15 +508,15 @@ discard block |
||
| 508 | 508 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
| 509 | 509 | } |
| 510 | 510 | } |
| 511 | - ?> |
|
| 511 | + ?> |
|
| 512 | 512 | </select> |
| 513 | 513 | </li> |
| 514 | 514 | <?php |
| 515 | 515 | } |
| 516 | - ?> |
|
| 516 | + ?> |
|
| 517 | 517 | <?php |
| 518 | 518 | if (isset($globalAPRS) && $globalAPRS) { |
| 519 | - ?> |
|
| 519 | + ?> |
|
| 520 | 520 | <li><?php echo _("Display APRS sources name:"); ?> |
| 521 | 521 | <select class="selectpicker" multiple onchange="sources(this);"> |
| 522 | 522 | <?php |
@@ -528,15 +528,15 @@ discard block |
||
| 528 | 528 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | - ?> |
|
| 531 | + ?> |
|
| 532 | 532 | </select> |
| 533 | 533 | </li> |
| 534 | 534 | <?php |
| 535 | 535 | } |
| 536 | - ?> |
|
| 536 | + ?> |
|
| 537 | 537 | <?php |
| 538 | 538 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
| 539 | - ?> |
|
| 539 | + ?> |
|
| 540 | 540 | <li><?php echo _("Display airlines of type:"); ?><br/> |
| 541 | 541 | <select class="selectpicker" onchange="airlinestype(this);"> |
| 542 | 542 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | </li> |
| 548 | 548 | <?php |
| 549 | 549 | } |
| 550 | - ?> |
|
| 550 | + ?> |
|
| 551 | 551 | <li> |
| 552 | 552 | <?php echo _("Display flight with ident:"); ?> |
| 553 | 553 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | </form> |
| 561 | 561 | </div> |
| 562 | 562 | <?php |
| 563 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 563 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
| 564 | 564 | ?> |
| 565 | 565 | <div class="sidebar-pane" id="satellites"> |
| 566 | 566 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -600,14 +600,14 @@ discard block |
||
| 600 | 600 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | - ?> |
|
| 603 | + ?> |
|
| 604 | 604 | </select> |
| 605 | 605 | </li> |
| 606 | 606 | </ul> |
| 607 | 607 | </form> |
| 608 | 608 | </div> |
| 609 | 609 | <?php |
| 610 | - } |
|
| 610 | + } |
|
| 611 | 611 | ?> |
| 612 | 612 | </div> |
| 613 | 613 | </div> |
@@ -150,11 +150,26 @@ discard block |
||
| 150 | 150 | <li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li> |
| 151 | 151 | <li><?php echo _("NOTAM scope:"); ?> |
| 152 | 152 | <select class="selectpicker" onchange="notamscope(this);"> |
| 153 | - <option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option> |
|
| 154 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option> |
|
| 155 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option> |
|
| 156 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option> |
|
| 157 | - <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option> |
|
| 153 | + <option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') { |
|
| 154 | + print ' selected'; |
|
| 155 | +} |
|
| 156 | +?>>All</option> |
|
| 157 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') { |
|
| 158 | + print ' selected'; |
|
| 159 | +} |
|
| 160 | +?>>Airport/Enroute warning</option> |
|
| 161 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') { |
|
| 162 | + print ' selected'; |
|
| 163 | +} |
|
| 164 | +?>>Airport warning</option> |
|
| 165 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') { |
|
| 166 | + print ' selected'; |
|
| 167 | +} |
|
| 168 | +?>>Navigation warning</option> |
|
| 169 | + <option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') { |
|
| 170 | + print ' selected'; |
|
| 171 | +} |
|
| 172 | +?>>Enroute warning</option> |
|
| 158 | 173 | </select |
| 159 | 174 | </li> |
| 160 | 175 | </ul> |
@@ -182,7 +197,12 @@ discard block |
||
| 182 | 197 | <div class="form-group"> |
| 183 | 198 | <label>From (UTC):</label> |
| 184 | 199 | <div class='input-group date' id='datetimepicker1'> |
| 185 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required /> |
|
| 200 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) { |
|
| 201 | + print $_POST['start_date']; |
|
| 202 | +} elseif (isset($_COOKIE['archive_begin'])) { |
|
| 203 | + print date("m/d/Y h:i a",$_COOKIE['archive_begin']); |
|
| 204 | +} |
|
| 205 | +?>" required /> |
|
| 186 | 206 | <span class="input-group-addon"> |
| 187 | 207 | <span class="glyphicon glyphicon-calendar"></span> |
| 188 | 208 | </span> |
@@ -191,7 +211,12 @@ discard block |
||
| 191 | 211 | <div class="form-group"> |
| 192 | 212 | <label>To (UTC):</label> |
| 193 | 213 | <div class='input-group date' id='datetimepicker2'> |
| 194 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" /> |
|
| 214 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) { |
|
| 215 | + print $_POST['end_date']; |
|
| 216 | +} elseif (isset($_COOKIE['archive_end'])) { |
|
| 217 | + print date("m/d/Y h:i a",$_COOKIE['archive_end']); |
|
| 218 | +} |
|
| 219 | +?>" /> |
|
| 195 | 220 | <span class="input-group-addon"> |
| 196 | 221 | <span class="glyphicon glyphicon-calendar"></span> |
| 197 | 222 | </span> |
@@ -217,8 +242,20 @@ discard block |
||
| 217 | 242 | |
| 218 | 243 | <li><?php echo _("Playback speed:"); ?> |
| 219 | 244 | <div class="range"> |
| 220 | - <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>"> |
|
| 221 | - <output id="archivespeedrange"><?php if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output> |
|
| 245 | + <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php if (isset($_POST['archivespeed'])) { |
|
| 246 | + print $_POST['archivespeed']; |
|
| 247 | +} elseif (isset($_COOKIE['archive_speed'])) { |
|
| 248 | + print $_COOKIE['archive_speed']; |
|
| 249 | +} else { |
|
| 250 | + print '1'; |
|
| 251 | +} |
|
| 252 | +?>"> |
|
| 253 | + <output id="archivespeedrange"><?php if (isset($_COOKIE['archive_speed'])) { |
|
| 254 | + print $_COOKIE['archive_speed']; |
|
| 255 | +} else { |
|
| 256 | + print '1'; |
|
| 257 | +} |
|
| 258 | +?></output> |
|
| 222 | 259 | </div> |
| 223 | 260 | </li> |
| 224 | 261 | <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li> |
@@ -240,15 +277,27 @@ discard block |
||
| 240 | 277 | <li><?php echo _("Type of Map:"); ?> |
| 241 | 278 | <select class="selectpicker" onchange="mapType(this);"> |
| 242 | 279 | <?php |
| 243 | - if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
|
| 244 | - else $MapType = $_COOKIE['MapType']; |
|
| 280 | + if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') { |
|
| 281 | + $MapType = $globalMapProvider; |
|
| 282 | + } else { |
|
| 283 | + $MapType = $_COOKIE['MapType']; |
|
| 284 | + } |
|
| 245 | 285 | ?> |
| 246 | 286 | <?php |
| 247 | 287 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
| 248 | 288 | ?> |
| 249 | - <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
|
| 250 | - <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
|
| 251 | - <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
|
| 289 | + <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') { |
|
| 290 | + print ' selected'; |
|
| 291 | +} |
|
| 292 | +?>>Bing-Aerial</option> |
|
| 293 | + <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') { |
|
| 294 | + print ' selected'; |
|
| 295 | +} |
|
| 296 | +?>>Bing-Hybrid</option> |
|
| 297 | + <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') { |
|
| 298 | + print ' selected'; |
|
| 299 | +} |
|
| 300 | +?>>Bing-Road</option> |
|
| 252 | 301 | <?php |
| 253 | 302 | } |
| 254 | 303 | ?> |
@@ -258,56 +307,131 @@ discard block |
||
| 258 | 307 | <?php |
| 259 | 308 | if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
| 260 | 309 | ?> |
| 261 | - <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
|
| 262 | - <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
|
| 263 | - <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
|
| 310 | + <option value="Here-Aerial"<?php if ($MapType == 'Here') { |
|
| 311 | + print ' selected'; |
|
| 312 | +} |
|
| 313 | +?>>Here-Aerial</option> |
|
| 314 | + <option value="Here-Hybrid"<?php if ($MapType == 'Here') { |
|
| 315 | + print ' selected'; |
|
| 316 | +} |
|
| 317 | +?>>Here-Hybrid</option> |
|
| 318 | + <option value="Here-Road"<?php if ($MapType == 'Here') { |
|
| 319 | + print ' selected'; |
|
| 320 | +} |
|
| 321 | +?>>Here-Road</option> |
|
| 264 | 322 | <?php |
| 265 | 323 | } |
| 266 | 324 | ?> |
| 267 | 325 | <?php |
| 268 | 326 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
| 269 | 327 | ?> |
| 270 | - <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
|
| 271 | - <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
|
| 272 | - <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
|
| 273 | - <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
|
| 328 | + <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') { |
|
| 329 | + print ' selected'; |
|
| 330 | +} |
|
| 331 | +?>>Google Roadmap</option> |
|
| 332 | + <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') { |
|
| 333 | + print ' selected'; |
|
| 334 | +} |
|
| 335 | +?>>Google Satellite</option> |
|
| 336 | + <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') { |
|
| 337 | + print ' selected'; |
|
| 338 | +} |
|
| 339 | +?>>Google Hybrid</option> |
|
| 340 | + <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') { |
|
| 341 | + print ' selected'; |
|
| 342 | +} |
|
| 343 | +?>>Google Terrain</option> |
|
| 274 | 344 | <?php |
| 275 | 345 | } |
| 276 | 346 | ?> |
| 277 | 347 | <?php |
| 278 | 348 | if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
| 279 | 349 | ?> |
| 280 | - <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
|
| 281 | - <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
|
| 282 | - <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
|
| 350 | + <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') { |
|
| 351 | + print ' selected'; |
|
| 352 | +} |
|
| 353 | +?>>MapQuest-OSM</option> |
|
| 354 | + <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') { |
|
| 355 | + print ' selected'; |
|
| 356 | +} |
|
| 357 | +?>>MapQuest-Aerial</option> |
|
| 358 | + <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') { |
|
| 359 | + print ' selected'; |
|
| 360 | +} |
|
| 361 | +?>>MapQuest-Hybrid</option> |
|
| 283 | 362 | <?php |
| 284 | 363 | } |
| 285 | 364 | ?> |
| 286 | - <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
|
| 365 | + <option value="Yandex"<?php if ($MapType == 'Yandex') { |
|
| 366 | + print ' selected'; |
|
| 367 | +} |
|
| 368 | +?>>Yandex</option> |
|
| 287 | 369 | <?php |
| 288 | 370 | } |
| 289 | 371 | ?> |
| 290 | 372 | <?php |
| 291 | 373 | if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
| 292 | - if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
|
| 293 | - else $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 374 | + if (!isset($_COOKIE['MapTypeId'])) { |
|
| 375 | + $MapBoxId = 'default'; |
|
| 376 | + } else { |
|
| 377 | + $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 378 | + } |
|
| 294 | 379 | ?> |
| 295 | - <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
|
| 296 | - <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
|
| 297 | - <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
|
| 298 | - <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option> |
|
| 299 | - <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option> |
|
| 300 | - <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option> |
|
| 301 | - <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option> |
|
| 302 | - <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option> |
|
| 303 | - <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option> |
|
| 304 | - <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option> |
|
| 305 | - <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
|
| 306 | - <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
|
| 380 | + <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') { |
|
| 381 | + print ' selected'; |
|
| 382 | +} |
|
| 383 | +?>>Mapbox default</option> |
|
| 384 | + <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') { |
|
| 385 | + print ' selected'; |
|
| 386 | +} |
|
| 387 | +?>>Mapbox streets</option> |
|
| 388 | + <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') { |
|
| 389 | + print ' selected'; |
|
| 390 | +} |
|
| 391 | +?>>Mapbox light</option> |
|
| 392 | + <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') { |
|
| 393 | + print ' selected'; |
|
| 394 | +} |
|
| 395 | +?>>Mapbox dark</option> |
|
| 396 | + <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') { |
|
| 397 | + print ' selected'; |
|
| 398 | +} |
|
| 399 | +?>>Mapbox satellite</option> |
|
| 400 | + <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') { |
|
| 401 | + print ' selected'; |
|
| 402 | +} |
|
| 403 | +?>>Mapbox streets-satellite</option> |
|
| 404 | + <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') { |
|
| 405 | + print ' selected'; |
|
| 406 | +} |
|
| 407 | +?>>Mapbox streets-basic</option> |
|
| 408 | + <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') { |
|
| 409 | + print ' selected'; |
|
| 410 | +} |
|
| 411 | +?>>Mapbox comic</option> |
|
| 412 | + <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') { |
|
| 413 | + print ' selected'; |
|
| 414 | +} |
|
| 415 | +?>>Mapbox outdoors</option> |
|
| 416 | + <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') { |
|
| 417 | + print ' selected'; |
|
| 418 | +} |
|
| 419 | +?>>Mapbox pencil</option> |
|
| 420 | + <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') { |
|
| 421 | + print ' selected'; |
|
| 422 | +} |
|
| 423 | +?>>Mapbox pirates</option> |
|
| 424 | + <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') { |
|
| 425 | + print ' selected'; |
|
| 426 | +} |
|
| 427 | +?>>Mapbox emerald</option> |
|
| 307 | 428 | <?php |
| 308 | 429 | } |
| 309 | 430 | ?> |
| 310 | - <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
|
| 431 | + <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') { |
|
| 432 | + print ' selected'; |
|
| 433 | +} |
|
| 434 | +?>>OpenStreetMap</option> |
|
| 311 | 435 | </select> |
| 312 | 436 | </li> |
| 313 | 437 | <?php |
@@ -315,9 +439,18 @@ discard block |
||
| 315 | 439 | ?> |
| 316 | 440 | <li><?php echo _("Type of Terrain:"); ?> |
| 317 | 441 | <select class="selectpicker" onchange="terrainType(this);"> |
| 318 | - <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option> |
|
| 319 | - <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option> |
|
| 320 | - <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option> |
|
| 442 | + <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') { |
|
| 443 | + print ' selected'; |
|
| 444 | +} |
|
| 445 | +?>>stk terrain</option> |
|
| 446 | + <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') { |
|
| 447 | + print ' selected'; |
|
| 448 | +} |
|
| 449 | +?>>ellipsoid</option> |
|
| 450 | + <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') { |
|
| 451 | + print ' selected'; |
|
| 452 | +} |
|
| 453 | +?>>vr terrain</option> |
|
| 321 | 454 | </select> |
| 322 | 455 | </li> |
| 323 | 456 | <?php |
@@ -327,18 +460,36 @@ discard block |
||
| 327 | 460 | if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
| 328 | 461 | ?> |
| 329 | 462 | |
| 330 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
|
| 331 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li> |
|
| 332 | - <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
|
| 333 | - <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
|
| 463 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') { |
|
| 464 | + print 'checked'; |
|
| 465 | +} |
|
| 466 | +?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
|
| 467 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) { |
|
| 468 | + print 'checked'; |
|
| 469 | +} |
|
| 470 | +?> ><?php echo _("Display flight path"); ?></label></div></li> |
|
| 471 | + <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) { |
|
| 472 | + print 'checked'; |
|
| 473 | +} |
|
| 474 | +?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
|
| 475 | + <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) { |
|
| 476 | + print 'checked'; |
|
| 477 | +} |
|
| 478 | +?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
|
| 334 | 479 | <?php |
| 335 | 480 | } |
| 336 | 481 | ?> |
| 337 | - <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
|
| 482 | + <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') { |
|
| 483 | + print 'checked'; |
|
| 484 | +} |
|
| 485 | +?> ><?php echo _("Display airports on map"); ?></label></div></li> |
|
| 338 | 486 | <?php |
| 339 | 487 | if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
| 340 | 488 | ?> |
| 341 | - <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
|
| 489 | + <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) { |
|
| 490 | + print 'checked'; |
|
| 491 | +} |
|
| 492 | +?> ><?php echo _("Show mini-map"); ?></label></div></li> |
|
| 342 | 493 | <?php |
| 343 | 494 | } |
| 344 | 495 | if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
@@ -352,17 +503,25 @@ discard block |
||
| 352 | 503 | if (function_exists('array_column')) { |
| 353 | 504 | if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
| 354 | 505 | ?> |
| 355 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
| 506 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
|
| 507 | + print 'checked'; |
|
| 508 | +} |
|
| 509 | +?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
| 356 | 510 | <?php |
| 357 | 511 | } |
| 358 | 512 | } elseif (isset($globalSources)) { |
| 359 | 513 | $dispolar = false; |
| 360 | 514 | foreach ($globalSources as $testsource) { |
| 361 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
| 515 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) { |
|
| 516 | + $dispolar = true; |
|
| 517 | + } |
|
| 362 | 518 | } |
| 363 | 519 | if ($dispolar) { |
| 364 | 520 | ?> |
| 365 | - <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
| 521 | + <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
|
| 522 | + print 'checked'; |
|
| 523 | +} |
|
| 524 | +?> ><?php echo _("Display polar on map"); ?></label></div></li> |
|
| 366 | 525 | <?php |
| 367 | 526 | } |
| 368 | 527 | } |
@@ -374,12 +533,22 @@ discard block |
||
| 374 | 533 | <?php |
| 375 | 534 | if (extension_loaded('gd') && function_exists('gd_info')) { |
| 376 | 535 | ?> |
| 377 | - <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
|
| 536 | + <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') { |
|
| 537 | + print 'checked'; |
|
| 538 | +} |
|
| 539 | +?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
|
| 378 | 540 | <?php |
| 379 | 541 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
| 380 | 542 | ?> |
| 381 | 543 | <li><?php echo _("Aircraft icon color:"); ?> |
| 382 | - <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
|
| 544 | + <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) { |
|
| 545 | + print $_COOKIE['IconColor']; |
|
| 546 | +} elseif (isset($globalAircraftIconColor)) { |
|
| 547 | + print $globalAircraftIconColor; |
|
| 548 | +} else { |
|
| 549 | + print '1a3151'; |
|
| 550 | +} |
|
| 551 | +?>"> |
|
| 383 | 552 | </li> |
| 384 | 553 | <?php |
| 385 | 554 | } |
@@ -389,30 +558,71 @@ discard block |
||
| 389 | 558 | if (extension_loaded('gd') && function_exists('gd_info')) { |
| 390 | 559 | ?> |
| 391 | 560 | <li><?php echo _("Marine icon color:"); ?> |
| 392 | - <input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>"> |
|
| 561 | + <input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) { |
|
| 562 | + print $_COOKIE['MarineIconColor']; |
|
| 563 | +} elseif (isset($globalMarineIconColor)) { |
|
| 564 | + print $globalMarineIconColor; |
|
| 565 | +} else { |
|
| 566 | + print '1a3151'; |
|
| 567 | +} |
|
| 568 | +?>"> |
|
| 393 | 569 | </li> |
| 394 | 570 | <?php |
| 395 | 571 | } |
| 396 | 572 | ?> |
| 397 | 573 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
| 398 | 574 | <div class="range"> |
| 399 | - <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
|
| 400 | - <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output> |
|
| 575 | + <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) { |
|
| 576 | + print $_COOKIE['AirportZoom']; |
|
| 577 | +} elseif (isset($globalAirportZoom)) { |
|
| 578 | + print $globalAirportZoom; |
|
| 579 | +} else { |
|
| 580 | + print '7'; |
|
| 581 | +} |
|
| 582 | +?>"> |
|
| 583 | + <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) { |
|
| 584 | + print $_COOKIE['AirportZoom']; |
|
| 585 | +} elseif (isset($globalAirportZoom)) { |
|
| 586 | + print $globalAirportZoom; |
|
| 587 | +} else { |
|
| 588 | + print '7'; |
|
| 589 | +} |
|
| 590 | +?></output> |
|
| 401 | 591 | </div> |
| 402 | 592 | </li> |
| 403 | 593 | <?php |
| 404 | 594 | } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
| 405 | 595 | ?> |
| 406 | - <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li> |
|
| 596 | + <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') { |
|
| 597 | + print 'checked'; |
|
| 598 | +} |
|
| 599 | +?> ><?php echo _("Force Aircraft color"); ?></li> |
|
| 407 | 600 | <li><?php echo _("Aircraft icon color:"); ?> |
| 408 | - <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>"> |
|
| 601 | + <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) { |
|
| 602 | + print $_COOKIE['IconColor']; |
|
| 603 | +} elseif (isset($globalAircraftIconColor)) { |
|
| 604 | + print $globalAircraftIconColor; |
|
| 605 | +} else { |
|
| 606 | + print 'ff0000'; |
|
| 607 | +} |
|
| 608 | +?>"> |
|
| 409 | 609 | </li> |
| 410 | 610 | <?php |
| 411 | 611 | if (isset($globalMarine) && $globalMarine) { |
| 412 | 612 | ?> |
| 413 | - <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li> |
|
| 613 | + <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') { |
|
| 614 | + print 'checked'; |
|
| 615 | +} |
|
| 616 | +?> ><?php echo _("Force Marine color"); ?></li> |
|
| 414 | 617 | <li><?php echo _("Marine icon color:"); ?> |
| 415 | - <input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>"> |
|
| 618 | + <input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) { |
|
| 619 | + print $_COOKIE['MarineIconColor']; |
|
| 620 | +} elseif (isset($globalMarineIconColor)) { |
|
| 621 | + print $globalMarineIconColor; |
|
| 622 | +} else { |
|
| 623 | + print 'ff0000'; |
|
| 624 | +} |
|
| 625 | +?>"> |
|
| 416 | 626 | </li> |
| 417 | 627 | <?php |
| 418 | 628 | } |
@@ -420,22 +630,46 @@ discard block |
||
| 420 | 630 | ?> |
| 421 | 631 | <li><?php echo _("Distance unit:"); ?> |
| 422 | 632 | <select class="selectpicker" onchange="unitdistance(this);"> |
| 423 | - <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option> |
|
| 424 | - <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option> |
|
| 425 | - <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option> |
|
| 633 | + <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
|
| 634 | + echo ' selected'; |
|
| 635 | +} |
|
| 636 | +?>>km</option> |
|
| 637 | + <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
|
| 638 | + echo ' selected'; |
|
| 639 | +} |
|
| 640 | +?>>nm</option> |
|
| 641 | + <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
|
| 642 | + echo ' selected'; |
|
| 643 | +} |
|
| 644 | +?>>mi</option> |
|
| 426 | 645 | </select> |
| 427 | 646 | </li> |
| 428 | 647 | <li><?php echo _("Altitude unit:"); ?> |
| 429 | 648 | <select class="selectpicker" onchange="unitaltitude(this);"> |
| 430 | - <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option> |
|
| 431 | - <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option> |
|
| 649 | + <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) { |
|
| 650 | + echo ' selected'; |
|
| 651 | +} |
|
| 652 | +?>>m</option> |
|
| 653 | + <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
|
| 654 | + echo ' selected'; |
|
| 655 | +} |
|
| 656 | +?>>feet</option> |
|
| 432 | 657 | </select> |
| 433 | 658 | </li> |
| 434 | 659 | <li><?php echo _("Speed unit:"); ?> |
| 435 | 660 | <select class="selectpicker" onchange="unitspeed(this);"> |
| 436 | - <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option> |
|
| 437 | - <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option> |
|
| 438 | - <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option> |
|
| 661 | + <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) { |
|
| 662 | + echo ' selected'; |
|
| 663 | +} |
|
| 664 | +?>>km/h</option> |
|
| 665 | + <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
|
| 666 | + echo ' selected'; |
|
| 667 | +} |
|
| 668 | +?>>mph</option> |
|
| 669 | + <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) { |
|
| 670 | + echo ' selected'; |
|
| 671 | +} |
|
| 672 | +?>>knots</option> |
|
| 439 | 673 | </select> |
| 440 | 674 | </li> |
| 441 | 675 | |
@@ -450,9 +684,18 @@ discard block |
||
| 450 | 684 | <?php |
| 451 | 685 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
| 452 | 686 | ?> |
| 453 | - <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
|
| 454 | - <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
|
| 455 | - <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
|
| 687 | + <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) { |
|
| 688 | + print 'checked'; |
|
| 689 | +} |
|
| 690 | +?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
|
| 691 | + <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) { |
|
| 692 | + print 'checked'; |
|
| 693 | +} |
|
| 694 | +?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
|
| 695 | + <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) { |
|
| 696 | + print 'checked'; |
|
| 697 | +} |
|
| 698 | +?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
|
| 456 | 699 | <?php |
| 457 | 700 | } |
| 458 | 701 | ?> |
@@ -460,10 +703,16 @@ discard block |
||
| 460 | 703 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
| 461 | 704 | ?> |
| 462 | 705 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
| 463 | - <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
|
| 706 | + <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) { |
|
| 707 | + print 'checked'; |
|
| 708 | +} |
|
| 709 | +?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
|
| 464 | 710 | <?php } ?> |
| 465 | 711 | <?php if (isset($globalAPRS) && $globalAPRS) { ?> |
| 466 | - <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li> |
|
| 712 | + <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) { |
|
| 713 | + print 'checked'; |
|
| 714 | +} |
|
| 715 | +?> ><?php echo _("Display APRS data"); ?></label></div></li> |
|
| 467 | 716 | <?php } ?> |
| 468 | 717 | <?php |
| 469 | 718 | } |
@@ -480,7 +729,9 @@ discard block |
||
| 480 | 729 | } |
| 481 | 730 | foreach($allairlinenames as $airline) { |
| 482 | 731 | $airline_name = $airline['airline_name']; |
| 483 | - if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...'; |
|
| 732 | + if (strlen($airline_name) > 30) { |
|
| 733 | + $airline_name = substr($airline_name,0,30).'...'; |
|
| 734 | + } |
|
| 484 | 735 | if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) { |
| 485 | 736 | echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>'; |
| 486 | 737 | } else { |
@@ -498,7 +749,10 @@ discard block |
||
| 498 | 749 | <li><?php echo _("Display alliance:"); ?> |
| 499 | 750 | <br/> |
| 500 | 751 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
| 501 | - <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
|
| 752 | + <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') { |
|
| 753 | + echo ' selected'; |
|
| 754 | +} |
|
| 755 | +?>><?php echo _("All"); ?></option> |
|
| 502 | 756 | <?php |
| 503 | 757 | foreach($allalliancenames as $alliance) { |
| 504 | 758 | $alliance_name = $alliance['alliance']; |
@@ -539,10 +793,22 @@ discard block |
||
| 539 | 793 | ?> |
| 540 | 794 | <li><?php echo _("Display airlines of type:"); ?><br/> |
| 541 | 795 | <select class="selectpicker" onchange="airlinestype(this);"> |
| 542 | - <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
|
| 543 | - <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option> |
|
| 544 | - <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option> |
|
| 545 | - <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option> |
|
| 796 | + <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') { |
|
| 797 | + echo ' selected'; |
|
| 798 | +} |
|
| 799 | +?>><?php echo _("All"); ?></option> |
|
| 800 | + <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') { |
|
| 801 | + echo ' selected'; |
|
| 802 | +} |
|
| 803 | +?>><?php echo _("Passenger"); ?></option> |
|
| 804 | + <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') { |
|
| 805 | + echo ' selected'; |
|
| 806 | +} |
|
| 807 | +?>><?php echo _("Cargo"); ?></option> |
|
| 808 | + <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') { |
|
| 809 | + echo ' selected'; |
|
| 810 | +} |
|
| 811 | +?>><?php echo _("Military"); ?></option> |
|
| 546 | 812 | </select> |
| 547 | 813 | </li> |
| 548 | 814 | <?php |
@@ -550,7 +816,10 @@ discard block |
||
| 550 | 816 | ?> |
| 551 | 817 | <li> |
| 552 | 818 | <?php echo _("Display flight with ident:"); ?> |
| 553 | - <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
|
| 819 | + <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) { |
|
| 820 | + print $_COOKIE['filter_ident']; |
|
| 821 | +} |
|
| 822 | +?>" /> |
|
| 554 | 823 | </li> |
| 555 | 824 | </ul> |
| 556 | 825 | </form> |
@@ -566,7 +835,10 @@ discard block |
||
| 566 | 835 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
| 567 | 836 | <form> |
| 568 | 837 | <ul> |
| 569 | - <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li> |
|
| 838 | + <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') { |
|
| 839 | + print 'checked'; |
|
| 840 | +} |
|
| 841 | +?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li> |
|
| 570 | 842 | <li><?php echo _("Type:"); ?> |
| 571 | 843 | <select class="selectpicker" multiple onchange="sattypes(this);"> |
| 572 | 844 | <?php |
@@ -574,25 +846,45 @@ discard block |
||
| 574 | 846 | $types = $Satellite->get_tle_types(); |
| 575 | 847 | foreach ($types as $type) { |
| 576 | 848 | $type_name = $type['tle_type']; |
| 577 | - if ($type_name == 'musson') $type_name = 'Russian LEO Navigation'; |
|
| 578 | - else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System'; |
|
| 579 | - else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System'; |
|
| 580 | - else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational'; |
|
| 581 | - else if ($type_name == 'gps-ops') $type_name = 'GPS Operational'; |
|
| 582 | - else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System'; |
|
| 583 | - else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System'; |
|
| 584 | - else if ($type_name == 'sarsat') $type_name = 'Search & Rescue'; |
|
| 585 | - else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring'; |
|
| 586 | - else if ($type_name == 'resource') $type_name = 'Earth Resources'; |
|
| 587 | - else if ($type_name == 'stations') $type_name = 'Space Stations'; |
|
| 588 | - else if ($type_name == 'geo') $type_name = 'Geostationary'; |
|
| 589 | - else if ($type_name == 'amateur') $type_name = 'Amateur Radio'; |
|
| 590 | - else if ($type_name == 'x-comm') $type_name = 'Experimental'; |
|
| 591 | - else if ($type_name == 'other-comm') $type_name = 'Other Comm'; |
|
| 592 | - else if ($type_name == 'science') $type_name = 'Space & Earth Science'; |
|
| 593 | - else if ($type_name == 'military') $type_name = 'Miscellaneous Military'; |
|
| 594 | - else if ($type_name == 'radar') $type_name = 'Radar Calibration'; |
|
| 595 | - else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches'; |
|
| 849 | + if ($type_name == 'musson') { |
|
| 850 | + $type_name = 'Russian LEO Navigation'; |
|
| 851 | + } else if ($type_name == 'nnss') { |
|
| 852 | + $type_name = 'Navi Navigation Satellite System'; |
|
| 853 | + } else if ($type_name == 'sbas') { |
|
| 854 | + $type_name = 'Satellite-Based Augmentation System'; |
|
| 855 | + } else if ($type_name == 'glo-ops') { |
|
| 856 | + $type_name = 'Glonass Operational'; |
|
| 857 | + } else if ($type_name == 'gps-ops') { |
|
| 858 | + $type_name = 'GPS Operational'; |
|
| 859 | + } else if ($type_name == 'argos') { |
|
| 860 | + $type_name = 'ARGOS Data Collection System'; |
|
| 861 | + } else if ($type_name == 'tdrss') { |
|
| 862 | + $type_name = 'Tracking and Data Relay Satellite System'; |
|
| 863 | + } else if ($type_name == 'sarsat') { |
|
| 864 | + $type_name = 'Search & Rescue'; |
|
| 865 | + } else if ($type_name == 'dmc') { |
|
| 866 | + $type_name = 'Disaster Monitoring'; |
|
| 867 | + } else if ($type_name == 'resource') { |
|
| 868 | + $type_name = 'Earth Resources'; |
|
| 869 | + } else if ($type_name == 'stations') { |
|
| 870 | + $type_name = 'Space Stations'; |
|
| 871 | + } else if ($type_name == 'geo') { |
|
| 872 | + $type_name = 'Geostationary'; |
|
| 873 | + } else if ($type_name == 'amateur') { |
|
| 874 | + $type_name = 'Amateur Radio'; |
|
| 875 | + } else if ($type_name == 'x-comm') { |
|
| 876 | + $type_name = 'Experimental'; |
|
| 877 | + } else if ($type_name == 'other-comm') { |
|
| 878 | + $type_name = 'Other Comm'; |
|
| 879 | + } else if ($type_name == 'science') { |
|
| 880 | + $type_name = 'Space & Earth Science'; |
|
| 881 | + } else if ($type_name == 'military') { |
|
| 882 | + $type_name = 'Miscellaneous Military'; |
|
| 883 | + } else if ($type_name == 'radar') { |
|
| 884 | + $type_name = 'Radar Calibration'; |
|
| 885 | + } else if ($type_name == 'tle-new') { |
|
| 886 | + $type_name = 'Last 30 days launches'; |
|
| 887 | + } |
|
| 596 | 888 | |
| 597 | 889 | if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) { |
| 598 | 890 | print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>'; |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | $this->db = $Connection->db; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Get SQL query part for filter used |
|
| 13 | - * @param Array $filter the filter |
|
| 14 | - * @return Array the SQL part |
|
| 15 | - */ |
|
| 16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 11 | + /** |
|
| 12 | + * Get SQL query part for filter used |
|
| 13 | + * @param Array $filter the filter |
|
| 14 | + * @return Array the SQL part |
|
| 15 | + */ |
|
| 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])) { |
@@ -30,88 +30,88 @@ discard block |
||
| 30 | 30 | $filter_query_join = ''; |
| 31 | 31 | $filter_query_where = ''; |
| 32 | 32 | foreach($filters as $flt) { |
| 33 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 33 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 34 | 34 | if ($flt['airlines'][0] != '') { |
| 35 | - if (isset($flt['source'])) { |
|
| 35 | + if (isset($flt['source'])) { |
|
| 36 | 36 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 37 | - } else { |
|
| 37 | + } else { |
|
| 38 | 38 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 39 | - } |
|
| 39 | + } |
|
| 40 | + } |
|
| 40 | 41 | } |
| 41 | - } |
|
| 42 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 42 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 43 | 43 | if (isset($flt['source'])) { |
| 44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | 45 | } else { |
| 46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | 47 | } |
| 48 | - } |
|
| 49 | - if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
| 48 | + } |
|
| 49 | + if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
| 50 | 50 | if (isset($flt['source'])) { |
| 51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | 52 | } else { |
| 53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + } |
|
| 54 | 55 | } |
| 55 | - } |
|
| 56 | - if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
| 56 | + if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
| 57 | 57 | if (isset($flt['source'])) { |
| 58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | 59 | } else { |
| 60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + } |
|
| 61 | 62 | } |
| 62 | - } |
|
| 63 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
| 63 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
| 64 | 64 | if (isset($flt['source'])) { |
| 65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | + } |
|
| 66 | 67 | } |
| 67 | - } |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 70 | - if ($filter['airlines'][0] != '') { |
|
| 70 | + if ($filter['airlines'][0] != '') { |
|
| 71 | 71 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
| 72 | - } |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 76 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 76 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | 80 | } |
| 81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 82 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 85 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 85 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 88 | 88 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 89 | 89 | } |
| 90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 91 | - $filter_query_date = ''; |
|
| 91 | + $filter_query_date = ''; |
|
| 92 | 92 | |
| 93 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
| 93 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
| 94 | 94 | if ($globalDBdriver == 'mysql') { |
| 95 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 95 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 96 | 96 | } else { |
| 97 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 97 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 98 | + } |
|
| 98 | 99 | } |
| 99 | - } |
|
| 100 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
| 100 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
| 101 | 101 | if ($globalDBdriver == 'mysql') { |
| 102 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 102 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 103 | 103 | } else { |
| 104 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 104 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 105 | 105 | } |
| 106 | - } |
|
| 107 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
| 106 | + } |
|
| 107 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
| 108 | 108 | if ($globalDBdriver == 'mysql') { |
| 109 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 109 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 110 | 110 | } else { |
| 111 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 111 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 112 | + } |
|
| 112 | 113 | } |
| 113 | - } |
|
| 114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 115 | 115 | } |
| 116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
| 122 | 122 | return $filter_query; |
| 123 | - } |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | // Spotter_archive |
| 126 | 126 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -151,44 +151,44 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * Gets all the spotter information based on a particular callsign |
|
| 156 | - * |
|
| 157 | - * @return Array the spotter information |
|
| 158 | - * |
|
| 159 | - */ |
|
| 160 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 161 | - { |
|
| 154 | + /** |
|
| 155 | + * Gets all the spotter information based on a particular callsign |
|
| 156 | + * |
|
| 157 | + * @return Array the spotter information |
|
| 158 | + * |
|
| 159 | + */ |
|
| 160 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 161 | + { |
|
| 162 | 162 | $Spotter = new Spotter($this->db); |
| 163 | - date_default_timezone_set('UTC'); |
|
| 163 | + date_default_timezone_set('UTC'); |
|
| 164 | 164 | |
| 165 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 166 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 167 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 165 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 166 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 167 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 168 | 168 | |
| 169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 169 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 170 | 170 | |
| 171 | - return $spotter_array; |
|
| 172 | - } |
|
| 171 | + return $spotter_array; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Gets last the spotter information based on a particular id |
|
| 177 | - * |
|
| 178 | - * @return Array the spotter information |
|
| 179 | - * |
|
| 180 | - */ |
|
| 181 | - public function getLastArchiveSpotterDataById($id) |
|
| 182 | - { |
|
| 183 | - $Spotter = new Spotter($this->db); |
|
| 184 | - date_default_timezone_set('UTC'); |
|
| 185 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 186 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 187 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 188 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 175 | + /** |
|
| 176 | + * Gets last the spotter information based on a particular id |
|
| 177 | + * |
|
| 178 | + * @return Array the spotter information |
|
| 179 | + * |
|
| 180 | + */ |
|
| 181 | + public function getLastArchiveSpotterDataById($id) |
|
| 182 | + { |
|
| 183 | + $Spotter = new Spotter($this->db); |
|
| 184 | + date_default_timezone_set('UTC'); |
|
| 185 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 186 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 187 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 188 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 189 | 189 | |
| 190 | 190 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 191 | - /* |
|
| 191 | + /* |
|
| 192 | 192 | try { |
| 193 | 193 | $Connection = new Connection(); |
| 194 | 194 | $sth = Connection->$db->prepare($query); |
@@ -198,232 +198,232 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 200 | 200 | */ |
| 201 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 202 | - |
|
| 203 | - return $spotter_array; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Gets all the spotter information based on a particular id |
|
| 208 | - * |
|
| 209 | - * @return Array the spotter information |
|
| 210 | - * |
|
| 211 | - */ |
|
| 212 | - public function getAllArchiveSpotterDataById($id) |
|
| 213 | - { |
|
| 214 | - date_default_timezone_set('UTC'); |
|
| 215 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 216 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 201 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 202 | + |
|
| 203 | + return $spotter_array; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Gets all the spotter information based on a particular id |
|
| 208 | + * |
|
| 209 | + * @return Array the spotter information |
|
| 210 | + * |
|
| 211 | + */ |
|
| 212 | + public function getAllArchiveSpotterDataById($id) |
|
| 213 | + { |
|
| 214 | + date_default_timezone_set('UTC'); |
|
| 215 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 216 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 217 | 217 | |
| 218 | 218 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 219 | 219 | |
| 220 | - try { |
|
| 221 | - $sth = $this->db->prepare($query); |
|
| 222 | - $sth->execute(array(':id' => $id)); |
|
| 223 | - } catch(PDOException $e) { |
|
| 224 | - echo $e->getMessage(); |
|
| 225 | - die; |
|
| 226 | - } |
|
| 227 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 228 | - |
|
| 229 | - return $spotter_array; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * Gets coordinate & time spotter information based on a particular id |
|
| 234 | - * |
|
| 235 | - * @return Array the spotter information |
|
| 236 | - * |
|
| 237 | - */ |
|
| 238 | - public function getCoordArchiveSpotterDataById($id) |
|
| 239 | - { |
|
| 240 | - date_default_timezone_set('UTC'); |
|
| 241 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 242 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 220 | + try { |
|
| 221 | + $sth = $this->db->prepare($query); |
|
| 222 | + $sth->execute(array(':id' => $id)); |
|
| 223 | + } catch(PDOException $e) { |
|
| 224 | + echo $e->getMessage(); |
|
| 225 | + die; |
|
| 226 | + } |
|
| 227 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 228 | + |
|
| 229 | + return $spotter_array; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * Gets coordinate & time spotter information based on a particular id |
|
| 234 | + * |
|
| 235 | + * @return Array the spotter information |
|
| 236 | + * |
|
| 237 | + */ |
|
| 238 | + public function getCoordArchiveSpotterDataById($id) |
|
| 239 | + { |
|
| 240 | + date_default_timezone_set('UTC'); |
|
| 241 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 242 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 243 | 243 | |
| 244 | 244 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 245 | 245 | |
| 246 | - try { |
|
| 247 | - $sth = $this->db->prepare($query); |
|
| 248 | - $sth->execute(array(':id' => $id)); |
|
| 249 | - } catch(PDOException $e) { |
|
| 250 | - echo $e->getMessage(); |
|
| 251 | - die; |
|
| 252 | - } |
|
| 253 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 246 | + try { |
|
| 247 | + $sth = $this->db->prepare($query); |
|
| 248 | + $sth->execute(array(':id' => $id)); |
|
| 249 | + } catch(PDOException $e) { |
|
| 250 | + echo $e->getMessage(); |
|
| 251 | + die; |
|
| 252 | + } |
|
| 253 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 254 | 254 | |
| 255 | - return $spotter_array; |
|
| 256 | - } |
|
| 255 | + return $spotter_array; |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Gets altitude information based on a particular callsign |
|
| 261 | - * |
|
| 262 | - * @return Array the spotter information |
|
| 263 | - * |
|
| 264 | - */ |
|
| 265 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 266 | - { |
|
| 259 | + /** |
|
| 260 | + * Gets altitude information based on a particular callsign |
|
| 261 | + * |
|
| 262 | + * @return Array the spotter information |
|
| 263 | + * |
|
| 264 | + */ |
|
| 265 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 266 | + { |
|
| 267 | 267 | |
| 268 | - date_default_timezone_set('UTC'); |
|
| 268 | + date_default_timezone_set('UTC'); |
|
| 269 | 269 | |
| 270 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 271 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 270 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 271 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 272 | 272 | |
| 273 | - try { |
|
| 274 | - $sth = $this->db->prepare($query); |
|
| 275 | - $sth->execute(array(':ident' => $ident)); |
|
| 276 | - } catch(PDOException $e) { |
|
| 277 | - echo $e->getMessage(); |
|
| 278 | - die; |
|
| 279 | - } |
|
| 280 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 273 | + try { |
|
| 274 | + $sth = $this->db->prepare($query); |
|
| 275 | + $sth->execute(array(':ident' => $ident)); |
|
| 276 | + } catch(PDOException $e) { |
|
| 277 | + echo $e->getMessage(); |
|
| 278 | + die; |
|
| 279 | + } |
|
| 280 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 281 | 281 | |
| 282 | - return $spotter_array; |
|
| 283 | - } |
|
| 282 | + return $spotter_array; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Gets altitude information based on a particular id |
|
| 287 | - * |
|
| 288 | - * @return Array the spotter information |
|
| 289 | - * |
|
| 290 | - */ |
|
| 291 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 292 | - { |
|
| 285 | + /** |
|
| 286 | + * Gets altitude information based on a particular id |
|
| 287 | + * |
|
| 288 | + * @return Array the spotter information |
|
| 289 | + * |
|
| 290 | + */ |
|
| 291 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 292 | + { |
|
| 293 | 293 | |
| 294 | - date_default_timezone_set('UTC'); |
|
| 294 | + date_default_timezone_set('UTC'); |
|
| 295 | 295 | |
| 296 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 297 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 296 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 297 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 298 | 298 | |
| 299 | - try { |
|
| 300 | - $sth = $this->db->prepare($query); |
|
| 301 | - $sth->execute(array(':id' => $id)); |
|
| 302 | - } catch(PDOException $e) { |
|
| 303 | - echo $e->getMessage(); |
|
| 304 | - die; |
|
| 305 | - } |
|
| 306 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 299 | + try { |
|
| 300 | + $sth = $this->db->prepare($query); |
|
| 301 | + $sth->execute(array(':id' => $id)); |
|
| 302 | + } catch(PDOException $e) { |
|
| 303 | + echo $e->getMessage(); |
|
| 304 | + die; |
|
| 305 | + } |
|
| 306 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 307 | 307 | |
| 308 | - return $spotter_array; |
|
| 309 | - } |
|
| 308 | + return $spotter_array; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - /** |
|
| 312 | - * Gets altitude & speed information based on a particular id |
|
| 313 | - * |
|
| 314 | - * @return Array the spotter information |
|
| 315 | - * |
|
| 316 | - */ |
|
| 317 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 318 | - { |
|
| 311 | + /** |
|
| 312 | + * Gets altitude & speed information based on a particular id |
|
| 313 | + * |
|
| 314 | + * @return Array the spotter information |
|
| 315 | + * |
|
| 316 | + */ |
|
| 317 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 318 | + { |
|
| 319 | 319 | |
| 320 | - date_default_timezone_set('UTC'); |
|
| 320 | + date_default_timezone_set('UTC'); |
|
| 321 | 321 | |
| 322 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 323 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 322 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 323 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 324 | 324 | |
| 325 | - try { |
|
| 326 | - $sth = $this->db->prepare($query); |
|
| 327 | - $sth->execute(array(':id' => $id)); |
|
| 328 | - } catch(PDOException $e) { |
|
| 329 | - echo $e->getMessage(); |
|
| 330 | - die; |
|
| 331 | - } |
|
| 332 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 325 | + try { |
|
| 326 | + $sth = $this->db->prepare($query); |
|
| 327 | + $sth->execute(array(':id' => $id)); |
|
| 328 | + } catch(PDOException $e) { |
|
| 329 | + echo $e->getMessage(); |
|
| 330 | + die; |
|
| 331 | + } |
|
| 332 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 333 | 333 | |
| 334 | - return $spotter_array; |
|
| 335 | - } |
|
| 334 | + return $spotter_array; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | 337 | |
| 338 | - /** |
|
| 339 | - * Gets altitude information based on a particular callsign |
|
| 340 | - * |
|
| 341 | - * @return Array the spotter information |
|
| 342 | - * |
|
| 343 | - */ |
|
| 344 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 345 | - { |
|
| 338 | + /** |
|
| 339 | + * Gets altitude information based on a particular callsign |
|
| 340 | + * |
|
| 341 | + * @return Array the spotter information |
|
| 342 | + * |
|
| 343 | + */ |
|
| 344 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 345 | + { |
|
| 346 | 346 | |
| 347 | - date_default_timezone_set('UTC'); |
|
| 347 | + date_default_timezone_set('UTC'); |
|
| 348 | 348 | |
| 349 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 350 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 349 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 350 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 351 | 351 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 352 | 352 | |
| 353 | - try { |
|
| 354 | - $sth = $this->db->prepare($query); |
|
| 355 | - $sth->execute(array(':ident' => $ident)); |
|
| 356 | - } catch(PDOException $e) { |
|
| 357 | - echo $e->getMessage(); |
|
| 358 | - die; |
|
| 359 | - } |
|
| 360 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 353 | + try { |
|
| 354 | + $sth = $this->db->prepare($query); |
|
| 355 | + $sth->execute(array(':ident' => $ident)); |
|
| 356 | + } catch(PDOException $e) { |
|
| 357 | + echo $e->getMessage(); |
|
| 358 | + die; |
|
| 359 | + } |
|
| 360 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 361 | 361 | |
| 362 | - return $spotter_array; |
|
| 363 | - } |
|
| 362 | + return $spotter_array; |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | 365 | |
| 366 | 366 | |
| 367 | - /** |
|
| 368 | - * Gets all the archive spotter information |
|
| 369 | - * |
|
| 370 | - * @return Array the spotter information |
|
| 371 | - * |
|
| 372 | - */ |
|
| 373 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 374 | - { |
|
| 375 | - $Spotter = new Spotter($this->db); |
|
| 376 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 377 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 367 | + /** |
|
| 368 | + * Gets all the archive spotter information |
|
| 369 | + * |
|
| 370 | + * @return Array the spotter information |
|
| 371 | + * |
|
| 372 | + */ |
|
| 373 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 374 | + { |
|
| 375 | + $Spotter = new Spotter($this->db); |
|
| 376 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 377 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 378 | 378 | |
| 379 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 379 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 380 | 380 | |
| 381 | - return $spotter_array; |
|
| 382 | - } |
|
| 381 | + return $spotter_array; |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - public function deleteSpotterArchiveTrackData() |
|
| 385 | - { |
|
| 384 | + public function deleteSpotterArchiveTrackData() |
|
| 385 | + { |
|
| 386 | 386 | global $globalArchiveKeepTrackMonths; |
| 387 | - date_default_timezone_set('UTC'); |
|
| 387 | + date_default_timezone_set('UTC'); |
|
| 388 | 388 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 389 | - try { |
|
| 390 | - $sth = $this->db->prepare($query); |
|
| 391 | - $sth->execute(); |
|
| 392 | - } catch(PDOException $e) { |
|
| 393 | - echo $e->getMessage(); |
|
| 394 | - die; |
|
| 395 | - } |
|
| 389 | + try { |
|
| 390 | + $sth = $this->db->prepare($query); |
|
| 391 | + $sth->execute(); |
|
| 392 | + } catch(PDOException $e) { |
|
| 393 | + echo $e->getMessage(); |
|
| 394 | + die; |
|
| 395 | + } |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
| 399 | - * Gets Minimal Live Spotter data |
|
| 400 | - * |
|
| 401 | - * @return Array the spotter information |
|
| 402 | - * |
|
| 403 | - */ |
|
| 404 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 405 | - { |
|
| 406 | - global $globalDBdriver, $globalLiveInterval; |
|
| 407 | - date_default_timezone_set('UTC'); |
|
| 408 | - |
|
| 409 | - $filter_query = ''; |
|
| 410 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 411 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 412 | - } |
|
| 413 | - // Use spotter_output also ? |
|
| 414 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 415 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 416 | - } |
|
| 417 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 418 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 419 | - } |
|
| 420 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 421 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 425 | - if ($globalDBdriver == 'mysql') { |
|
| 426 | - /* |
|
| 399 | + * Gets Minimal Live Spotter data |
|
| 400 | + * |
|
| 401 | + * @return Array the spotter information |
|
| 402 | + * |
|
| 403 | + */ |
|
| 404 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 405 | + { |
|
| 406 | + global $globalDBdriver, $globalLiveInterval; |
|
| 407 | + date_default_timezone_set('UTC'); |
|
| 408 | + |
|
| 409 | + $filter_query = ''; |
|
| 410 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 411 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 412 | + } |
|
| 413 | + // Use spotter_output also ? |
|
| 414 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 415 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 416 | + } |
|
| 417 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 418 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 419 | + } |
|
| 420 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 421 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 425 | + if ($globalDBdriver == 'mysql') { |
|
| 426 | + /* |
|
| 427 | 427 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 428 | 428 | FROM spotter_archive |
| 429 | 429 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -442,56 +442,56 @@ discard block |
||
| 442 | 442 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 443 | 443 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 444 | 444 | '.$filter_query.' ORDER BY flightaware_id'; |
| 445 | - } else { |
|
| 446 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 447 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 445 | + } else { |
|
| 446 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 447 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 448 | 448 | FROM spotter_archive |
| 449 | 449 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 450 | 450 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
| 451 | 451 | '.$filter_query.' ORDER BY flightaware_id'; |
| 452 | - } |
|
| 453 | - //echo $query; |
|
| 454 | - try { |
|
| 455 | - $sth = $this->db->prepare($query); |
|
| 456 | - $sth->execute(); |
|
| 457 | - } catch(PDOException $e) { |
|
| 458 | - echo $e->getMessage(); |
|
| 459 | - die; |
|
| 460 | - } |
|
| 461 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 462 | - |
|
| 463 | - return $spotter_array; |
|
| 464 | - } |
|
| 452 | + } |
|
| 453 | + //echo $query; |
|
| 454 | + try { |
|
| 455 | + $sth = $this->db->prepare($query); |
|
| 456 | + $sth->execute(); |
|
| 457 | + } catch(PDOException $e) { |
|
| 458 | + echo $e->getMessage(); |
|
| 459 | + die; |
|
| 460 | + } |
|
| 461 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 462 | + |
|
| 463 | + return $spotter_array; |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | 466 | /** |
| 467 | - * Gets Minimal Live Spotter data |
|
| 468 | - * |
|
| 469 | - * @return Array the spotter information |
|
| 470 | - * |
|
| 471 | - */ |
|
| 472 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 473 | - { |
|
| 474 | - global $globalDBdriver, $globalLiveInterval; |
|
| 475 | - date_default_timezone_set('UTC'); |
|
| 476 | - |
|
| 477 | - $filter_query = ''; |
|
| 478 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 479 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 480 | - } |
|
| 481 | - // Should use spotter_output also ? |
|
| 482 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 483 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 484 | - } |
|
| 485 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 486 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 487 | - } |
|
| 488 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 489 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 493 | - if ($globalDBdriver == 'mysql') { |
|
| 494 | - /* |
|
| 467 | + * Gets Minimal Live Spotter data |
|
| 468 | + * |
|
| 469 | + * @return Array the spotter information |
|
| 470 | + * |
|
| 471 | + */ |
|
| 472 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 473 | + { |
|
| 474 | + global $globalDBdriver, $globalLiveInterval; |
|
| 475 | + date_default_timezone_set('UTC'); |
|
| 476 | + |
|
| 477 | + $filter_query = ''; |
|
| 478 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 479 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 480 | + } |
|
| 481 | + // Should use spotter_output also ? |
|
| 482 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 483 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 484 | + } |
|
| 485 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 486 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 487 | + } |
|
| 488 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 489 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 493 | + if ($globalDBdriver == 'mysql') { |
|
| 494 | + /* |
|
| 495 | 495 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 496 | 496 | FROM spotter_archive |
| 497 | 497 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -502,95 +502,95 @@ discard block |
||
| 502 | 502 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 503 | 503 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 504 | 504 | |
| 505 | - } else { |
|
| 506 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 507 | - /* |
|
| 505 | + } else { |
|
| 506 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 507 | + /* |
|
| 508 | 508 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
| 509 | 509 | FROM spotter_archive_output |
| 510 | 510 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 511 | 511 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 512 | 512 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 513 | 513 | */ |
| 514 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 514 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 515 | 515 | FROM spotter_archive_output |
| 516 | 516 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 517 | 517 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 518 | 518 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 519 | 519 | // .' GROUP BY spotter_output.flightaware_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'; |
| 520 | 520 | |
| 521 | - } |
|
| 522 | - //echo $query; |
|
| 523 | - try { |
|
| 524 | - $sth = $this->db->prepare($query); |
|
| 525 | - $sth->execute(); |
|
| 526 | - } catch(PDOException $e) { |
|
| 527 | - echo $e->getMessage(); |
|
| 528 | - die; |
|
| 529 | - } |
|
| 530 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 531 | - |
|
| 532 | - return $spotter_array; |
|
| 533 | - } |
|
| 521 | + } |
|
| 522 | + //echo $query; |
|
| 523 | + try { |
|
| 524 | + $sth = $this->db->prepare($query); |
|
| 525 | + $sth->execute(); |
|
| 526 | + } catch(PDOException $e) { |
|
| 527 | + echo $e->getMessage(); |
|
| 528 | + die; |
|
| 529 | + } |
|
| 530 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 531 | + |
|
| 532 | + return $spotter_array; |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | - * Gets count Live Spotter data |
|
| 537 | - * |
|
| 538 | - * @return Array the spotter information |
|
| 539 | - * |
|
| 540 | - */ |
|
| 541 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 542 | - { |
|
| 543 | - global $globalDBdriver, $globalLiveInterval; |
|
| 544 | - date_default_timezone_set('UTC'); |
|
| 545 | - |
|
| 546 | - $filter_query = ''; |
|
| 547 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 548 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 549 | - } |
|
| 550 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 551 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 552 | - } |
|
| 553 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 554 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 555 | - } |
|
| 556 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 557 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 561 | - if ($globalDBdriver == 'mysql') { |
|
| 536 | + * Gets count Live Spotter data |
|
| 537 | + * |
|
| 538 | + * @return Array the spotter information |
|
| 539 | + * |
|
| 540 | + */ |
|
| 541 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 542 | + { |
|
| 543 | + global $globalDBdriver, $globalLiveInterval; |
|
| 544 | + date_default_timezone_set('UTC'); |
|
| 545 | + |
|
| 546 | + $filter_query = ''; |
|
| 547 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 548 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 549 | + } |
|
| 550 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 551 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 552 | + } |
|
| 553 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 554 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 555 | + } |
|
| 556 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 557 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 561 | + if ($globalDBdriver == 'mysql') { |
|
| 562 | 562 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 563 | 563 | FROM spotter_archive l |
| 564 | 564 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 565 | - } else { |
|
| 565 | + } else { |
|
| 566 | 566 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 567 | - } |
|
| 568 | - //echo $query; |
|
| 569 | - try { |
|
| 570 | - $sth = $this->db->prepare($query); |
|
| 571 | - $sth->execute(); |
|
| 572 | - } catch(PDOException $e) { |
|
| 573 | - echo $e->getMessage(); |
|
| 574 | - die; |
|
| 575 | - } |
|
| 567 | + } |
|
| 568 | + //echo $query; |
|
| 569 | + try { |
|
| 570 | + $sth = $this->db->prepare($query); |
|
| 571 | + $sth->execute(); |
|
| 572 | + } catch(PDOException $e) { |
|
| 573 | + echo $e->getMessage(); |
|
| 574 | + die; |
|
| 575 | + } |
|
| 576 | 576 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 577 | 577 | $sth->closeCursor(); |
| 578 | - return $result['nb']; |
|
| 578 | + return $result['nb']; |
|
| 579 | 579 | |
| 580 | - } |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | 582 | |
| 583 | 583 | |
| 584 | 584 | // Spotter_Archive_output |
| 585 | 585 | |
| 586 | - /** |
|
| 587 | - * Gets all the spotter information |
|
| 588 | - * |
|
| 589 | - * @return Array the spotter information |
|
| 590 | - * |
|
| 591 | - */ |
|
| 592 | - public function searchSpotterData($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()) |
|
| 593 | - { |
|
| 586 | + /** |
|
| 587 | + * Gets all the spotter information |
|
| 588 | + * |
|
| 589 | + * @return Array the spotter information |
|
| 590 | + * |
|
| 591 | + */ |
|
| 592 | + public function searchSpotterData($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()) |
|
| 593 | + { |
|
| 594 | 594 | global $globalTimezone, $globalDBdriver; |
| 595 | 595 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 596 | 596 | $Translation = new Translation(); |
@@ -604,159 +604,159 @@ discard block |
||
| 604 | 604 | $filter_query = $this->getFilter($filters); |
| 605 | 605 | if ($q != "") |
| 606 | 606 | { |
| 607 | - if (!is_string($q)) |
|
| 608 | - { |
|
| 607 | + if (!is_string($q)) |
|
| 608 | + { |
|
| 609 | 609 | return false; |
| 610 | - } else { |
|
| 610 | + } else { |
|
| 611 | 611 | |
| 612 | 612 | $q_array = explode(" ", $q); |
| 613 | 613 | |
| 614 | 614 | foreach ($q_array as $q_item){ |
| 615 | - $additional_query .= " AND ("; |
|
| 616 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 617 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 618 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 619 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 620 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 621 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 622 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 623 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 624 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 625 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 626 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 627 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 628 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 629 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 630 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 631 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 632 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 633 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 634 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 635 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 636 | - $translate = $Translation->ident2icao($q_item); |
|
| 637 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 638 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 639 | - $additional_query .= ")"; |
|
| 640 | - } |
|
| 641 | - } |
|
| 615 | + $additional_query .= " AND ("; |
|
| 616 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 617 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 618 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 619 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 620 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 621 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 622 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 623 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 624 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 625 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 626 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 627 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 628 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 629 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 630 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 631 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 632 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 633 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 634 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 635 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 636 | + $translate = $Translation->ident2icao($q_item); |
|
| 637 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 638 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 639 | + $additional_query .= ")"; |
|
| 640 | + } |
|
| 641 | + } |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | if ($registration != "") |
| 645 | 645 | { |
| 646 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 647 | - if (!is_string($registration)) |
|
| 648 | - { |
|
| 646 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 647 | + if (!is_string($registration)) |
|
| 648 | + { |
|
| 649 | 649 | return false; |
| 650 | - } else { |
|
| 650 | + } else { |
|
| 651 | 651 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 652 | - } |
|
| 652 | + } |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | if ($aircraft_icao != "") |
| 656 | 656 | { |
| 657 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 658 | - if (!is_string($aircraft_icao)) |
|
| 659 | - { |
|
| 657 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 658 | + if (!is_string($aircraft_icao)) |
|
| 659 | + { |
|
| 660 | 660 | return false; |
| 661 | - } else { |
|
| 661 | + } else { |
|
| 662 | 662 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 663 | - } |
|
| 663 | + } |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | if ($aircraft_manufacturer != "") |
| 667 | 667 | { |
| 668 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 669 | - if (!is_string($aircraft_manufacturer)) |
|
| 670 | - { |
|
| 668 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 669 | + if (!is_string($aircraft_manufacturer)) |
|
| 670 | + { |
|
| 671 | 671 | return false; |
| 672 | - } else { |
|
| 672 | + } else { |
|
| 673 | 673 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 674 | - } |
|
| 674 | + } |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | if ($highlights == "true") |
| 678 | 678 | { |
| 679 | - if (!is_string($highlights)) |
|
| 680 | - { |
|
| 679 | + if (!is_string($highlights)) |
|
| 680 | + { |
|
| 681 | 681 | return false; |
| 682 | - } else { |
|
| 682 | + } else { |
|
| 683 | 683 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 684 | - } |
|
| 684 | + } |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | if ($airline_icao != "") |
| 688 | 688 | { |
| 689 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 690 | - if (!is_string($airline_icao)) |
|
| 691 | - { |
|
| 689 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 690 | + if (!is_string($airline_icao)) |
|
| 691 | + { |
|
| 692 | 692 | return false; |
| 693 | - } else { |
|
| 693 | + } else { |
|
| 694 | 694 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 695 | - } |
|
| 695 | + } |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | if ($airline_country != "") |
| 699 | 699 | { |
| 700 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 701 | - if (!is_string($airline_country)) |
|
| 702 | - { |
|
| 700 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 701 | + if (!is_string($airline_country)) |
|
| 702 | + { |
|
| 703 | 703 | return false; |
| 704 | - } else { |
|
| 704 | + } else { |
|
| 705 | 705 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 706 | - } |
|
| 706 | + } |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | if ($airline_type != "") |
| 710 | 710 | { |
| 711 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 712 | - if (!is_string($airline_type)) |
|
| 713 | - { |
|
| 711 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 712 | + if (!is_string($airline_type)) |
|
| 713 | + { |
|
| 714 | 714 | return false; |
| 715 | - } else { |
|
| 715 | + } else { |
|
| 716 | 716 | if ($airline_type == "passenger") |
| 717 | 717 | { |
| 718 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 718 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 719 | 719 | } |
| 720 | 720 | if ($airline_type == "cargo") |
| 721 | 721 | { |
| 722 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 722 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 723 | 723 | } |
| 724 | 724 | if ($airline_type == "military") |
| 725 | 725 | { |
| 726 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 726 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 727 | + } |
|
| 727 | 728 | } |
| 728 | - } |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | if ($airport != "") |
| 732 | 732 | { |
| 733 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 734 | - if (!is_string($airport)) |
|
| 735 | - { |
|
| 733 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 734 | + if (!is_string($airport)) |
|
| 735 | + { |
|
| 736 | 736 | return false; |
| 737 | - } else { |
|
| 737 | + } else { |
|
| 738 | 738 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 739 | - } |
|
| 739 | + } |
|
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | if ($airport_country != "") |
| 743 | 743 | { |
| 744 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 745 | - if (!is_string($airport_country)) |
|
| 746 | - { |
|
| 744 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 745 | + if (!is_string($airport_country)) |
|
| 746 | + { |
|
| 747 | 747 | return false; |
| 748 | - } else { |
|
| 748 | + } else { |
|
| 749 | 749 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 750 | - } |
|
| 750 | + } |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | if ($callsign != "") |
| 754 | 754 | { |
| 755 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 756 | - if (!is_string($callsign)) |
|
| 757 | - { |
|
| 755 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 756 | + if (!is_string($callsign)) |
|
| 757 | + { |
|
| 758 | 758 | return false; |
| 759 | - } else { |
|
| 759 | + } else { |
|
| 760 | 760 | $translate = $Translation->ident2icao($callsign); |
| 761 | 761 | if ($translate != $callsign) { |
| 762 | 762 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -764,99 +764,99 @@ discard block |
||
| 764 | 764 | } else { |
| 765 | 765 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 766 | 766 | } |
| 767 | - } |
|
| 767 | + } |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | if ($owner != "") |
| 771 | 771 | { |
| 772 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 773 | - if (!is_string($owner)) |
|
| 774 | - { |
|
| 772 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 773 | + if (!is_string($owner)) |
|
| 774 | + { |
|
| 775 | 775 | return false; |
| 776 | - } else { |
|
| 776 | + } else { |
|
| 777 | 777 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 778 | - } |
|
| 778 | + } |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | if ($pilot_name != "") |
| 782 | 782 | { |
| 783 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 784 | - if (!is_string($pilot_name)) |
|
| 785 | - { |
|
| 783 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 784 | + if (!is_string($pilot_name)) |
|
| 785 | + { |
|
| 786 | 786 | return false; |
| 787 | - } else { |
|
| 787 | + } else { |
|
| 788 | 788 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 789 | - } |
|
| 789 | + } |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | if ($pilot_id != "") |
| 793 | 793 | { |
| 794 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 795 | - if (!is_string($pilot_id)) |
|
| 796 | - { |
|
| 794 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 795 | + if (!is_string($pilot_id)) |
|
| 796 | + { |
|
| 797 | 797 | return false; |
| 798 | - } else { |
|
| 798 | + } else { |
|
| 799 | 799 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 800 | - } |
|
| 800 | + } |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | if ($departure_airport_route != "") |
| 804 | 804 | { |
| 805 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 806 | - if (!is_string($departure_airport_route)) |
|
| 807 | - { |
|
| 805 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 806 | + if (!is_string($departure_airport_route)) |
|
| 807 | + { |
|
| 808 | 808 | return false; |
| 809 | - } else { |
|
| 809 | + } else { |
|
| 810 | 810 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 811 | - } |
|
| 811 | + } |
|
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | if ($arrival_airport_route != "") |
| 815 | 815 | { |
| 816 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 817 | - if (!is_string($arrival_airport_route)) |
|
| 818 | - { |
|
| 816 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 817 | + if (!is_string($arrival_airport_route)) |
|
| 818 | + { |
|
| 819 | 819 | return false; |
| 820 | - } else { |
|
| 820 | + } else { |
|
| 821 | 821 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 822 | - } |
|
| 822 | + } |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | if ($altitude != "") |
| 826 | 826 | { |
| 827 | - $altitude_array = explode(",", $altitude); |
|
| 827 | + $altitude_array = explode(",", $altitude); |
|
| 828 | 828 | |
| 829 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 830 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 829 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 830 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 831 | 831 | |
| 832 | 832 | |
| 833 | - if ($altitude_array[1] != "") |
|
| 834 | - { |
|
| 833 | + if ($altitude_array[1] != "") |
|
| 834 | + { |
|
| 835 | 835 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 836 | 836 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 837 | 837 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 838 | - } else { |
|
| 838 | + } else { |
|
| 839 | 839 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 840 | 840 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 841 | - } |
|
| 841 | + } |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | if ($date_posted != "") |
| 845 | 845 | { |
| 846 | - $date_array = explode(",", $date_posted); |
|
| 846 | + $date_array = explode(",", $date_posted); |
|
| 847 | 847 | |
| 848 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 849 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 848 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 849 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 850 | 850 | |
| 851 | - if ($globalTimezone != '') { |
|
| 851 | + if ($globalTimezone != '') { |
|
| 852 | 852 | date_default_timezone_set($globalTimezone); |
| 853 | 853 | $datetime = new DateTime(); |
| 854 | 854 | $offset = $datetime->format('P'); |
| 855 | - } else $offset = '+00:00'; |
|
| 855 | + } else $offset = '+00:00'; |
|
| 856 | 856 | |
| 857 | 857 | |
| 858 | - if ($date_array[1] != "") |
|
| 859 | - { |
|
| 858 | + if ($date_array[1] != "") |
|
| 859 | + { |
|
| 860 | 860 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 861 | 861 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 862 | 862 | if ($globalDBdriver == 'mysql') { |
@@ -864,28 +864,28 @@ discard block |
||
| 864 | 864 | } else { |
| 865 | 865 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 866 | 866 | } |
| 867 | - } else { |
|
| 867 | + } else { |
|
| 868 | 868 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 869 | - if ($globalDBdriver == 'mysql') { |
|
| 869 | + if ($globalDBdriver == 'mysql') { |
|
| 870 | 870 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 871 | 871 | } else { |
| 872 | 872 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 873 | 873 | } |
| 874 | - } |
|
| 874 | + } |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | if ($limit != "") |
| 878 | 878 | { |
| 879 | - $limit_array = explode(",", $limit); |
|
| 879 | + $limit_array = explode(",", $limit); |
|
| 880 | 880 | |
| 881 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 881 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 883 | 883 | |
| 884 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 885 | - { |
|
| 884 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 885 | + { |
|
| 886 | 886 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 887 | 887 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 888 | - } |
|
| 888 | + } |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | |
@@ -916,33 +916,33 @@ discard block |
||
| 916 | 916 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
| 917 | 917 | |
| 918 | 918 | return $spotter_array; |
| 919 | - } |
|
| 919 | + } |
|
| 920 | 920 | |
| 921 | - public function deleteSpotterArchiveData() |
|
| 922 | - { |
|
| 921 | + public function deleteSpotterArchiveData() |
|
| 922 | + { |
|
| 923 | 923 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 924 | - date_default_timezone_set('UTC'); |
|
| 925 | - if ($globalDBdriver == 'mysql') { |
|
| 924 | + date_default_timezone_set('UTC'); |
|
| 925 | + if ($globalDBdriver == 'mysql') { |
|
| 926 | 926 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 927 | 927 | } else { |
| 928 | 928 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 929 | 929 | } |
| 930 | - try { |
|
| 931 | - $sth = $this->db->prepare($query); |
|
| 932 | - $sth->execute(); |
|
| 933 | - } catch(PDOException $e) { |
|
| 934 | - return "error"; |
|
| 935 | - } |
|
| 930 | + try { |
|
| 931 | + $sth = $this->db->prepare($query); |
|
| 932 | + $sth->execute(); |
|
| 933 | + } catch(PDOException $e) { |
|
| 934 | + return "error"; |
|
| 935 | + } |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | - /** |
|
| 939 | - * Gets all the spotter information based on the callsign |
|
| 940 | - * |
|
| 941 | - * @return Array the spotter information |
|
| 942 | - * |
|
| 943 | - */ |
|
| 944 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 945 | - { |
|
| 938 | + /** |
|
| 939 | + * Gets all the spotter information based on the callsign |
|
| 940 | + * |
|
| 941 | + * @return Array the spotter information |
|
| 942 | + * |
|
| 943 | + */ |
|
| 944 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 945 | + { |
|
| 946 | 946 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 947 | 947 | |
| 948 | 948 | date_default_timezone_set('UTC'); |
@@ -954,35 +954,35 @@ discard block |
||
| 954 | 954 | |
| 955 | 955 | if ($ident != "") |
| 956 | 956 | { |
| 957 | - if (!is_string($ident)) |
|
| 958 | - { |
|
| 957 | + if (!is_string($ident)) |
|
| 958 | + { |
|
| 959 | 959 | return false; |
| 960 | - } else { |
|
| 960 | + } else { |
|
| 961 | 961 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 962 | 962 | $query_values = array(':ident' => $ident); |
| 963 | - } |
|
| 963 | + } |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | if ($limit != "") |
| 967 | 967 | { |
| 968 | - $limit_array = explode(",", $limit); |
|
| 968 | + $limit_array = explode(",", $limit); |
|
| 969 | 969 | |
| 970 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 971 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 970 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 971 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 972 | 972 | |
| 973 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 974 | - { |
|
| 973 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 974 | + { |
|
| 975 | 975 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 976 | 976 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 977 | - } |
|
| 977 | + } |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | if ($sort != "") |
| 981 | 981 | { |
| 982 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 983 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 982 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 983 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 984 | 984 | } else { |
| 985 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 985 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -990,17 +990,17 @@ discard block |
||
| 990 | 990 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 991 | 991 | |
| 992 | 992 | return $spotter_array; |
| 993 | - } |
|
| 993 | + } |
|
| 994 | 994 | |
| 995 | 995 | |
| 996 | - /** |
|
| 997 | - * Gets all the spotter information based on the owner |
|
| 998 | - * |
|
| 999 | - * @return Array the spotter information |
|
| 1000 | - * |
|
| 1001 | - */ |
|
| 1002 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1003 | - { |
|
| 996 | + /** |
|
| 997 | + * Gets all the spotter information based on the owner |
|
| 998 | + * |
|
| 999 | + * @return Array the spotter information |
|
| 1000 | + * |
|
| 1001 | + */ |
|
| 1002 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1003 | + { |
|
| 1004 | 1004 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1005 | 1005 | |
| 1006 | 1006 | date_default_timezone_set('UTC'); |
@@ -1013,35 +1013,35 @@ discard block |
||
| 1013 | 1013 | |
| 1014 | 1014 | if ($owner != "") |
| 1015 | 1015 | { |
| 1016 | - if (!is_string($owner)) |
|
| 1017 | - { |
|
| 1016 | + if (!is_string($owner)) |
|
| 1017 | + { |
|
| 1018 | 1018 | return false; |
| 1019 | - } else { |
|
| 1019 | + } else { |
|
| 1020 | 1020 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
| 1021 | 1021 | $query_values = array(':owner' => $owner); |
| 1022 | - } |
|
| 1022 | + } |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | if ($limit != "") |
| 1026 | 1026 | { |
| 1027 | - $limit_array = explode(",", $limit); |
|
| 1027 | + $limit_array = explode(",", $limit); |
|
| 1028 | 1028 | |
| 1029 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1030 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1029 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1030 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1031 | 1031 | |
| 1032 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1033 | - { |
|
| 1032 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1033 | + { |
|
| 1034 | 1034 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1035 | 1035 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1036 | - } |
|
| 1036 | + } |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | if ($sort != "") |
| 1040 | 1040 | { |
| 1041 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1042 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1041 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1042 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1043 | 1043 | } else { |
| 1044 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1044 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1049,16 +1049,16 @@ discard block |
||
| 1049 | 1049 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1050 | 1050 | |
| 1051 | 1051 | return $spotter_array; |
| 1052 | - } |
|
| 1053 | - |
|
| 1054 | - /** |
|
| 1055 | - * Gets all the spotter information based on the pilot |
|
| 1056 | - * |
|
| 1057 | - * @return Array the spotter information |
|
| 1058 | - * |
|
| 1059 | - */ |
|
| 1060 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1061 | - { |
|
| 1052 | + } |
|
| 1053 | + |
|
| 1054 | + /** |
|
| 1055 | + * Gets all the spotter information based on the pilot |
|
| 1056 | + * |
|
| 1057 | + * @return Array the spotter information |
|
| 1058 | + * |
|
| 1059 | + */ |
|
| 1060 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1061 | + { |
|
| 1062 | 1062 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1063 | 1063 | |
| 1064 | 1064 | date_default_timezone_set('UTC'); |
@@ -1077,24 +1077,24 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | if ($limit != "") |
| 1079 | 1079 | { |
| 1080 | - $limit_array = explode(",", $limit); |
|
| 1080 | + $limit_array = explode(",", $limit); |
|
| 1081 | 1081 | |
| 1082 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1083 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1082 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1083 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1084 | 1084 | |
| 1085 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1086 | - { |
|
| 1085 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1086 | + { |
|
| 1087 | 1087 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1088 | 1088 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1089 | - } |
|
| 1089 | + } |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | if ($sort != "") |
| 1093 | 1093 | { |
| 1094 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1095 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1094 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1095 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1096 | 1096 | } else { |
| 1097 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1097 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1102,16 +1102,16 @@ discard block |
||
| 1102 | 1102 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1103 | 1103 | |
| 1104 | 1104 | return $spotter_array; |
| 1105 | - } |
|
| 1106 | - |
|
| 1107 | - /** |
|
| 1108 | - * Gets all number of flight over countries |
|
| 1109 | - * |
|
| 1110 | - * @return Array the airline country list |
|
| 1111 | - * |
|
| 1112 | - */ |
|
| 1113 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1114 | - { |
|
| 1105 | + } |
|
| 1106 | + |
|
| 1107 | + /** |
|
| 1108 | + * Gets all number of flight over countries |
|
| 1109 | + * |
|
| 1110 | + * @return Array the airline country list |
|
| 1111 | + * |
|
| 1112 | + */ |
|
| 1113 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1114 | + { |
|
| 1115 | 1115 | global $globalDBdriver; |
| 1116 | 1116 | /* |
| 1117 | 1117 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1121,14 +1121,14 @@ discard block |
||
| 1121 | 1121 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1122 | 1122 | FROM countries c, spotter_archive s |
| 1123 | 1123 | WHERE c.iso2 = s.over_country "; |
| 1124 | - if ($olderthanmonths > 0) { |
|
| 1125 | - if ($globalDBdriver == 'mysql') { |
|
| 1124 | + if ($olderthanmonths > 0) { |
|
| 1125 | + if ($globalDBdriver == 'mysql') { |
|
| 1126 | 1126 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1127 | 1127 | } else { |
| 1128 | 1128 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1129 | 1129 | } |
| 1130 | 1130 | } |
| 1131 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1131 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1132 | 1132 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1133 | 1133 | if ($limit) $query .= " LIMIT 0,10"; |
| 1134 | 1134 | |
@@ -1141,23 +1141,23 @@ discard block |
||
| 1141 | 1141 | |
| 1142 | 1142 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1143 | 1143 | { |
| 1144 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1145 | - $temp_array['flight_country'] = $row['name']; |
|
| 1146 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1147 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1148 | - $flight_array[] = $temp_array; |
|
| 1144 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1145 | + $temp_array['flight_country'] = $row['name']; |
|
| 1146 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1147 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1148 | + $flight_array[] = $temp_array; |
|
| 1149 | 1149 | } |
| 1150 | 1150 | return $flight_array; |
| 1151 | - } |
|
| 1152 | - |
|
| 1153 | - /** |
|
| 1154 | - * Gets all number of flight over countries |
|
| 1155 | - * |
|
| 1156 | - * @return Array the airline country list |
|
| 1157 | - * |
|
| 1158 | - */ |
|
| 1159 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1160 | - { |
|
| 1151 | + } |
|
| 1152 | + |
|
| 1153 | + /** |
|
| 1154 | + * Gets all number of flight over countries |
|
| 1155 | + * |
|
| 1156 | + * @return Array the airline country list |
|
| 1157 | + * |
|
| 1158 | + */ |
|
| 1159 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1160 | + { |
|
| 1161 | 1161 | global $globalDBdriver; |
| 1162 | 1162 | /* |
| 1163 | 1163 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1167,14 +1167,14 @@ discard block |
||
| 1167 | 1167 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1168 | 1168 | FROM countries c, spotter_archive s, spotter_output o |
| 1169 | 1169 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
| 1170 | - if ($olderthanmonths > 0) { |
|
| 1171 | - if ($globalDBdriver == 'mysql') { |
|
| 1170 | + if ($olderthanmonths > 0) { |
|
| 1171 | + if ($globalDBdriver == 'mysql') { |
|
| 1172 | 1172 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1173 | 1173 | } else { |
| 1174 | 1174 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1175 | 1175 | } |
| 1176 | 1176 | } |
| 1177 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1177 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1178 | 1178 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1179 | 1179 | if ($limit) $query .= " LIMIT 0,10"; |
| 1180 | 1180 | |
@@ -1187,24 +1187,24 @@ discard block |
||
| 1187 | 1187 | |
| 1188 | 1188 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1189 | 1189 | { |
| 1190 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1191 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1192 | - $temp_array['flight_country'] = $row['name']; |
|
| 1193 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1194 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1195 | - $flight_array[] = $temp_array; |
|
| 1190 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1191 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1192 | + $temp_array['flight_country'] = $row['name']; |
|
| 1193 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1194 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1195 | + $flight_array[] = $temp_array; |
|
| 1196 | 1196 | } |
| 1197 | 1197 | return $flight_array; |
| 1198 | - } |
|
| 1199 | - |
|
| 1200 | - /** |
|
| 1201 | - * Gets last spotter information based on a particular callsign |
|
| 1202 | - * |
|
| 1203 | - * @return Array the spotter information |
|
| 1204 | - * |
|
| 1205 | - */ |
|
| 1206 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1207 | - { |
|
| 1198 | + } |
|
| 1199 | + |
|
| 1200 | + /** |
|
| 1201 | + * Gets last spotter information based on a particular callsign |
|
| 1202 | + * |
|
| 1203 | + * @return Array the spotter information |
|
| 1204 | + * |
|
| 1205 | + */ |
|
| 1206 | + public function getDateArchiveSpotterDataById($id,$date) |
|
| 1207 | + { |
|
| 1208 | 1208 | $Spotter = new Spotter($this->db); |
| 1209 | 1209 | date_default_timezone_set('UTC'); |
| 1210 | 1210 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1212,16 +1212,16 @@ discard block |
||
| 1212 | 1212 | $date = date('c',$date); |
| 1213 | 1213 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1214 | 1214 | return $spotter_array; |
| 1215 | - } |
|
| 1216 | - |
|
| 1217 | - /** |
|
| 1218 | - * Gets all the spotter information based on a particular callsign |
|
| 1219 | - * |
|
| 1220 | - * @return Array the spotter information |
|
| 1221 | - * |
|
| 1222 | - */ |
|
| 1223 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1224 | - { |
|
| 1215 | + } |
|
| 1216 | + |
|
| 1217 | + /** |
|
| 1218 | + * Gets all the spotter information based on a particular callsign |
|
| 1219 | + * |
|
| 1220 | + * @return Array the spotter information |
|
| 1221 | + * |
|
| 1222 | + */ |
|
| 1223 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1224 | + { |
|
| 1225 | 1225 | $Spotter = new Spotter($this->db); |
| 1226 | 1226 | date_default_timezone_set('UTC'); |
| 1227 | 1227 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1229,16 +1229,16 @@ discard block |
||
| 1229 | 1229 | $date = date('c',$date); |
| 1230 | 1230 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1231 | 1231 | return $spotter_array; |
| 1232 | - } |
|
| 1233 | - |
|
| 1234 | - /** |
|
| 1235 | - * Gets all the spotter information based on the airport |
|
| 1236 | - * |
|
| 1237 | - * @return Array the spotter information |
|
| 1238 | - * |
|
| 1239 | - */ |
|
| 1240 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1241 | - { |
|
| 1232 | + } |
|
| 1233 | + |
|
| 1234 | + /** |
|
| 1235 | + * Gets all the spotter information based on the airport |
|
| 1236 | + * |
|
| 1237 | + * @return Array the spotter information |
|
| 1238 | + * |
|
| 1239 | + */ |
|
| 1240 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1241 | + { |
|
| 1242 | 1242 | global $global_query; |
| 1243 | 1243 | $Spotter = new Spotter(); |
| 1244 | 1244 | date_default_timezone_set('UTC'); |
@@ -1249,35 +1249,35 @@ discard block |
||
| 1249 | 1249 | |
| 1250 | 1250 | if ($airport != "") |
| 1251 | 1251 | { |
| 1252 | - if (!is_string($airport)) |
|
| 1253 | - { |
|
| 1252 | + if (!is_string($airport)) |
|
| 1253 | + { |
|
| 1254 | 1254 | return false; |
| 1255 | - } else { |
|
| 1255 | + } else { |
|
| 1256 | 1256 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
| 1257 | 1257 | $query_values = array(':airport' => $airport); |
| 1258 | - } |
|
| 1258 | + } |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | if ($limit != "") |
| 1262 | 1262 | { |
| 1263 | - $limit_array = explode(",", $limit); |
|
| 1263 | + $limit_array = explode(",", $limit); |
|
| 1264 | 1264 | |
| 1265 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1266 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1265 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1266 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1267 | 1267 | |
| 1268 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1269 | - { |
|
| 1268 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1269 | + { |
|
| 1270 | 1270 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1271 | 1271 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1272 | - } |
|
| 1272 | + } |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | if ($sort != "") |
| 1276 | 1276 | { |
| 1277 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1278 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1277 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1278 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1279 | 1279 | } else { |
| 1280 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1280 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1281 | 1281 | } |
| 1282 | 1282 | |
| 1283 | 1283 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1285,6 +1285,6 @@ discard block |
||
| 1285 | 1285 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1286 | 1286 | |
| 1287 | 1287 | return $spotter_array; |
| 1288 | - } |
|
| 1288 | + } |
|
| 1289 | 1289 | } |
| 1290 | 1290 | ?> |
| 1291 | 1291 | \ No newline at end of file |
@@ -13,62 +13,62 @@ 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['airlines']) && !empty($flt['airlines'])) { |
| 34 | 34 | if ($flt['airlines'][0] != '') { |
| 35 | 35 | if (isset($flt['source'])) { |
| 36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 37 | 37 | } else { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 43 | 43 | if (isset($flt['source'])) { |
| 44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | 45 | } else { |
| 46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 50 | 50 | if (isset($flt['source'])) { |
| 51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | 52 | } else { |
| 53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 57 | 57 | if (isset($flt['source'])) { |
| 58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | 59 | } else { |
| 60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 64 | 64 | if (isset($flt['source'])) { |
| 65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 70 | 70 | if ($filter['airlines'][0] != '') { |
| 71 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 71 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -76,16 +76,16 @@ discard block |
||
| 76 | 76 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | 80 | } |
| 81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 82 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 85 | 85 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 88 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 88 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 89 | 89 | } |
| 90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 91 | 91 | $filter_query_date = ''; |
@@ -111,40 +111,40 @@ discard block |
||
| 111 | 111 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 115 | 115 | } |
| 116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 118 | 118 | if ($filter_query_where != '') { |
| 119 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 119 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 120 | 120 | } |
| 121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
| 122 | 122 | return $filter_query; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // Spotter_archive |
| 126 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 126 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 127 | 127 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 128 | 128 | if ($over_country == '') { |
| 129 | 129 | $Spotter = new Spotter($this->db); |
| 130 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 130 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 131 | 131 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 132 | 132 | else $country = ''; |
| 133 | 133 | } else $country = $over_country; |
| 134 | - if ($airline_type === NULL) $airline_type =''; |
|
| 134 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 135 | 135 | |
| 136 | 136 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 137 | 137 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 138 | 138 | |
| 139 | 139 | // Route is not added in spotter_archive |
| 140 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
| 140 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
| 141 | 141 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
| 142 | 142 | |
| 143 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
| 143 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
| 144 | 144 | try { |
| 145 | 145 | $sth = $this->db->prepare($query); |
| 146 | 146 | $sth->execute($query_values); |
| 147 | - } catch(PDOException $e) { |
|
| 147 | + } catch (PDOException $e) { |
|
| 148 | 148 | return "error : ".$e->getMessage(); |
| 149 | 149 | } |
| 150 | 150 | return "success"; |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 166 | 166 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 167 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 167 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 168 | 168 | |
| 169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 169 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 170 | 170 | |
| 171 | 171 | return $spotter_array; |
| 172 | 172 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 186 | 186 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 187 | 187 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 188 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 188 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 189 | 189 | |
| 190 | 190 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 191 | 191 | /* |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 200 | 200 | */ |
| 201 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 201 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 202 | 202 | |
| 203 | 203 | return $spotter_array; |
| 204 | 204 | } |
@@ -213,14 +213,14 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | date_default_timezone_set('UTC'); |
| 215 | 215 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 216 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 216 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 217 | 217 | |
| 218 | 218 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 219 | 219 | |
| 220 | 220 | try { |
| 221 | 221 | $sth = $this->db->prepare($query); |
| 222 | 222 | $sth->execute(array(':id' => $id)); |
| 223 | - } catch(PDOException $e) { |
|
| 223 | + } catch (PDOException $e) { |
|
| 224 | 224 | echo $e->getMessage(); |
| 225 | 225 | die; |
| 226 | 226 | } |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | { |
| 240 | 240 | date_default_timezone_set('UTC'); |
| 241 | 241 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 242 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 242 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 243 | 243 | |
| 244 | 244 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 245 | 245 | |
| 246 | 246 | try { |
| 247 | 247 | $sth = $this->db->prepare($query); |
| 248 | 248 | $sth->execute(array(':id' => $id)); |
| 249 | - } catch(PDOException $e) { |
|
| 249 | + } catch (PDOException $e) { |
|
| 250 | 250 | echo $e->getMessage(); |
| 251 | 251 | die; |
| 252 | 252 | } |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | date_default_timezone_set('UTC'); |
| 269 | 269 | |
| 270 | 270 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 271 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 271 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 272 | 272 | |
| 273 | 273 | try { |
| 274 | 274 | $sth = $this->db->prepare($query); |
| 275 | 275 | $sth->execute(array(':ident' => $ident)); |
| 276 | - } catch(PDOException $e) { |
|
| 276 | + } catch (PDOException $e) { |
|
| 277 | 277 | echo $e->getMessage(); |
| 278 | 278 | die; |
| 279 | 279 | } |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | date_default_timezone_set('UTC'); |
| 295 | 295 | |
| 296 | 296 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 297 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 297 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 298 | 298 | |
| 299 | 299 | try { |
| 300 | 300 | $sth = $this->db->prepare($query); |
| 301 | 301 | $sth->execute(array(':id' => $id)); |
| 302 | - } catch(PDOException $e) { |
|
| 302 | + } catch (PDOException $e) { |
|
| 303 | 303 | echo $e->getMessage(); |
| 304 | 304 | die; |
| 305 | 305 | } |
@@ -320,12 +320,12 @@ discard block |
||
| 320 | 320 | date_default_timezone_set('UTC'); |
| 321 | 321 | |
| 322 | 322 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 323 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 323 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 324 | 324 | |
| 325 | 325 | try { |
| 326 | 326 | $sth = $this->db->prepare($query); |
| 327 | 327 | $sth->execute(array(':id' => $id)); |
| 328 | - } catch(PDOException $e) { |
|
| 328 | + } catch (PDOException $e) { |
|
| 329 | 329 | echo $e->getMessage(); |
| 330 | 330 | die; |
| 331 | 331 | } |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | date_default_timezone_set('UTC'); |
| 348 | 348 | |
| 349 | 349 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 350 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 350 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 351 | 351 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 352 | 352 | |
| 353 | 353 | try { |
| 354 | 354 | $sth = $this->db->prepare($query); |
| 355 | 355 | $sth->execute(array(':ident' => $ident)); |
| 356 | - } catch(PDOException $e) { |
|
| 356 | + } catch (PDOException $e) { |
|
| 357 | 357 | echo $e->getMessage(); |
| 358 | 358 | die; |
| 359 | 359 | } |
@@ -370,13 +370,13 @@ discard block |
||
| 370 | 370 | * @return Array the spotter information |
| 371 | 371 | * |
| 372 | 372 | */ |
| 373 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 373 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
| 374 | 374 | { |
| 375 | 375 | $Spotter = new Spotter($this->db); |
| 376 | 376 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 377 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 377 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 378 | 378 | |
| 379 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 379 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 380 | 380 | |
| 381 | 381 | return $spotter_array; |
| 382 | 382 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | try { |
| 390 | 390 | $sth = $this->db->prepare($query); |
| 391 | 391 | $sth->execute(); |
| 392 | - } catch(PDOException $e) { |
|
| 392 | + } catch (PDOException $e) { |
|
| 393 | 393 | echo $e->getMessage(); |
| 394 | 394 | die; |
| 395 | 395 | } |
@@ -401,24 +401,24 @@ discard block |
||
| 401 | 401 | * @return Array the spotter information |
| 402 | 402 | * |
| 403 | 403 | */ |
| 404 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 404 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
| 405 | 405 | { |
| 406 | 406 | global $globalDBdriver, $globalLiveInterval; |
| 407 | 407 | date_default_timezone_set('UTC'); |
| 408 | 408 | |
| 409 | 409 | $filter_query = ''; |
| 410 | 410 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 411 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 411 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 412 | 412 | } |
| 413 | 413 | // Use spotter_output also ? |
| 414 | 414 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 415 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 415 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 416 | 416 | } |
| 417 | 417 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 418 | 418 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 419 | 419 | } |
| 420 | 420 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 421 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 421 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -437,14 +437,14 @@ discard block |
||
| 437 | 437 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 438 | 438 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 439 | 439 | */ |
| 440 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 440 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 441 | 441 | FROM spotter_archive |
| 442 | 442 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 443 | 443 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 444 | 444 | '.$filter_query.' ORDER BY flightaware_id'; |
| 445 | 445 | } else { |
| 446 | 446 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
| 447 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 447 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 448 | 448 | FROM spotter_archive |
| 449 | 449 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 450 | 450 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | try { |
| 455 | 455 | $sth = $this->db->prepare($query); |
| 456 | 456 | $sth->execute(); |
| 457 | - } catch(PDOException $e) { |
|
| 457 | + } catch (PDOException $e) { |
|
| 458 | 458 | echo $e->getMessage(); |
| 459 | 459 | die; |
| 460 | 460 | } |
@@ -469,24 +469,24 @@ discard block |
||
| 469 | 469 | * @return Array the spotter information |
| 470 | 470 | * |
| 471 | 471 | */ |
| 472 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 472 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
| 473 | 473 | { |
| 474 | 474 | global $globalDBdriver, $globalLiveInterval; |
| 475 | 475 | date_default_timezone_set('UTC'); |
| 476 | 476 | |
| 477 | 477 | $filter_query = ''; |
| 478 | 478 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 479 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 479 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 480 | 480 | } |
| 481 | 481 | // Should use spotter_output also ? |
| 482 | 482 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 483 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 483 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 484 | 484 | } |
| 485 | 485 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 486 | 486 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 487 | 487 | } |
| 488 | 488 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 489 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 489 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | FROM spotter_archive |
| 497 | 497 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 498 | 498 | */ |
| 499 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 499 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 500 | 500 | FROM spotter_archive_output |
| 501 | 501 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 502 | 502 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 512 | 512 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 513 | 513 | */ |
| 514 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 514 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 515 | 515 | FROM spotter_archive_output |
| 516 | 516 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 517 | 517 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | try { |
| 524 | 524 | $sth = $this->db->prepare($query); |
| 525 | 525 | $sth->execute(); |
| 526 | - } catch(PDOException $e) { |
|
| 526 | + } catch (PDOException $e) { |
|
| 527 | 527 | echo $e->getMessage(); |
| 528 | 528 | die; |
| 529 | 529 | } |
@@ -538,23 +538,23 @@ discard block |
||
| 538 | 538 | * @return Array the spotter information |
| 539 | 539 | * |
| 540 | 540 | */ |
| 541 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 541 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
| 542 | 542 | { |
| 543 | 543 | global $globalDBdriver, $globalLiveInterval; |
| 544 | 544 | date_default_timezone_set('UTC'); |
| 545 | 545 | |
| 546 | 546 | $filter_query = ''; |
| 547 | 547 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 548 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 548 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 549 | 549 | } |
| 550 | 550 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 551 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 551 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 552 | 552 | } |
| 553 | 553 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 554 | 554 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 555 | 555 | } |
| 556 | 556 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 557 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 557 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | try { |
| 570 | 570 | $sth = $this->db->prepare($query); |
| 571 | 571 | $sth->execute(); |
| 572 | - } catch(PDOException $e) { |
|
| 572 | + } catch (PDOException $e) { |
|
| 573 | 573 | echo $e->getMessage(); |
| 574 | 574 | die; |
| 575 | 575 | } |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | * @return Array the spotter information |
| 590 | 590 | * |
| 591 | 591 | */ |
| 592 | - public function searchSpotterData($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()) |
|
| 592 | + public function searchSpotterData($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()) |
|
| 593 | 593 | { |
| 594 | 594 | global $globalTimezone, $globalDBdriver; |
| 595 | 595 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | |
| 612 | 612 | $q_array = explode(" ", $q); |
| 613 | 613 | |
| 614 | - foreach ($q_array as $q_item){ |
|
| 614 | + foreach ($q_array as $q_item) { |
|
| 615 | 615 | $additional_query .= " AND ("; |
| 616 | 616 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 617 | 617 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | |
| 644 | 644 | if ($registration != "") |
| 645 | 645 | { |
| 646 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 646 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 647 | 647 | if (!is_string($registration)) |
| 648 | 648 | { |
| 649 | 649 | return false; |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | if ($aircraft_icao != "") |
| 656 | 656 | { |
| 657 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 657 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 658 | 658 | if (!is_string($aircraft_icao)) |
| 659 | 659 | { |
| 660 | 660 | return false; |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | if ($aircraft_manufacturer != "") |
| 667 | 667 | { |
| 668 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 668 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 669 | 669 | if (!is_string($aircraft_manufacturer)) |
| 670 | 670 | { |
| 671 | 671 | return false; |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | |
| 687 | 687 | if ($airline_icao != "") |
| 688 | 688 | { |
| 689 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 689 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 690 | 690 | if (!is_string($airline_icao)) |
| 691 | 691 | { |
| 692 | 692 | return false; |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | |
| 698 | 698 | if ($airline_country != "") |
| 699 | 699 | { |
| 700 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 700 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 701 | 701 | if (!is_string($airline_country)) |
| 702 | 702 | { |
| 703 | 703 | return false; |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | |
| 709 | 709 | if ($airline_type != "") |
| 710 | 710 | { |
| 711 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 711 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 712 | 712 | if (!is_string($airline_type)) |
| 713 | 713 | { |
| 714 | 714 | return false; |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | |
| 731 | 731 | if ($airport != "") |
| 732 | 732 | { |
| 733 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 733 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 734 | 734 | if (!is_string($airport)) |
| 735 | 735 | { |
| 736 | 736 | return false; |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | |
| 742 | 742 | if ($airport_country != "") |
| 743 | 743 | { |
| 744 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 744 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 745 | 745 | if (!is_string($airport_country)) |
| 746 | 746 | { |
| 747 | 747 | return false; |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | |
| 753 | 753 | if ($callsign != "") |
| 754 | 754 | { |
| 755 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 755 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 756 | 756 | if (!is_string($callsign)) |
| 757 | 757 | { |
| 758 | 758 | return false; |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | $translate = $Translation->ident2icao($callsign); |
| 761 | 761 | if ($translate != $callsign) { |
| 762 | 762 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 763 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 763 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 764 | 764 | } else { |
| 765 | 765 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 766 | 766 | } |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | |
| 770 | 770 | if ($owner != "") |
| 771 | 771 | { |
| 772 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 772 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 773 | 773 | if (!is_string($owner)) |
| 774 | 774 | { |
| 775 | 775 | return false; |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | |
| 781 | 781 | if ($pilot_name != "") |
| 782 | 782 | { |
| 783 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 783 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 784 | 784 | if (!is_string($pilot_name)) |
| 785 | 785 | { |
| 786 | 786 | return false; |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | |
| 792 | 792 | if ($pilot_id != "") |
| 793 | 793 | { |
| 794 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 794 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 795 | 795 | if (!is_string($pilot_id)) |
| 796 | 796 | { |
| 797 | 797 | return false; |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | if ($departure_airport_route != "") |
| 804 | 804 | { |
| 805 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 805 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 806 | 806 | if (!is_string($departure_airport_route)) |
| 807 | 807 | { |
| 808 | 808 | return false; |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | |
| 814 | 814 | if ($arrival_airport_route != "") |
| 815 | 815 | { |
| 816 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 816 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 817 | 817 | if (!is_string($arrival_airport_route)) |
| 818 | 818 | { |
| 819 | 819 | return false; |
@@ -826,8 +826,8 @@ discard block |
||
| 826 | 826 | { |
| 827 | 827 | $altitude_array = explode(",", $altitude); |
| 828 | 828 | |
| 829 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 830 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 829 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 830 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 831 | 831 | |
| 832 | 832 | |
| 833 | 833 | if ($altitude_array[1] != "") |
@@ -845,8 +845,8 @@ discard block |
||
| 845 | 845 | { |
| 846 | 846 | $date_array = explode(",", $date_posted); |
| 847 | 847 | |
| 848 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 849 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 848 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 849 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 850 | 850 | |
| 851 | 851 | if ($globalTimezone != '') { |
| 852 | 852 | date_default_timezone_set($globalTimezone); |
@@ -878,8 +878,8 @@ discard block |
||
| 878 | 878 | { |
| 879 | 879 | $limit_array = explode(",", $limit); |
| 880 | 880 | |
| 881 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 881 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 883 | 883 | |
| 884 | 884 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 885 | 885 | { |
@@ -890,8 +890,8 @@ discard block |
||
| 890 | 890 | |
| 891 | 891 | |
| 892 | 892 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 893 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 894 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 893 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 894 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 895 | 895 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 896 | 896 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 897 | 897 | } else { |
@@ -908,12 +908,12 @@ discard block |
||
| 908 | 908 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 911 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 912 | 912 | WHERE spotter_archive_output.ident <> '' |
| 913 | 913 | ".$additional_query." |
| 914 | 914 | ".$filter_query.$orderby_query; |
| 915 | 915 | } |
| 916 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 916 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 917 | 917 | |
| 918 | 918 | return $spotter_array; |
| 919 | 919 | } |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | try { |
| 931 | 931 | $sth = $this->db->prepare($query); |
| 932 | 932 | $sth->execute(); |
| 933 | - } catch(PDOException $e) { |
|
| 933 | + } catch (PDOException $e) { |
|
| 934 | 934 | return "error"; |
| 935 | 935 | } |
| 936 | 936 | } |
@@ -967,8 +967,8 @@ discard block |
||
| 967 | 967 | { |
| 968 | 968 | $limit_array = explode(",", $limit); |
| 969 | 969 | |
| 970 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 971 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 970 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 971 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 972 | 972 | |
| 973 | 973 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 974 | 974 | { |
@@ -1009,7 +1009,7 @@ discard block |
||
| 1009 | 1009 | $query_values = array(); |
| 1010 | 1010 | $limit_query = ''; |
| 1011 | 1011 | $additional_query = ''; |
| 1012 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1012 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1013 | 1013 | |
| 1014 | 1014 | if ($owner != "") |
| 1015 | 1015 | { |
@@ -1026,8 +1026,8 @@ discard block |
||
| 1026 | 1026 | { |
| 1027 | 1027 | $limit_array = explode(",", $limit); |
| 1028 | 1028 | |
| 1029 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1030 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1029 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1030 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1031 | 1031 | |
| 1032 | 1032 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1033 | 1033 | { |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | $query_values = array(); |
| 1068 | 1068 | $limit_query = ''; |
| 1069 | 1069 | $additional_query = ''; |
| 1070 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1070 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1071 | 1071 | |
| 1072 | 1072 | if ($pilot != "") |
| 1073 | 1073 | { |
@@ -1079,8 +1079,8 @@ discard block |
||
| 1079 | 1079 | { |
| 1080 | 1080 | $limit_array = explode(",", $limit); |
| 1081 | 1081 | |
| 1082 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1083 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1082 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1083 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1084 | 1084 | |
| 1085 | 1085 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1086 | 1086 | { |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | * @return Array the airline country list |
| 1111 | 1111 | * |
| 1112 | 1112 | */ |
| 1113 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1113 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1114 | 1114 | { |
| 1115 | 1115 | global $globalDBdriver; |
| 1116 | 1116 | /* |
@@ -1139,7 +1139,7 @@ discard block |
||
| 1139 | 1139 | $flight_array = array(); |
| 1140 | 1140 | $temp_array = array(); |
| 1141 | 1141 | |
| 1142 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1142 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1143 | 1143 | { |
| 1144 | 1144 | $temp_array['flight_count'] = $row['nb']; |
| 1145 | 1145 | $temp_array['flight_country'] = $row['name']; |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | * @return Array the airline country list |
| 1157 | 1157 | * |
| 1158 | 1158 | */ |
| 1159 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1159 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1160 | 1160 | { |
| 1161 | 1161 | global $globalDBdriver; |
| 1162 | 1162 | /* |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | $flight_array = array(); |
| 1186 | 1186 | $temp_array = array(); |
| 1187 | 1187 | |
| 1188 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1188 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1189 | 1189 | { |
| 1190 | 1190 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1191 | 1191 | $temp_array['flight_count'] = $row['nb']; |
@@ -1203,14 +1203,14 @@ discard block |
||
| 1203 | 1203 | * @return Array the spotter information |
| 1204 | 1204 | * |
| 1205 | 1205 | */ |
| 1206 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1206 | + public function getDateArchiveSpotterDataById($id, $date) |
|
| 1207 | 1207 | { |
| 1208 | 1208 | $Spotter = new Spotter($this->db); |
| 1209 | 1209 | date_default_timezone_set('UTC'); |
| 1210 | 1210 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1211 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1212 | - $date = date('c',$date); |
|
| 1213 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1211 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1212 | + $date = date('c', $date); |
|
| 1213 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1214 | 1214 | return $spotter_array; |
| 1215 | 1215 | } |
| 1216 | 1216 | |
@@ -1220,14 +1220,14 @@ discard block |
||
| 1220 | 1220 | * @return Array the spotter information |
| 1221 | 1221 | * |
| 1222 | 1222 | */ |
| 1223 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1223 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
| 1224 | 1224 | { |
| 1225 | 1225 | $Spotter = new Spotter($this->db); |
| 1226 | 1226 | date_default_timezone_set('UTC'); |
| 1227 | 1227 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1228 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1229 | - $date = date('c',$date); |
|
| 1230 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1228 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1229 | + $date = date('c', $date); |
|
| 1230 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1231 | 1231 | return $spotter_array; |
| 1232 | 1232 | } |
| 1233 | 1233 | |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | * @return Array the spotter information |
| 1238 | 1238 | * |
| 1239 | 1239 | */ |
| 1240 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1240 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1241 | 1241 | { |
| 1242 | 1242 | global $global_query; |
| 1243 | 1243 | $Spotter = new Spotter(); |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | $query_values = array(); |
| 1246 | 1246 | $limit_query = ''; |
| 1247 | 1247 | $additional_query = ''; |
| 1248 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1248 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1249 | 1249 | |
| 1250 | 1250 | if ($airport != "") |
| 1251 | 1251 | { |
@@ -1262,8 +1262,8 @@ discard block |
||
| 1262 | 1262 | { |
| 1263 | 1263 | $limit_array = explode(",", $limit); |
| 1264 | 1264 | |
| 1265 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1266 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1265 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1266 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1267 | 1267 | |
| 1268 | 1268 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1269 | 1269 | { |
@@ -9,25 +9,25 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
| 10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | class MarineImport { |
| 16 | - private $all_tracked = array(); |
|
| 17 | - private $last_delete_hourly = 0; |
|
| 18 | - private $last_delete = 0; |
|
| 19 | - private $stats = array(); |
|
| 20 | - private $tmd = 0; |
|
| 21 | - private $source_location = array(); |
|
| 22 | - public $db = null; |
|
| 23 | - public $nb = 0; |
|
| 16 | + private $all_tracked = array(); |
|
| 17 | + private $last_delete_hourly = 0; |
|
| 18 | + private $last_delete = 0; |
|
| 19 | + private $stats = array(); |
|
| 20 | + private $tmd = 0; |
|
| 21 | + private $source_location = array(); |
|
| 22 | + public $db = null; |
|
| 23 | + public $nb = 0; |
|
| 24 | 24 | |
| 25 | - public function __construct($dbc = null) { |
|
| 25 | + public function __construct($dbc = null) { |
|
| 26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
| 27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 28 | - $Connection = new Connection($dbc); |
|
| 29 | - $this->db = $Connection->db(); |
|
| 30 | - date_default_timezone_set('UTC'); |
|
| 28 | + $Connection = new Connection($dbc); |
|
| 29 | + $this->db = $Connection->db(); |
|
| 30 | + date_default_timezone_set('UTC'); |
|
| 31 | 31 | } |
| 32 | 32 | // Get previous source stats |
| 33 | 33 | /* |
@@ -46,55 +46,55 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | */ |
| 48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 49 | - $APRSMarine = new APRSMarine(); |
|
| 50 | - //$APRSSpotter->connect(); |
|
| 49 | + $APRSMarine = new APRSMarine(); |
|
| 50 | + //$APRSSpotter->connect(); |
|
| 51 | + } |
|
| 51 | 52 | } |
| 52 | - } |
|
| 53 | 53 | |
| 54 | - public function checkAll() { |
|
| 54 | + public function checkAll() { |
|
| 55 | 55 | global $globalDebug; |
| 56 | 56 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
| 57 | 57 | foreach ($this->all_tracked as $key => $flight) { |
| 58 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 58 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 60 | - $Marine = new Marine($this->db); |
|
| 61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 62 | - } |
|
| 60 | + $Marine = new Marine($this->db); |
|
| 61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 62 | + } |
|
| 63 | + } |
|
| 63 | 64 | } |
| 64 | - } |
|
| 65 | 65 | |
| 66 | - public function del() { |
|
| 66 | + public function del() { |
|
| 67 | 67 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 68 | 68 | // Delete old infos |
| 69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | - if (isset($flight['lastupdate'])) { |
|
| 72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 73 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 74 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 76 | - /* |
|
| 71 | + if (isset($flight['lastupdate'])) { |
|
| 72 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 73 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 74 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 75 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 76 | + /* |
|
| 77 | 77 | $MarineLive = new MarineLive(); |
| 78 | 78 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
| 79 | 79 | $MarineLive->db = null; |
| 80 | 80 | */ |
| 81 | - //$real_arrival = $this->arrival($key); |
|
| 82 | - $Marine = new Marine($this->db); |
|
| 83 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 81 | + //$real_arrival = $this->arrival($key); |
|
| 82 | + $Marine = new Marine($this->db); |
|
| 83 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 84 | 84 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
| 85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 86 | - } |
|
| 87 | - // Put in archive |
|
| 86 | + } |
|
| 87 | + // Put in archive |
|
| 88 | 88 | // $Marine->db = null; |
| 89 | 89 | } |
| 90 | - } |
|
| 91 | - unset($this->all_tracked[$key]); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 90 | + } |
|
| 91 | + unset($this->all_tracked[$key]); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public function add($line) { |
|
| 97 | + public function add($line) { |
|
| 98 | 98 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
| 99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 100 | 100 | date_default_timezone_set('UTC'); |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // SBS format is CSV format |
| 105 | 105 | if(is_array($line) && isset($line['mmsi'])) { |
| 106 | - //print_r($line); |
|
| 107 | - if (isset($line['mmsi'])) { |
|
| 106 | + //print_r($line); |
|
| 107 | + if (isset($line['mmsi'])) { |
|
| 108 | 108 | |
| 109 | 109 | /* |
| 110 | 110 | // Increment message number |
@@ -121,64 +121,64 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $Common = new Common(); |
| 123 | 123 | $AIS = new AIS(); |
| 124 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 125 | - else $id = trim($line['id']); |
|
| 124 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 125 | + else $id = trim($line['id']); |
|
| 126 | 126 | |
| 127 | 127 | if (!isset($this->all_tracked[$id])) { |
| 128 | - $this->all_tracked[$id] = array(); |
|
| 129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
| 131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 132 | - if (!isset($line['id'])) { |
|
| 128 | + $this->all_tracked[$id] = array(); |
|
| 129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
| 131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 132 | + if (!isset($line['id'])) { |
|
| 133 | 133 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 134 | 134 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 136 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 135 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 136 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 141 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 141 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 142 | 142 | $Marine = new Marine($this->db); |
| 143 | 143 | $identity = $Marine->getIdentity($line['mmsi']); |
| 144 | 144 | if (!empty($identity)) { |
| 145 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 146 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 145 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 146 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 147 | 147 | } |
| 148 | 148 | //print_r($identity); |
| 149 | 149 | unset($Marine); |
| 150 | 150 | //$dataFound = true; |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | } |
| 153 | 153 | if (isset($line['type_id']) && $line['type_id'] != '') { |
| 154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 155 | 155 | } |
| 156 | 156 | if (isset($line['type']) && $line['type'] != '') { |
| 157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 158 | 158 | } |
| 159 | 159 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 161 | 161 | } |
| 162 | 162 | if (isset($line['imo']) && $line['imo'] != '') { |
| 163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 164 | 164 | } |
| 165 | 165 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 167 | 167 | } |
| 168 | 168 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 170 | 170 | } |
| 171 | 171 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 177 | 177 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 179 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 179 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 180 | 180 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 181 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 181 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 182 | 182 | $timeelapsed = microtime(true); |
| 183 | 183 | $Marine = new Marine($this->db); |
| 184 | 184 | $fromsource = NULL; |
@@ -186,31 +186,31 @@ discard block |
||
| 186 | 186 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 187 | 187 | $Marine->db = null; |
| 188 | 188 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 189 | - } |
|
| 189 | + } |
|
| 190 | 190 | } |
| 191 | - } |
|
| 192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 191 | + } |
|
| 192 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | if (isset($line['speed']) && $line['speed'] != '') { |
| 196 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 197 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 196 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 198 | 198 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 199 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 200 | - if ($distance > 1000 && $distance < 10000) { |
|
| 199 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 200 | + if ($distance > 1000 && $distance < 10000) { |
|
| 201 | 201 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 202 | 202 | $speed = $speed*3.6; |
| 203 | 203 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
| 204 | 204 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 205 | - } |
|
| 205 | + } |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 209 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 210 | - else unset($timediff); |
|
| 211 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 208 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 209 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 210 | + else unset($timediff); |
|
| 211 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 212 | 212 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 213 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 213 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 214 | 214 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 215 | 215 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 216 | 216 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -218,84 +218,84 @@ discard block |
||
| 218 | 218 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 219 | 219 | $timeelapsed = microtime(true); |
| 220 | 220 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 221 | - $Marine = new Marine($this->db); |
|
| 222 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 223 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 224 | - $Marine->db = null; |
|
| 225 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 221 | + $Marine = new Marine($this->db); |
|
| 222 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 223 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 224 | + $Marine->db = null; |
|
| 225 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 226 | 226 | } |
| 227 | 227 | $this->tmd = 0; |
| 228 | 228 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 229 | - } |
|
| 229 | + } |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 233 | 233 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 234 | 234 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 235 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 236 | - $dataFound = true; |
|
| 237 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 235 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 236 | + $dataFound = true; |
|
| 237 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 238 | 238 | } |
| 239 | 239 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 240 | 240 | } |
| 241 | 241 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 242 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 242 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 243 | 243 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 244 | 244 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 245 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 246 | - $dataFound = true; |
|
| 247 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 245 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 246 | + $dataFound = true; |
|
| 247 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 248 | 248 | } |
| 249 | 249 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - } else if ($globalDebug && $timediff > 20) { |
|
| 252 | + } else if ($globalDebug && $timediff > 20) { |
|
| 253 | 253 | $this->tmd = $this->tmd + 1; |
| 254 | 254 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 255 | 255 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 256 | 256 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 257 | 257 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 258 | - } |
|
| 258 | + } |
|
| 259 | 259 | } |
| 260 | 260 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 261 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 261 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 263 | 263 | } |
| 264 | 264 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 265 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 265 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 266 | 266 | } |
| 267 | 267 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 268 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 268 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 269 | 269 | } |
| 270 | 270 | if (isset($line['status']) && $line['status'] != '') { |
| 271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 275 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 275 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | if (isset($line['heading']) && $line['heading'] != '') { |
| 279 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 280 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 281 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 282 | - //$dataFound = true; |
|
| 279 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 280 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 281 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 282 | + //$dataFound = true; |
|
| 283 | 283 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 284 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 286 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 287 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 284 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 286 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 287 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 288 | 288 | } |
| 289 | 289 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 290 | 290 | |
| 291 | 291 | if (isset($line['datetime'])) { |
| 292 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 292 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 293 | 293 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 294 | - } else { |
|
| 294 | + } else { |
|
| 295 | 295 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
| 296 | 296 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 297 | 297 | return ''; |
| 298 | - } |
|
| 298 | + } |
|
| 299 | 299 | } else { |
| 300 | 300 | date_default_timezone_set('UTC'); |
| 301 | 301 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -303,50 +303,50 @@ discard block |
||
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 306 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 307 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 308 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 309 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 306 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 307 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 308 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 309 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 310 | 310 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 311 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 312 | - $timeelapsed = microtime(true); |
|
| 313 | - $MarineLive = new MarineLive($this->db); |
|
| 314 | - if (isset($line['id'])) { |
|
| 311 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 312 | + $timeelapsed = microtime(true); |
|
| 313 | + $MarineLive = new MarineLive($this->db); |
|
| 314 | + if (isset($line['id'])) { |
|
| 315 | 315 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 316 | 316 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 317 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 317 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 318 | 318 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 319 | 319 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 320 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 320 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 321 | 321 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 322 | 322 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 323 | - } else $recent_ident = ''; |
|
| 324 | - $MarineLive->db=null; |
|
| 325 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 326 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 323 | + } else $recent_ident = ''; |
|
| 324 | + $MarineLive->db=null; |
|
| 325 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 326 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 327 | 327 | } else $recent_ident = ''; |
| 328 | - } else { |
|
| 328 | + } else { |
|
| 329 | 329 | $recent_ident = ''; |
| 330 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 331 | - } |
|
| 332 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 333 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 334 | - { |
|
| 331 | + } |
|
| 332 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 333 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 334 | + { |
|
| 335 | 335 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 336 | 336 | //adds the spotter data for the archive |
| 337 | - $highlight = ''; |
|
| 338 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 339 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 337 | + $highlight = ''; |
|
| 338 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 339 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 340 | 340 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 341 | - $timeelapsed = microtime(true); |
|
| 342 | - $Marine = new Marine($this->db); |
|
| 343 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 344 | - $Marine->db = null; |
|
| 345 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 341 | + $timeelapsed = microtime(true); |
|
| 342 | + $Marine = new Marine($this->db); |
|
| 343 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 344 | + $Marine->db = null; |
|
| 345 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 346 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 347 | 347 | } |
| 348 | - } |
|
| 349 | - /* |
|
| 348 | + } |
|
| 349 | + /* |
|
| 350 | 350 | // Add source stat in DB |
| 351 | 351 | $Stats = new Stats($this->db); |
| 352 | 352 | if (!empty($this->stats)) { |
@@ -373,56 +373,56 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | $Stats->db = null; |
| 375 | 375 | */ |
| 376 | - $this->del(); |
|
| 376 | + $this->del(); |
|
| 377 | 377 | //$ignoreImport = false; |
| 378 | 378 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 379 | 379 | //print_r($this->all_tracked[$id]); |
| 380 | 380 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 381 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 382 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 383 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 381 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 382 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 383 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 384 | 384 | $MarineLive = new MarineLive($this->db); |
| 385 | 385 | $MarineLive->deleteLiveMarineData(); |
| 386 | 386 | $MarineLive->db=null; |
| 387 | 387 | if ($globalDebug) echo " Done\n"; |
| 388 | - } |
|
| 389 | - $this->last_delete = time(); |
|
| 388 | + } |
|
| 389 | + $this->last_delete = time(); |
|
| 390 | 390 | } |
| 391 | - } elseif ($recent_ident != '') { |
|
| 391 | + } elseif ($recent_ident != '') { |
|
| 392 | 392 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 393 | 393 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 394 | 394 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 395 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
| 395 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
| 396 | 396 | $Marine = new Marine($this->db); |
| 397 | 397 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
| 398 | 398 | $Marine->db = null; |
| 399 | - } |
|
| 399 | + } |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - } |
|
| 402 | + } |
|
| 403 | 403 | } |
| 404 | - } |
|
| 405 | - //adds the spotter LIVE data |
|
| 406 | - if ($globalDebug) { |
|
| 404 | + } |
|
| 405 | + //adds the spotter LIVE data |
|
| 406 | + if ($globalDebug) { |
|
| 407 | 407 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 408 | - } |
|
| 409 | - $ignoreImport = false; |
|
| 408 | + } |
|
| 409 | + $ignoreImport = false; |
|
| 410 | 410 | |
| 411 | - if (!$ignoreImport) { |
|
| 411 | + if (!$ignoreImport) { |
|
| 412 | 412 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 413 | 413 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 414 | 414 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 415 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 415 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 416 | 416 | $timeelapsed = microtime(true); |
| 417 | 417 | $MarineLive = new MarineLive($this->db); |
| 418 | 418 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 419 | 419 | $MarineLive->db = null; |
| 420 | 420 | if ($globalDebug) echo $result."\n"; |
| 421 | 421 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 422 | - } |
|
| 422 | + } |
|
| 423 | 423 | } |
| 424 | 424 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 425 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 425 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 426 | 426 | } |
| 427 | 427 | $this->all_tracked[$id]['putinarchive'] = false; |
| 428 | 428 | |
@@ -487,24 +487,24 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 490 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 490 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 491 | 491 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
| 492 | 492 | $MarineLive = new MarineLive($this->db); |
| 493 | 493 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 494 | 494 | $MarineLive->db = null; |
| 495 | 495 | //MarineLive->deleteLiveMarineData(); |
| 496 | 496 | if ($globalDebug) echo " Done\n"; |
| 497 | - } |
|
| 498 | - $this->last_delete_hourly = time(); |
|
| 497 | + } |
|
| 498 | + $this->last_delete_hourly = time(); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - } |
|
| 502 | - //$ignoreImport = false; |
|
| 501 | + } |
|
| 502 | + //$ignoreImport = false; |
|
| 503 | 503 | } |
| 504 | 504 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 505 | 505 | if ($send) return $this->all_tracked[$id]; |
| 506 | - } |
|
| 506 | + } |
|
| 507 | + } |
|
| 507 | 508 | } |
| 508 | - } |
|
| 509 | 509 | } |
| 510 | 510 | ?> |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | if (isset($this->all_tracked[$key]['id'])) { |
| 59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 60 | 60 | $Marine = new Marine($this->db); |
| 61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | 71 | if (isset($flight['lastupdate'])) { |
| 72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 72 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 73 | 73 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 74 | 74 | if (isset($this->all_tracked[$key]['id'])) { |
| 75 | 75 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | //$real_arrival = $this->arrival($key); |
| 82 | 82 | $Marine = new Marine($this->db); |
| 83 | 83 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 84 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 84 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
| 85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 86 | 86 | } |
| 87 | 87 | // Put in archive |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function add($line) { |
| 98 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
| 98 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
| 99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 100 | 100 | date_default_timezone_set('UTC'); |
| 101 | 101 | $dataFound = false; |
| 102 | 102 | $send = false; |
| 103 | 103 | |
| 104 | 104 | // SBS format is CSV format |
| 105 | - if(is_array($line) && isset($line['mmsi'])) { |
|
| 105 | + if (is_array($line) && isset($line['mmsi'])) { |
|
| 106 | 106 | //print_r($line); |
| 107 | 107 | if (isset($line['mmsi'])) { |
| 108 | 108 | |
@@ -126,18 +126,18 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | if (!isset($this->all_tracked[$id])) { |
| 128 | 128 | $this->all_tracked[$id] = array(); |
| 129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
| 131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
| 130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
| 131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
| 132 | 132 | if (!isset($line['id'])) { |
| 133 | 133 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 135 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
| 136 | 136 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
| 141 | 141 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 142 | 142 | $Marine = new Marine($this->db); |
| 143 | 143 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -151,66 +151,66 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | if (isset($line['type_id']) && $line['type_id'] != '') { |
| 154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
| 155 | 155 | } |
| 156 | 156 | if (isset($line['type']) && $line['type'] != '') { |
| 157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 158 | 158 | } |
| 159 | 159 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
| 161 | 161 | } |
| 162 | 162 | if (isset($line['imo']) && $line['imo'] != '') { |
| 163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
| 164 | 164 | } |
| 165 | 165 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
| 167 | 167 | } |
| 168 | 168 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
| 170 | 170 | } |
| 171 | 171 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 177 | 177 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 179 | 179 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 180 | 180 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 181 | 181 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 182 | 182 | $timeelapsed = microtime(true); |
| 183 | 183 | $Marine = new Marine($this->db); |
| 184 | 184 | $fromsource = NULL; |
| 185 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 185 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 186 | 186 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 187 | 187 | $Marine->db = null; |
| 188 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 188 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 192 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | if (isset($line['speed']) && $line['speed'] != '') { |
| 196 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 197 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 196 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
| 197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 198 | 198 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 199 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 199 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 200 | 200 | if ($distance > 1000 && $distance < 10000) { |
| 201 | 201 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 202 | 202 | $speed = $speed*3.6; |
| 203 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 203 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
| 204 | 204 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 209 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 209 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 210 | 210 | else unset($timediff); |
| 211 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 211 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
| 212 | 212 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 213 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 213 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 214 | 214 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 215 | 215 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 216 | 216 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | $timeelapsed = microtime(true); |
| 220 | 220 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 221 | 221 | $Marine = new Marine($this->db); |
| 222 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 222 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 223 | 223 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 224 | 224 | $Marine->db = null; |
| 225 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 225 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 226 | 226 | } |
| 227 | 227 | $this->tmd = 0; |
| 228 | 228 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -231,66 +231,66 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 233 | 233 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 234 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 234 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 235 | 235 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 236 | 236 | $dataFound = true; |
| 237 | 237 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 238 | 238 | } |
| 239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 240 | 240 | } |
| 241 | 241 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 242 | 242 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 243 | 243 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 244 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 244 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 245 | 245 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 246 | 246 | $dataFound = true; |
| 247 | 247 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 248 | 248 | } |
| 249 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 249 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | } else if ($globalDebug && $timediff > 20) { |
| 253 | 253 | $this->tmd = $this->tmd + 1; |
| 254 | 254 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 255 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 256 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 255 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 256 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 257 | 257 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 261 | 261 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 263 | 263 | } |
| 264 | 264 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 265 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 265 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 266 | 266 | } |
| 267 | 267 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 268 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 268 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 269 | 269 | } |
| 270 | 270 | if (isset($line['status']) && $line['status'] != '') { |
| 271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 275 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 275 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | if (isset($line['heading']) && $line['heading'] != '') { |
| 279 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 280 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 281 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 279 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 280 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 281 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 282 | 282 | //$dataFound = true; |
| 283 | 283 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 284 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 286 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 284 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 286 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 287 | 287 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 288 | 288 | } |
| 289 | 289 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 290 | 290 | |
| 291 | 291 | if (isset($line['datetime'])) { |
| 292 | 292 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 294 | 294 | } else { |
| 295 | 295 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
| 296 | 296 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -298,14 +298,14 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | } else { |
| 300 | 300 | date_default_timezone_set('UTC'); |
| 301 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 301 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 306 | 306 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 307 | 307 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
| 308 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 308 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 309 | 309 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 310 | 310 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 311 | 311 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
@@ -313,37 +313,37 @@ discard block |
||
| 313 | 313 | $MarineLive = new MarineLive($this->db); |
| 314 | 314 | if (isset($line['id'])) { |
| 315 | 315 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 316 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 316 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 317 | 317 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 318 | 318 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 319 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 320 | 320 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 321 | 321 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 322 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 322 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 323 | 323 | } else $recent_ident = ''; |
| 324 | - $MarineLive->db=null; |
|
| 324 | + $MarineLive->db = null; |
|
| 325 | 325 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 326 | 326 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 327 | 327 | } else $recent_ident = ''; |
| 328 | 328 | } else { |
| 329 | 329 | $recent_ident = ''; |
| 330 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 330 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 331 | 331 | } |
| 332 | 332 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 333 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 333 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 334 | 334 | { |
| 335 | 335 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 336 | 336 | //adds the spotter data for the archive |
| 337 | 337 | $highlight = ''; |
| 338 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 338 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 339 | 339 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 340 | 340 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 341 | 341 | $timeelapsed = microtime(true); |
| 342 | 342 | $Marine = new Marine($this->db); |
| 343 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 343 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
| 344 | 344 | $Marine->db = null; |
| 345 | 345 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 346 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | /* |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 384 | 384 | $MarineLive = new MarineLive($this->db); |
| 385 | 385 | $MarineLive->deleteLiveMarineData(); |
| 386 | - $MarineLive->db=null; |
|
| 386 | + $MarineLive->db = null; |
|
| 387 | 387 | if ($globalDebug) echo " Done\n"; |
| 388 | 388 | } |
| 389 | 389 | $this->last_delete = time(); |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 395 | 395 | if (isset($globalDaemon) && !$globalDaemon) { |
| 396 | 396 | $Marine = new Marine($this->db); |
| 397 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
| 397 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
| 398 | 398 | $Marine->db = null; |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -409,20 +409,20 @@ discard block |
||
| 409 | 409 | $ignoreImport = false; |
| 410 | 410 | |
| 411 | 411 | if (!$ignoreImport) { |
| 412 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 412 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 413 | 413 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 414 | 414 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 415 | 415 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 416 | 416 | $timeelapsed = microtime(true); |
| 417 | 417 | $MarineLive = new MarineLive($this->db); |
| 418 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 418 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 419 | 419 | $MarineLive->db = null; |
| 420 | 420 | if ($globalDebug) echo $result."\n"; |
| 421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 421 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 425 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 425 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 426 | 426 | } |
| 427 | 427 | $this->all_tracked[$id]['putinarchive'] = false; |
| 428 | 428 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 484 | 484 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 485 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 485 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 486 | 486 | //$this->del(); |
| 487 | 487 | |
| 488 | 488 | |
@@ -53,7 +53,9 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function checkAll() { |
| 55 | 55 | global $globalDebug; |
| 56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 56 | + if ($globalDebug) { |
|
| 57 | + echo "Update last seen tracked data...\n"; |
|
| 58 | + } |
|
| 57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
| 58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
| 59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,13 +68,17 @@ discard block |
||
| 66 | 68 | public function del() { |
| 67 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 68 | 70 | // Delete old infos |
| 69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 71 | + if ($globalDebug) { |
|
| 72 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 73 | + } |
|
| 70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | 75 | if (isset($flight['lastupdate'])) { |
| 72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
| 73 | 77 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 74 | 78 | if (isset($this->all_tracked[$key]['id'])) { |
| 75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 79 | + if ($globalDebug) { |
|
| 80 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 81 | + } |
|
| 76 | 82 | /* |
| 77 | 83 | $MarineLive = new MarineLive(); |
| 78 | 84 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -82,7 +88,9 @@ discard block |
||
| 82 | 88 | $Marine = new Marine($this->db); |
| 83 | 89 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 84 | 90 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
| 85 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 91 | + if ($globalDebug && $result != 'success') { |
|
| 92 | + echo '!!! ERROR : '.$result."\n"; |
|
| 93 | + } |
|
| 86 | 94 | } |
| 87 | 95 | // Put in archive |
| 88 | 96 | // $Marine->db = null; |
@@ -96,7 +104,9 @@ discard block |
||
| 96 | 104 | |
| 97 | 105 | public function add($line) { |
| 98 | 106 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
| 99 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 107 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 108 | + $globalCoordMinChange = '0.02'; |
|
| 109 | + } |
|
| 100 | 110 | date_default_timezone_set('UTC'); |
| 101 | 111 | $dataFound = false; |
| 102 | 112 | $send = false; |
@@ -121,8 +131,11 @@ discard block |
||
| 121 | 131 | |
| 122 | 132 | $Common = new Common(); |
| 123 | 133 | $AIS = new AIS(); |
| 124 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 125 | - else $id = trim($line['id']); |
|
| 134 | + if (!isset($line['id'])) { |
|
| 135 | + $id = trim($line['mmsi']); |
|
| 136 | + } else { |
|
| 137 | + $id = trim($line['id']); |
|
| 138 | + } |
|
| 126 | 139 | |
| 127 | 140 | if (!isset($this->all_tracked[$id])) { |
| 128 | 141 | $this->all_tracked[$id] = array(); |
@@ -130,10 +143,16 @@ discard block |
||
| 130 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
| 131 | 144 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 132 | 145 | if (!isset($line['id'])) { |
| 133 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 146 | + if (!isset($globalDaemon)) { |
|
| 147 | + $globalDaemon = TRUE; |
|
| 148 | + } |
|
| 134 | 149 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 136 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 150 | + } else { |
|
| 151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 152 | + } |
|
| 153 | + if ($globalAllTracked !== FALSE) { |
|
| 154 | + $dataFound = true; |
|
| 155 | + } |
|
| 137 | 156 | } |
| 138 | 157 | |
| 139 | 158 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -183,13 +202,19 @@ discard block |
||
| 183 | 202 | $Marine = new Marine($this->db); |
| 184 | 203 | $fromsource = NULL; |
| 185 | 204 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 186 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 205 | + if ($globalDebug && $result != 'success') { |
|
| 206 | + echo '!!! ERROR : '.$result."\n"; |
|
| 207 | + } |
|
| 187 | 208 | $Marine->db = null; |
| 188 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 209 | + if ($globalDebugTimeElapsed) { |
|
| 210 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 211 | + } |
|
| 189 | 212 | } |
| 190 | 213 | } |
| 191 | 214 | } |
| 192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 215 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 216 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 217 | + } |
|
| 193 | 218 | } |
| 194 | 219 | |
| 195 | 220 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -200,14 +225,21 @@ discard block |
||
| 200 | 225 | if ($distance > 1000 && $distance < 10000) { |
| 201 | 226 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 202 | 227 | $speed = $speed*3.6; |
| 203 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 204 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 228 | + if ($speed < 1000) { |
|
| 229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 230 | + } |
|
| 231 | + if ($globalDebug) { |
|
| 232 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 233 | + } |
|
| 205 | 234 | } |
| 206 | 235 | } |
| 207 | 236 | |
| 208 | 237 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 209 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 210 | - else unset($timediff); |
|
| 238 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 239 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 240 | + } else { |
|
| 241 | + unset($timediff); |
|
| 242 | + } |
|
| 211 | 243 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 212 | 244 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 213 | 245 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -215,22 +247,32 @@ discard block |
||
| 215 | 247 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 216 | 248 | $this->all_tracked[$id]['putinarchive'] = true; |
| 217 | 249 | |
| 218 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 250 | + if ($globalDebug) { |
|
| 251 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 252 | + } |
|
| 219 | 253 | $timeelapsed = microtime(true); |
| 220 | 254 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 221 | 255 | $Marine = new Marine($this->db); |
| 222 | 256 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 223 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 257 | + if (!empty($all_country)) { |
|
| 258 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 259 | + } |
|
| 224 | 260 | $Marine->db = null; |
| 225 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 261 | + if ($globalDebugTimeElapsed) { |
|
| 262 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 263 | + } |
|
| 226 | 264 | } |
| 227 | 265 | $this->tmd = 0; |
| 228 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 266 | + if ($globalDebug) { |
|
| 267 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 268 | + } |
|
| 229 | 269 | } |
| 230 | 270 | } |
| 231 | 271 | |
| 232 | 272 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 233 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 273 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 274 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 275 | + } |
|
| 234 | 276 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 235 | 277 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 236 | 278 | $dataFound = true; |
@@ -239,8 +281,12 @@ discard block |
||
| 239 | 281 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 240 | 282 | } |
| 241 | 283 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 242 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 243 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 284 | + if ($line['longitude'] > 180) { |
|
| 285 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 286 | + } |
|
| 287 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 288 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 289 | + } |
|
| 244 | 290 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 245 | 291 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 246 | 292 | $dataFound = true; |
@@ -258,7 +304,9 @@ discard block |
||
| 258 | 304 | } |
| 259 | 305 | } |
| 260 | 306 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 261 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 307 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 308 | + $dataFound = true; |
|
| 309 | + } |
|
| 262 | 310 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 263 | 311 | } |
| 264 | 312 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -276,15 +324,21 @@ discard block |
||
| 276 | 324 | } |
| 277 | 325 | |
| 278 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
| 279 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 329 | + } |
|
| 280 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 281 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 282 | 332 | //$dataFound = true; |
| 283 | 333 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 284 | 334 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 285 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 286 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 287 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | + } |
|
| 339 | + if ($globalDebug) { |
|
| 340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 341 | + } |
|
| 288 | 342 | } |
| 289 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 290 | 344 | |
@@ -292,8 +346,11 @@ discard block |
||
| 292 | 346 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 293 | 347 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 294 | 348 | } else { |
| 295 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 296 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 349 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 350 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 351 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 352 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 353 | + } |
|
| 297 | 354 | return ''; |
| 298 | 355 | } |
| 299 | 356 | } else { |
@@ -308,23 +365,38 @@ discard block |
||
| 308 | 365 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 309 | 366 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 310 | 367 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 311 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 368 | + if ($globalDebug) { |
|
| 369 | + echo "Check if aircraft is already in DB..."; |
|
| 370 | + } |
|
| 312 | 371 | $timeelapsed = microtime(true); |
| 313 | 372 | $MarineLive = new MarineLive($this->db); |
| 314 | 373 | if (isset($line['id'])) { |
| 315 | 374 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 316 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 375 | + if ($globalDebugTimeElapsed) { |
|
| 376 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 377 | + } |
|
| 317 | 378 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 318 | 379 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 380 | + if ($globalDebugTimeElapsed) { |
|
| 381 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 382 | + } |
|
| 320 | 383 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 321 | 384 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 322 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 323 | - } else $recent_ident = ''; |
|
| 385 | + if ($globalDebugTimeElapsed) { |
|
| 386 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 387 | + } |
|
| 388 | + } else { |
|
| 389 | + $recent_ident = ''; |
|
| 390 | + } |
|
| 324 | 391 | $MarineLive->db=null; |
| 325 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 326 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 327 | - } else $recent_ident = ''; |
|
| 392 | + if ($globalDebug && $recent_ident == '') { |
|
| 393 | + echo " Not in DB.\n"; |
|
| 394 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 395 | + echo " Already in DB.\n"; |
|
| 396 | + } |
|
| 397 | + } else { |
|
| 398 | + $recent_ident = ''; |
|
| 399 | + } |
|
| 328 | 400 | } else { |
| 329 | 401 | $recent_ident = ''; |
| 330 | 402 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -332,18 +404,26 @@ discard block |
||
| 332 | 404 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 333 | 405 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
| 334 | 406 | { |
| 335 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 407 | + if ($globalDebug) { |
|
| 408 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 409 | + } |
|
| 336 | 410 | //adds the spotter data for the archive |
| 337 | 411 | $highlight = ''; |
| 338 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 412 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 413 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 414 | + } |
|
| 339 | 415 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 340 | 416 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 341 | 417 | $timeelapsed = microtime(true); |
| 342 | 418 | $Marine = new Marine($this->db); |
| 343 | 419 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 344 | 420 | $Marine->db = null; |
| 345 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 421 | + if ($globalDebug && isset($result)) { |
|
| 422 | + echo $result."\n"; |
|
| 423 | + } |
|
| 424 | + if ($globalDebugTimeElapsed) { |
|
| 425 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 426 | + } |
|
| 347 | 427 | } |
| 348 | 428 | } |
| 349 | 429 | /* |
@@ -378,13 +458,17 @@ discard block |
||
| 378 | 458 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 379 | 459 | //print_r($this->all_tracked[$id]); |
| 380 | 460 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 381 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 461 | + if ($globalDebug) { |
|
| 462 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 463 | + } |
|
| 382 | 464 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 383 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 384 | 466 | $MarineLive = new MarineLive($this->db); |
| 385 | 467 | $MarineLive->deleteLiveMarineData(); |
| 386 | 468 | $MarineLive->db=null; |
| 387 | - if ($globalDebug) echo " Done\n"; |
|
| 469 | + if ($globalDebug) { |
|
| 470 | + echo " Done\n"; |
|
| 471 | + } |
|
| 388 | 472 | } |
| 389 | 473 | $this->last_delete = time(); |
| 390 | 474 | } |
@@ -410,15 +494,21 @@ discard block |
||
| 410 | 494 | |
| 411 | 495 | if (!$ignoreImport) { |
| 412 | 496 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 413 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 497 | + if ($globalDebug) { |
|
| 498 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 499 | + } |
|
| 414 | 500 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 415 | 501 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 416 | 502 | $timeelapsed = microtime(true); |
| 417 | 503 | $MarineLive = new MarineLive($this->db); |
| 418 | 504 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 419 | 505 | $MarineLive->db = null; |
| 420 | - if ($globalDebug) echo $result."\n"; |
|
| 421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 506 | + if ($globalDebug) { |
|
| 507 | + echo $result."\n"; |
|
| 508 | + } |
|
| 509 | + if ($globalDebugTimeElapsed) { |
|
| 510 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 511 | + } |
|
| 422 | 512 | } |
| 423 | 513 | } |
| 424 | 514 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -481,19 +571,27 @@ discard block |
||
| 481 | 571 | */ |
| 482 | 572 | |
| 483 | 573 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 484 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 485 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 574 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 575 | + $send = true; |
|
| 576 | + } |
|
| 577 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 578 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 579 | + } |
|
| 486 | 580 | //$this->del(); |
| 487 | 581 | |
| 488 | 582 | |
| 489 | 583 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 490 | 584 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 491 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 585 | + if ($globalDebug) { |
|
| 586 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 587 | + } |
|
| 492 | 588 | $MarineLive = new MarineLive($this->db); |
| 493 | 589 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 494 | 590 | $MarineLive->db = null; |
| 495 | 591 | //MarineLive->deleteLiveMarineData(); |
| 496 | - if ($globalDebug) echo " Done\n"; |
|
| 592 | + if ($globalDebug) { |
|
| 593 | + echo " Done\n"; |
|
| 594 | + } |
|
| 497 | 595 | } |
| 498 | 596 | $this->last_delete_hourly = time(); |
| 499 | 597 | } |
@@ -502,7 +600,9 @@ discard block |
||
| 502 | 600 | //$ignoreImport = false; |
| 503 | 601 | } |
| 504 | 602 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 505 | - if ($send) return $this->all_tracked[$id]; |
|
| 603 | + if ($send) { |
|
| 604 | + return $this->all_tracked[$id]; |
|
| 605 | + } |
|
| 506 | 606 | } |
| 507 | 607 | } |
| 508 | 608 | } |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Get SQL query part for filter used |
|
| 16 | - * @param Array $filter the filter |
|
| 17 | - * @return Array the SQL part |
|
| 18 | - */ |
|
| 15 | + * Get SQL query part for filter used |
|
| 16 | + * @param Array $filter the filter |
|
| 17 | + * @return Array the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * Gets all the spotter information based on the latest data entry |
|
| 90 | - * |
|
| 91 | - * @return Array the spotter information |
|
| 92 | - * |
|
| 93 | - */ |
|
| 89 | + * Gets all the spotter information based on the latest data entry |
|
| 90 | + * |
|
| 91 | + * @return Array the spotter information |
|
| 92 | + * |
|
| 93 | + */ |
|
| 94 | 94 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
| 95 | 95 | { |
| 96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * Gets Minimal Live Spotter data |
|
| 136 | - * |
|
| 137 | - * @return Array the spotter information |
|
| 138 | - * |
|
| 139 | - */ |
|
| 135 | + * Gets Minimal Live Spotter data |
|
| 136 | + * |
|
| 137 | + * @return Array the spotter information |
|
| 138 | + * |
|
| 139 | + */ |
|
| 140 | 140 | public function getMinLiveMarineData($filter = array()) |
| 141 | 141 | { |
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -166,11 +166,11 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 170 | - * |
|
| 171 | - * @return Array the spotter information |
|
| 172 | - * |
|
| 173 | - */ |
|
| 169 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 170 | + * |
|
| 171 | + * @return Array the spotter information |
|
| 172 | + * |
|
| 173 | + */ |
|
| 174 | 174 | public function getMinLastLiveMarineData($filter = array()) |
| 175 | 175 | { |
| 176 | 176 | global $globalDBdriver, $globalLiveInterval; |
@@ -183,13 +183,13 @@ discard block |
||
| 183 | 183 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 186 | - } else { |
|
| 186 | + } else { |
|
| 187 | 187 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - try { |
|
| 192 | + try { |
|
| 193 | 193 | $sth = $this->db->prepare($query); |
| 194 | 194 | $sth->execute(); |
| 195 | 195 | } catch(PDOException $e) { |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * Gets number of latest data entry |
|
| 205 | - * |
|
| 206 | - * @return String number of entry |
|
| 207 | - * |
|
| 208 | - */ |
|
| 204 | + * Gets number of latest data entry |
|
| 205 | + * |
|
| 206 | + * @return String number of entry |
|
| 207 | + * |
|
| 208 | + */ |
|
| 209 | 209 | public function getLiveMarineCount($filter = array()) |
| 210 | 210 | { |
| 211 | 211 | global $globalDBdriver, $globalLiveInterval; |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 234 | - * |
|
| 235 | - * @return Array the spotter information |
|
| 236 | - * |
|
| 237 | - */ |
|
| 233 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 234 | + * |
|
| 235 | + * @return Array the spotter information |
|
| 236 | + * |
|
| 237 | + */ |
|
| 238 | 238 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
| 239 | 239 | { |
| 240 | 240 | global $globalDBdriver, $globalLiveInterval; |
@@ -258,11 +258,11 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 262 | - * |
|
| 263 | - * @return Array the spotter information |
|
| 264 | - * |
|
| 265 | - */ |
|
| 261 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 262 | + * |
|
| 263 | + * @return Array the spotter information |
|
| 264 | + * |
|
| 265 | + */ |
|
| 266 | 266 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
| 267 | 267 | { |
| 268 | 268 | global $globalDBdriver, $globalLiveInterval; |
@@ -290,11 +290,11 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
| 293 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 294 | - * |
|
| 295 | - * @return Array the spotter information |
|
| 296 | - * |
|
| 297 | - */ |
|
| 293 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 294 | + * |
|
| 295 | + * @return Array the spotter information |
|
| 296 | + * |
|
| 297 | + */ |
|
| 298 | 298 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
| 299 | 299 | { |
| 300 | 300 | $Marine = new Marine($this->db); |
@@ -307,134 +307,134 @@ discard block |
||
| 307 | 307 | if ($lng != '') |
| 308 | 308 | { |
| 309 | 309 | if (!is_numeric($lng)) |
| 310 | - { |
|
| 311 | - return false; |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - if ($radius != '') |
|
| 316 | - { |
|
| 317 | - if (!is_numeric($radius)) |
|
| 318 | - { |
|
| 319 | - return false; |
|
| 320 | - } |
|
| 321 | - } |
|
| 310 | + { |
|
| 311 | + return false; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + if ($radius != '') |
|
| 316 | + { |
|
| 317 | + if (!is_numeric($radius)) |
|
| 318 | + { |
|
| 319 | + return false; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | 322 | $additional_query = ''; |
| 323 | 323 | if ($interval != '') |
| 324 | - { |
|
| 325 | - if (!is_string($interval)) |
|
| 326 | - { |
|
| 327 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 328 | - return false; |
|
| 329 | - } else { |
|
| 330 | - if ($interval == '1m') |
|
| 331 | - { |
|
| 332 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 333 | - } else if ($interval == '15m'){ |
|
| 334 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - } else { |
|
| 338 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 324 | + { |
|
| 325 | + if (!is_string($interval)) |
|
| 326 | + { |
|
| 327 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 328 | + return false; |
|
| 329 | + } else { |
|
| 330 | + if ($interval == '1m') |
|
| 331 | + { |
|
| 332 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 333 | + } else if ($interval == '15m'){ |
|
| 334 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + } else { |
|
| 338 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 342 | 342 | WHERE marine_live.latitude <> '' |
| 343 | 343 | AND marine_live.longitude <> '' |
| 344 | 344 | ".$additional_query." |
| 345 | 345 | HAVING distance < :radius |
| 346 | 346 | ORDER BY distance"; |
| 347 | 347 | |
| 348 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 348 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 349 | 349 | |
| 350 | - return $spotter_array; |
|
| 351 | - } |
|
| 350 | + return $spotter_array; |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | 353 | |
| 354 | - /** |
|
| 355 | - * Gets all the spotter information based on a particular callsign |
|
| 356 | - * |
|
| 357 | - * @return Array the spotter information |
|
| 358 | - * |
|
| 359 | - */ |
|
| 354 | + /** |
|
| 355 | + * Gets all the spotter information based on a particular callsign |
|
| 356 | + * |
|
| 357 | + * @return Array the spotter information |
|
| 358 | + * |
|
| 359 | + */ |
|
| 360 | 360 | public function getLastLiveMarineDataByIdent($ident) |
| 361 | 361 | { |
| 362 | 362 | $Marine = new Marine($this->db); |
| 363 | 363 | date_default_timezone_set('UTC'); |
| 364 | 364 | |
| 365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 367 | 367 | |
| 368 | 368 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 369 | 369 | |
| 370 | 370 | return $spotter_array; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * Gets all the spotter information based on a particular callsign |
|
| 375 | - * |
|
| 376 | - * @return Array the spotter information |
|
| 377 | - * |
|
| 378 | - */ |
|
| 373 | + /** |
|
| 374 | + * Gets all the spotter information based on a particular callsign |
|
| 375 | + * |
|
| 376 | + * @return Array the spotter information |
|
| 377 | + * |
|
| 378 | + */ |
|
| 379 | 379 | public function getDateLiveMarineDataByIdent($ident,$date) |
| 380 | 380 | { |
| 381 | 381 | $Marine = new Marine($this->db); |
| 382 | 382 | date_default_timezone_set('UTC'); |
| 383 | 383 | |
| 384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 386 | 386 | |
| 387 | - $date = date('c',$date); |
|
| 387 | + $date = date('c',$date); |
|
| 388 | 388 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 389 | 389 | |
| 390 | 390 | return $spotter_array; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - /** |
|
| 394 | - * Gets last spotter information based on a particular callsign |
|
| 395 | - * |
|
| 396 | - * @return Array the spotter information |
|
| 397 | - * |
|
| 398 | - */ |
|
| 393 | + /** |
|
| 394 | + * Gets last spotter information based on a particular callsign |
|
| 395 | + * |
|
| 396 | + * @return Array the spotter information |
|
| 397 | + * |
|
| 398 | + */ |
|
| 399 | 399 | public function getLastLiveMarineDataById($id) |
| 400 | 400 | { |
| 401 | 401 | $Marine = new Marine($this->db); |
| 402 | 402 | date_default_timezone_set('UTC'); |
| 403 | 403 | |
| 404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 406 | 406 | |
| 407 | 407 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
| 408 | 408 | |
| 409 | 409 | return $spotter_array; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - /** |
|
| 413 | - * Gets last spotter information based on a particular callsign |
|
| 414 | - * |
|
| 415 | - * @return Array the spotter information |
|
| 416 | - * |
|
| 417 | - */ |
|
| 412 | + /** |
|
| 413 | + * Gets last spotter information based on a particular callsign |
|
| 414 | + * |
|
| 415 | + * @return Array the spotter information |
|
| 416 | + * |
|
| 417 | + */ |
|
| 418 | 418 | public function getDateLiveMarineDataById($id,$date) |
| 419 | 419 | { |
| 420 | 420 | $Marine = new Marine($this->db); |
| 421 | 421 | date_default_timezone_set('UTC'); |
| 422 | 422 | |
| 423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | - $date = date('c',$date); |
|
| 424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | + $date = date('c',$date); |
|
| 426 | 426 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 427 | 427 | |
| 428 | 428 | return $spotter_array; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | |
| 432 | - /** |
|
| 433 | - * Gets all the spotter information based on a particular id |
|
| 434 | - * |
|
| 435 | - * @return Array the spotter information |
|
| 436 | - * |
|
| 437 | - */ |
|
| 432 | + /** |
|
| 433 | + * Gets all the spotter information based on a particular id |
|
| 434 | + * |
|
| 435 | + * @return Array the spotter information |
|
| 436 | + * |
|
| 437 | + */ |
|
| 438 | 438 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
| 439 | 439 | { |
| 440 | 440 | global $globalDBdriver, $globalLiveInterval; |
@@ -462,18 +462,18 @@ discard block |
||
| 462 | 462 | return $spotter_array; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - /** |
|
| 466 | - * Gets all the spotter information based on a particular ident |
|
| 467 | - * |
|
| 468 | - * @return Array the spotter information |
|
| 469 | - * |
|
| 470 | - */ |
|
| 465 | + /** |
|
| 466 | + * Gets all the spotter information based on a particular ident |
|
| 467 | + * |
|
| 468 | + * @return Array the spotter information |
|
| 469 | + * |
|
| 470 | + */ |
|
| 471 | 471 | public function getAllLiveMarineDataByIdent($ident) |
| 472 | 472 | { |
| 473 | 473 | date_default_timezone_set('UTC'); |
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 475 | 475 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
| 476 | - try { |
|
| 476 | + try { |
|
| 477 | 477 | |
| 478 | 478 | $sth = $this->db->prepare($query); |
| 479 | 479 | $sth->execute(array(':ident' => $ident)); |
@@ -487,23 +487,23 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | /** |
| 490 | - * Deletes all info in the table |
|
| 491 | - * |
|
| 492 | - * @return String success or false |
|
| 493 | - * |
|
| 494 | - */ |
|
| 490 | + * Deletes all info in the table |
|
| 491 | + * |
|
| 492 | + * @return String success or false |
|
| 493 | + * |
|
| 494 | + */ |
|
| 495 | 495 | public function deleteLiveMarineData() |
| 496 | 496 | { |
| 497 | 497 | global $globalDBdriver; |
| 498 | 498 | if ($globalDBdriver == 'mysql') { |
| 499 | 499 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
| 500 | 500 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
| 501 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 501 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 502 | 502 | } else { |
| 503 | 503 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - try { |
|
| 506 | + try { |
|
| 507 | 507 | |
| 508 | 508 | $sth = $this->db->prepare($query); |
| 509 | 509 | $sth->execute(); |
@@ -515,18 +515,18 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
| 518 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 519 | - * |
|
| 520 | - * @return String success or false |
|
| 521 | - * |
|
| 522 | - */ |
|
| 518 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 519 | + * |
|
| 520 | + * @return String success or false |
|
| 521 | + * |
|
| 522 | + */ |
|
| 523 | 523 | public function deleteLiveMarineDataNotUpdated() |
| 524 | 524 | { |
| 525 | 525 | global $globalDBdriver, $globalDebug; |
| 526 | 526 | if ($globalDBdriver == 'mysql') { |
| 527 | 527 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
| 528 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 529 | - try { |
|
| 528 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 529 | + try { |
|
| 530 | 530 | |
| 531 | 531 | $sth = $this->db->prepare($query); |
| 532 | 532 | $sth->execute(); |
@@ -534,8 +534,8 @@ discard block |
||
| 534 | 534 | return "error"; |
| 535 | 535 | } |
| 536 | 536 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 537 | - $i = 0; |
|
| 538 | - $j =0; |
|
| 537 | + $i = 0; |
|
| 538 | + $j =0; |
|
| 539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 540 | 540 | foreach($all as $row) |
| 541 | 541 | { |
@@ -543,20 +543,20 @@ discard block |
||
| 543 | 543 | $j++; |
| 544 | 544 | if ($j == 30) { |
| 545 | 545 | if ($globalDebug) echo "."; |
| 546 | - try { |
|
| 546 | + try { |
|
| 547 | 547 | |
| 548 | 548 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 549 | 549 | $sth->execute(); |
| 550 | 550 | } catch(PDOException $e) { |
| 551 | 551 | return "error"; |
| 552 | 552 | } |
| 553 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 554 | - $j = 0; |
|
| 553 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 554 | + $j = 0; |
|
| 555 | 555 | } |
| 556 | 556 | $query_delete .= "'".$row['fammarine_id']."',"; |
| 557 | 557 | } |
| 558 | 558 | if ($i > 0) { |
| 559 | - try { |
|
| 559 | + try { |
|
| 560 | 560 | |
| 561 | 561 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 562 | 562 | $sth->execute(); |
@@ -567,9 +567,9 @@ discard block |
||
| 567 | 567 | return "success"; |
| 568 | 568 | } elseif ($globalDBdriver == 'pgsql') { |
| 569 | 569 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
| 570 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 571 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 572 | - try { |
|
| 570 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 571 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 572 | + try { |
|
| 573 | 573 | |
| 574 | 574 | $sth = $this->db->prepare($query); |
| 575 | 575 | $sth->execute(); |
@@ -613,17 +613,17 @@ discard block |
||
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | - * Deletes all info in the table for an ident |
|
| 617 | - * |
|
| 618 | - * @return String success or false |
|
| 619 | - * |
|
| 620 | - */ |
|
| 616 | + * Deletes all info in the table for an ident |
|
| 617 | + * |
|
| 618 | + * @return String success or false |
|
| 619 | + * |
|
| 620 | + */ |
|
| 621 | 621 | public function deleteLiveMarineDataByIdent($ident) |
| 622 | 622 | { |
| 623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 624 | 624 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
| 625 | 625 | |
| 626 | - try { |
|
| 626 | + try { |
|
| 627 | 627 | |
| 628 | 628 | $sth = $this->db->prepare($query); |
| 629 | 629 | $sth->execute(array(':ident' => $ident)); |
@@ -635,17 +635,17 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /** |
| 638 | - * Deletes all info in the table for an id |
|
| 639 | - * |
|
| 640 | - * @return String success or false |
|
| 641 | - * |
|
| 642 | - */ |
|
| 638 | + * Deletes all info in the table for an id |
|
| 639 | + * |
|
| 640 | + * @return String success or false |
|
| 641 | + * |
|
| 642 | + */ |
|
| 643 | 643 | public function deleteLiveMarineDataById($id) |
| 644 | 644 | { |
| 645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 646 | 646 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
| 647 | 647 | |
| 648 | - try { |
|
| 648 | + try { |
|
| 649 | 649 | |
| 650 | 650 | $sth = $this->db->prepare($query); |
| 651 | 651 | $sth->execute(array(':id' => $id)); |
@@ -658,11 +658,11 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | |
| 660 | 660 | /** |
| 661 | - * Gets the aircraft ident within the last hour |
|
| 662 | - * |
|
| 663 | - * @return String the ident |
|
| 664 | - * |
|
| 665 | - */ |
|
| 661 | + * Gets the aircraft ident within the last hour |
|
| 662 | + * |
|
| 663 | + * @return String the ident |
|
| 664 | + * |
|
| 665 | + */ |
|
| 666 | 666 | public function getIdentFromLastHour($ident) |
| 667 | 667 | { |
| 668 | 668 | global $globalDBdriver, $globalTimezone; |
@@ -688,14 +688,14 @@ discard block |
||
| 688 | 688 | $ident_result = $row['ident']; |
| 689 | 689 | } |
| 690 | 690 | return $ident_result; |
| 691 | - } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | 693 | /** |
| 694 | - * Check recent aircraft |
|
| 695 | - * |
|
| 696 | - * @return String the ident |
|
| 697 | - * |
|
| 698 | - */ |
|
| 694 | + * Check recent aircraft |
|
| 695 | + * |
|
| 696 | + * @return String the ident |
|
| 697 | + * |
|
| 698 | + */ |
|
| 699 | 699 | public function checkIdentRecent($ident) |
| 700 | 700 | { |
| 701 | 701 | global $globalDBdriver, $globalTimezone; |
@@ -721,14 +721,14 @@ discard block |
||
| 721 | 721 | $ident_result = $row['fammarine_id']; |
| 722 | 722 | } |
| 723 | 723 | return $ident_result; |
| 724 | - } |
|
| 724 | + } |
|
| 725 | 725 | |
| 726 | 726 | /** |
| 727 | - * Check recent aircraft by id |
|
| 728 | - * |
|
| 729 | - * @return String the ident |
|
| 730 | - * |
|
| 731 | - */ |
|
| 727 | + * Check recent aircraft by id |
|
| 728 | + * |
|
| 729 | + * @return String the ident |
|
| 730 | + * |
|
| 731 | + */ |
|
| 732 | 732 | public function checkIdRecent($id) |
| 733 | 733 | { |
| 734 | 734 | global $globalDBdriver, $globalTimezone; |
@@ -754,14 +754,14 @@ discard block |
||
| 754 | 754 | $ident_result = $row['fammarine_id']; |
| 755 | 755 | } |
| 756 | 756 | return $ident_result; |
| 757 | - } |
|
| 757 | + } |
|
| 758 | 758 | |
| 759 | 759 | /** |
| 760 | - * Check recent aircraft by mmsi |
|
| 761 | - * |
|
| 762 | - * @return String the ident |
|
| 763 | - * |
|
| 764 | - */ |
|
| 760 | + * Check recent aircraft by mmsi |
|
| 761 | + * |
|
| 762 | + * @return String the ident |
|
| 763 | + * |
|
| 764 | + */ |
|
| 765 | 765 | public function checkMMSIRecent($mmsi) |
| 766 | 766 | { |
| 767 | 767 | global $globalDBdriver, $globalTimezone; |
@@ -787,19 +787,19 @@ discard block |
||
| 787 | 787 | $ident_result = $row['fammarine_id']; |
| 788 | 788 | } |
| 789 | 789 | return $ident_result; |
| 790 | - } |
|
| 790 | + } |
|
| 791 | 791 | |
| 792 | 792 | /** |
| 793 | - * Adds a new spotter data |
|
| 794 | - * |
|
| 795 | - * @param String $fammarine_id the ID from flightaware |
|
| 796 | - * @param String $ident the flight ident |
|
| 797 | - * @param String $aircraft_icao the aircraft type |
|
| 798 | - * @param String $departure_airport_icao the departure airport |
|
| 799 | - * @param String $arrival_airport_icao the arrival airport |
|
| 800 | - * @return String success or false |
|
| 801 | - * |
|
| 802 | - */ |
|
| 793 | + * Adds a new spotter data |
|
| 794 | + * |
|
| 795 | + * @param String $fammarine_id the ID from flightaware |
|
| 796 | + * @param String $ident the flight ident |
|
| 797 | + * @param String $aircraft_icao the aircraft type |
|
| 798 | + * @param String $departure_airport_icao the departure airport |
|
| 799 | + * @param String $arrival_airport_icao the arrival airport |
|
| 800 | + * @return String success or false |
|
| 801 | + * |
|
| 802 | + */ |
|
| 803 | 803 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 804 | 804 | { |
| 805 | 805 | global $globalURL, $globalArchive, $globalDebug; |
@@ -870,9 +870,9 @@ discard block |
||
| 870 | 870 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
| 871 | 871 | |
| 872 | 872 | |
| 873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 875 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 874 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 875 | + if ($arrival_date == '') $arrival_date = NULL; |
|
| 876 | 876 | $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
| 877 | 877 | 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)'; |
| 878 | 878 | |
@@ -881,9 +881,9 @@ discard block |
||
| 881 | 881 | |
| 882 | 882 | $sth = $this->db->prepare($query); |
| 883 | 883 | $sth->execute($query_values); |
| 884 | - } catch(PDOException $e) { |
|
| 885 | - return "error : ".$e->getMessage(); |
|
| 886 | - } |
|
| 884 | + } catch(PDOException $e) { |
|
| 885 | + return "error : ".$e->getMessage(); |
|
| 886 | + } |
|
| 887 | 887 | /* |
| 888 | 888 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 889 | 889 | if ($globalDebug) echo '(Add to SBS archive : '; |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 75 | 75 | } |
| 76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 78 | 78 | } |
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 81 | 81 | if ($filter_query_where != '') { |
| 82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 83 | 83 | } |
| 84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
| 85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | if ($limit != '') |
| 103 | 103 | { |
| 104 | 104 | $limit_array = explode(',', $limit); |
| 105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 108 | 108 | { |
| 109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } else { |
| 127 | 127 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
| 128 | 128 | } |
| 129 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 129 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 130 | 130 | |
| 131 | 131 | return $spotter_array; |
| 132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
| 143 | 143 | date_default_timezone_set('UTC'); |
| 144 | 144 | |
| 145 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 145 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 146 | 146 | |
| 147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | try { |
| 157 | 157 | $sth = $this->db->prepare($query); |
| 158 | 158 | $sth->execute(); |
| 159 | - } catch(PDOException $e) { |
|
| 159 | + } catch (PDOException $e) { |
|
| 160 | 160 | echo $e->getMessage(); |
| 161 | 161 | die; |
| 162 | 162 | } |
@@ -176,15 +176,15 @@ discard block |
||
| 176 | 176 | global $globalDBdriver, $globalLiveInterval; |
| 177 | 177 | date_default_timezone_set('UTC'); |
| 178 | 178 | |
| 179 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 179 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 180 | 180 | |
| 181 | 181 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 182 | 182 | if ($globalDBdriver == 'mysql') { |
| 183 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 183 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 186 | 186 | } else { |
| 187 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 187 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | try { |
| 193 | 193 | $sth = $this->db->prepare($query); |
| 194 | 194 | $sth->execute(); |
| 195 | - } catch(PDOException $e) { |
|
| 195 | + } catch (PDOException $e) { |
|
| 196 | 196 | echo $e->getMessage(); |
| 197 | 197 | die; |
| 198 | 198 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | public function getLiveMarineCount($filter = array()) |
| 210 | 210 | { |
| 211 | 211 | global $globalDBdriver, $globalLiveInterval; |
| 212 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 212 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 213 | 213 | |
| 214 | 214 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 215 | 215 | if ($globalDBdriver == 'mysql') { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | try { |
| 221 | 221 | $sth = $this->db->prepare($query); |
| 222 | 222 | $sth->execute(); |
| 223 | - } catch(PDOException $e) { |
|
| 223 | + } catch (PDOException $e) { |
|
| 224 | 224 | echo $e->getMessage(); |
| 225 | 225 | die; |
| 226 | 226 | } |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | $filter_query = $this->getFilter($filter); |
| 244 | 244 | |
| 245 | 245 | if (is_array($coord)) { |
| 246 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 247 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 246 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 247 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | 250 | } else return array(); |
| 251 | 251 | if ($globalDBdriver == 'mysql') { |
| 252 | 252 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -271,17 +271,17 @@ discard block |
||
| 271 | 271 | $filter_query = $this->getFilter($filter); |
| 272 | 272 | |
| 273 | 273 | if (is_array($coord)) { |
| 274 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 275 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 276 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 277 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 274 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 275 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 276 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 277 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 278 | 278 | } else return array(); |
| 279 | 279 | if ($globalDBdriver == 'mysql') { |
| 280 | 280 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 281 | 281 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
| 282 | 282 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 283 | 283 | } else { |
| 284 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 284 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 285 | 285 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 286 | 286 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 287 | 287 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | if ($interval == '1m') |
| 331 | 331 | { |
| 332 | 332 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 333 | - } else if ($interval == '15m'){ |
|
| 333 | + } else if ($interval == '15m') { |
|
| 334 | 334 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
| 335 | 335 | } |
| 336 | 336 | } |
@@ -338,14 +338,14 @@ discard block |
||
| 338 | 338 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 342 | 342 | WHERE marine_live.latitude <> '' |
| 343 | 343 | AND marine_live.longitude <> '' |
| 344 | 344 | ".$additional_query." |
| 345 | 345 | HAVING distance < :radius |
| 346 | 346 | ORDER BY distance"; |
| 347 | 347 | |
| 348 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 348 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 349 | 349 | |
| 350 | 350 | return $spotter_array; |
| 351 | 351 | } |
@@ -363,9 +363,9 @@ discard block |
||
| 363 | 363 | date_default_timezone_set('UTC'); |
| 364 | 364 | |
| 365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 367 | 367 | |
| 368 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 368 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 369 | 369 | |
| 370 | 370 | return $spotter_array; |
| 371 | 371 | } |
@@ -376,16 +376,16 @@ discard block |
||
| 376 | 376 | * @return Array the spotter information |
| 377 | 377 | * |
| 378 | 378 | */ |
| 379 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
| 379 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
| 380 | 380 | { |
| 381 | 381 | $Marine = new Marine($this->db); |
| 382 | 382 | date_default_timezone_set('UTC'); |
| 383 | 383 | |
| 384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 386 | 386 | |
| 387 | - $date = date('c',$date); |
|
| 388 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 387 | + $date = date('c', $date); |
|
| 388 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 389 | 389 | |
| 390 | 390 | return $spotter_array; |
| 391 | 391 | } |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | date_default_timezone_set('UTC'); |
| 403 | 403 | |
| 404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 406 | 406 | |
| 407 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 407 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 408 | 408 | |
| 409 | 409 | return $spotter_array; |
| 410 | 410 | } |
@@ -415,15 +415,15 @@ discard block |
||
| 415 | 415 | * @return Array the spotter information |
| 416 | 416 | * |
| 417 | 417 | */ |
| 418 | - public function getDateLiveMarineDataById($id,$date) |
|
| 418 | + public function getDateLiveMarineDataById($id, $date) |
|
| 419 | 419 | { |
| 420 | 420 | $Marine = new Marine($this->db); |
| 421 | 421 | date_default_timezone_set('UTC'); |
| 422 | 422 | |
| 423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | - $date = date('c',$date); |
|
| 426 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | + $date = date('c', $date); |
|
| 426 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 427 | 427 | |
| 428 | 428 | return $spotter_array; |
| 429 | 429 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * @return Array the spotter information |
| 436 | 436 | * |
| 437 | 437 | */ |
| 438 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
| 438 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
| 439 | 439 | { |
| 440 | 440 | global $globalDBdriver, $globalLiveInterval; |
| 441 | 441 | date_default_timezone_set('UTC'); |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | try { |
| 455 | 455 | $sth = $this->db->prepare($query); |
| 456 | 456 | $sth->execute(array(':id' => $id)); |
| 457 | - } catch(PDOException $e) { |
|
| 457 | + } catch (PDOException $e) { |
|
| 458 | 458 | echo $e->getMessage(); |
| 459 | 459 | die; |
| 460 | 460 | } |
@@ -472,12 +472,12 @@ discard block |
||
| 472 | 472 | { |
| 473 | 473 | date_default_timezone_set('UTC'); |
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 475 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 475 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 476 | 476 | try { |
| 477 | 477 | |
| 478 | 478 | $sth = $this->db->prepare($query); |
| 479 | 479 | $sth->execute(array(':ident' => $ident)); |
| 480 | - } catch(PDOException $e) { |
|
| 480 | + } catch (PDOException $e) { |
|
| 481 | 481 | echo $e->getMessage(); |
| 482 | 482 | die; |
| 483 | 483 | } |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | $sth = $this->db->prepare($query); |
| 509 | 509 | $sth->execute(); |
| 510 | - } catch(PDOException $e) { |
|
| 510 | + } catch (PDOException $e) { |
|
| 511 | 511 | return "error"; |
| 512 | 512 | } |
| 513 | 513 | |
@@ -530,14 +530,14 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | $sth = $this->db->prepare($query); |
| 532 | 532 | $sth->execute(); |
| 533 | - } catch(PDOException $e) { |
|
| 533 | + } catch (PDOException $e) { |
|
| 534 | 534 | return "error"; |
| 535 | 535 | } |
| 536 | 536 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 537 | 537 | $i = 0; |
| 538 | - $j =0; |
|
| 538 | + $j = 0; |
|
| 539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 540 | - foreach($all as $row) |
|
| 540 | + foreach ($all as $row) |
|
| 541 | 541 | { |
| 542 | 542 | $i++; |
| 543 | 543 | $j++; |
@@ -545,9 +545,9 @@ discard block |
||
| 545 | 545 | if ($globalDebug) echo "."; |
| 546 | 546 | try { |
| 547 | 547 | |
| 548 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 548 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 549 | 549 | $sth->execute(); |
| 550 | - } catch(PDOException $e) { |
|
| 550 | + } catch (PDOException $e) { |
|
| 551 | 551 | return "error"; |
| 552 | 552 | } |
| 553 | 553 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -558,9 +558,9 @@ discard block |
||
| 558 | 558 | if ($i > 0) { |
| 559 | 559 | try { |
| 560 | 560 | |
| 561 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 561 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 562 | 562 | $sth->execute(); |
| 563 | - } catch(PDOException $e) { |
|
| 563 | + } catch (PDOException $e) { |
|
| 564 | 564 | return "error"; |
| 565 | 565 | } |
| 566 | 566 | } |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | |
| 574 | 574 | $sth = $this->db->prepare($query); |
| 575 | 575 | $sth->execute(); |
| 576 | - } catch(PDOException $e) { |
|
| 576 | + } catch (PDOException $e) { |
|
| 577 | 577 | return "error"; |
| 578 | 578 | } |
| 579 | 579 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -621,13 +621,13 @@ discard block |
||
| 621 | 621 | public function deleteLiveMarineDataByIdent($ident) |
| 622 | 622 | { |
| 623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 624 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 624 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 625 | 625 | |
| 626 | 626 | try { |
| 627 | 627 | |
| 628 | 628 | $sth = $this->db->prepare($query); |
| 629 | 629 | $sth->execute(array(':ident' => $ident)); |
| 630 | - } catch(PDOException $e) { |
|
| 630 | + } catch (PDOException $e) { |
|
| 631 | 631 | return "error"; |
| 632 | 632 | } |
| 633 | 633 | |
@@ -643,13 +643,13 @@ discard block |
||
| 643 | 643 | public function deleteLiveMarineDataById($id) |
| 644 | 644 | { |
| 645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 646 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 646 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 647 | 647 | |
| 648 | 648 | try { |
| 649 | 649 | |
| 650 | 650 | $sth = $this->db->prepare($query); |
| 651 | 651 | $sth->execute(array(':id' => $id)); |
| 652 | - } catch(PDOException $e) { |
|
| 652 | + } catch (PDOException $e) { |
|
| 653 | 653 | return "error"; |
| 654 | 654 | } |
| 655 | 655 | |
@@ -667,13 +667,13 @@ discard block |
||
| 667 | 667 | { |
| 668 | 668 | global $globalDBdriver, $globalTimezone; |
| 669 | 669 | if ($globalDBdriver == 'mysql') { |
| 670 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
| 670 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
| 671 | 671 | WHERE marine_live.ident = :ident |
| 672 | 672 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 673 | 673 | AND marine_live.date < UTC_TIMESTAMP()'; |
| 674 | 674 | $query_data = array(':ident' => $ident); |
| 675 | 675 | } else { |
| 676 | - $query = "SELECT marine_live.ident FROM marine_live |
|
| 676 | + $query = "SELECT marine_live.ident FROM marine_live |
|
| 677 | 677 | WHERE marine_live.ident = :ident |
| 678 | 678 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 679 | 679 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -682,8 +682,8 @@ discard block |
||
| 682 | 682 | |
| 683 | 683 | $sth = $this->db->prepare($query); |
| 684 | 684 | $sth->execute($query_data); |
| 685 | - $ident_result=''; |
|
| 686 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 685 | + $ident_result = ''; |
|
| 686 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 687 | 687 | { |
| 688 | 688 | $ident_result = $row['ident']; |
| 689 | 689 | } |
@@ -700,13 +700,13 @@ discard block |
||
| 700 | 700 | { |
| 701 | 701 | global $globalDBdriver, $globalTimezone; |
| 702 | 702 | if ($globalDBdriver == 'mysql') { |
| 703 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 703 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 704 | 704 | WHERE marine_live.ident = :ident |
| 705 | 705 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 706 | 706 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 707 | 707 | $query_data = array(':ident' => $ident); |
| 708 | 708 | } else { |
| 709 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 709 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 710 | 710 | WHERE marine_live.ident = :ident |
| 711 | 711 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 712 | 712 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -715,8 +715,8 @@ discard block |
||
| 715 | 715 | |
| 716 | 716 | $sth = $this->db->prepare($query); |
| 717 | 717 | $sth->execute($query_data); |
| 718 | - $ident_result=''; |
|
| 719 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 718 | + $ident_result = ''; |
|
| 719 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 720 | 720 | { |
| 721 | 721 | $ident_result = $row['fammarine_id']; |
| 722 | 722 | } |
@@ -733,13 +733,13 @@ discard block |
||
| 733 | 733 | { |
| 734 | 734 | global $globalDBdriver, $globalTimezone; |
| 735 | 735 | if ($globalDBdriver == 'mysql') { |
| 736 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 736 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 737 | 737 | WHERE marine_live.fammarine_id = :id |
| 738 | 738 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 739 | 739 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 740 | 740 | $query_data = array(':id' => $id); |
| 741 | 741 | } else { |
| 742 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 742 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 743 | 743 | WHERE marine_live.fammarine_id = :id |
| 744 | 744 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 745 | 745 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -748,8 +748,8 @@ discard block |
||
| 748 | 748 | |
| 749 | 749 | $sth = $this->db->prepare($query); |
| 750 | 750 | $sth->execute($query_data); |
| 751 | - $ident_result=''; |
|
| 752 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 751 | + $ident_result = ''; |
|
| 752 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 753 | 753 | { |
| 754 | 754 | $ident_result = $row['fammarine_id']; |
| 755 | 755 | } |
@@ -766,13 +766,13 @@ discard block |
||
| 766 | 766 | { |
| 767 | 767 | global $globalDBdriver, $globalTimezone; |
| 768 | 768 | if ($globalDBdriver == 'mysql') { |
| 769 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 769 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 770 | 770 | WHERE marine_live.mmsi = :mmsi |
| 771 | 771 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 772 | 772 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 773 | 773 | $query_data = array(':mmsi' => $mmsi); |
| 774 | 774 | } else { |
| 775 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 775 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 776 | 776 | WHERE marine_live.mmsi = :mmsi |
| 777 | 777 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 778 | 778 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -781,8 +781,8 @@ discard block |
||
| 781 | 781 | |
| 782 | 782 | $sth = $this->db->prepare($query); |
| 783 | 783 | $sth->execute($query_data); |
| 784 | - $ident_result=''; |
|
| 785 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 784 | + $ident_result = ''; |
|
| 785 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 786 | 786 | { |
| 787 | 787 | $ident_result = $row['fammarine_id']; |
| 788 | 788 | } |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | * @return String success or false |
| 801 | 801 | * |
| 802 | 802 | */ |
| 803 | - public function addLiveMarineData($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 = '') |
|
| 803 | + public function addLiveMarineData($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 = '') |
|
| 804 | 804 | { |
| 805 | 805 | global $globalURL, $globalArchive, $globalDebug; |
| 806 | 806 | $Common = new Common(); |
@@ -852,36 +852,36 @@ discard block |
||
| 852 | 852 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 853 | 853 | |
| 854 | 854 | |
| 855 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 856 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 857 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 859 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 860 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 861 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 862 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 863 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 864 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 865 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 866 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 867 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 868 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 869 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 870 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 855 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 856 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 857 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 859 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 860 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 861 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 862 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 863 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 864 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 865 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 866 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 867 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 868 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 869 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 870 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 871 | 871 | |
| 872 | 872 | |
| 873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 874 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 875 | 875 | if ($arrival_date == '') $arrival_date = NULL; |
| 876 | - $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
| 876 | + $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
| 877 | 877 | 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)'; |
| 878 | 878 | |
| 879 | - $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); |
|
| 879 | + $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); |
|
| 880 | 880 | try { |
| 881 | 881 | |
| 882 | 882 | $sth = $this->db->prepare($query); |
| 883 | 883 | $sth->execute($query_values); |
| 884 | - } catch(PDOException $e) { |
|
| 884 | + } catch (PDOException $e) { |
|
| 885 | 885 | return "error : ".$e->getMessage(); |
| 886 | 886 | } |
| 887 | 887 | /* |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | |
| 899 | 899 | public function getOrderBy() |
| 900 | 900 | { |
| 901 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 901 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 902 | 902 | return $orderby; |
| 903 | 903 | } |
| 904 | 904 | |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
| 76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 78 | 80 | } |
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 81 | + if ($filter_query_where == '' && $where) { |
|
| 82 | + $filter_query_where = ' WHERE'; |
|
| 83 | + } elseif ($filter_query_where != '' && $and) { |
|
| 84 | + $filter_query_where .= ' AND'; |
|
| 85 | + } |
|
| 81 | 86 | if ($filter_query_where != '') { |
| 82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 83 | 88 | } |
@@ -119,7 +124,9 @@ discard block |
||
| 119 | 124 | } |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 127 | + if (!isset($globalLiveInterval)) { |
|
| 128 | + $globalLiveInterval = '200'; |
|
| 129 | + } |
|
| 123 | 130 | if ($globalDBdriver == 'mysql') { |
| 124 | 131 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
| 125 | 132 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
| 144 | 151 | |
| 145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
| 146 | 153 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 154 | + if (!isset($globalLiveInterval)) { |
|
| 155 | + $globalLiveInterval = '200'; |
|
| 156 | + } |
|
| 148 | 157 | if ($globalDBdriver == 'mysql') { |
| 149 | 158 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 150 | 159 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -178,7 +187,9 @@ discard block |
||
| 178 | 187 | |
| 179 | 188 | $filter_query = $this->getFilter($filter,true,true); |
| 180 | 189 | |
| 181 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 190 | + if (!isset($globalLiveInterval)) { |
|
| 191 | + $globalLiveInterval = '200'; |
|
| 192 | + } |
|
| 182 | 193 | if ($globalDBdriver == 'mysql') { |
| 183 | 194 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 184 | 195 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
@@ -211,7 +222,9 @@ discard block |
||
| 211 | 222 | global $globalDBdriver, $globalLiveInterval; |
| 212 | 223 | $filter_query = $this->getFilter($filter,true,true); |
| 213 | 224 | |
| 214 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 225 | + if (!isset($globalLiveInterval)) { |
|
| 226 | + $globalLiveInterval = '200'; |
|
| 227 | + } |
|
| 215 | 228 | if ($globalDBdriver == 'mysql') { |
| 216 | 229 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 217 | 230 | } else { |
@@ -239,7 +252,9 @@ discard block |
||
| 239 | 252 | { |
| 240 | 253 | global $globalDBdriver, $globalLiveInterval; |
| 241 | 254 | $Spotter = new Spotter($this->db); |
| 242 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 255 | + if (!isset($globalLiveInterval)) { |
|
| 256 | + $globalLiveInterval = '200'; |
|
| 257 | + } |
|
| 243 | 258 | $filter_query = $this->getFilter($filter); |
| 244 | 259 | |
| 245 | 260 | if (is_array($coord)) { |
@@ -247,7 +262,9 @@ discard block |
||
| 247 | 262 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 248 | 263 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 249 | 264 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 250 | - } else return array(); |
|
| 265 | + } else { |
|
| 266 | + return array(); |
|
| 267 | + } |
|
| 251 | 268 | if ($globalDBdriver == 'mysql') { |
| 252 | 269 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
| 253 | 270 | } else { |
@@ -267,7 +284,9 @@ discard block |
||
| 267 | 284 | { |
| 268 | 285 | global $globalDBdriver, $globalLiveInterval; |
| 269 | 286 | $Spotter = new Spotter($this->db); |
| 270 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 287 | + if (!isset($globalLiveInterval)) { |
|
| 288 | + $globalLiveInterval = '200'; |
|
| 289 | + } |
|
| 271 | 290 | $filter_query = $this->getFilter($filter); |
| 272 | 291 | |
| 273 | 292 | if (is_array($coord)) { |
@@ -275,7 +294,9 @@ discard block |
||
| 275 | 294 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 276 | 295 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 277 | 296 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 278 | - } else return array(); |
|
| 297 | + } else { |
|
| 298 | + return array(); |
|
| 299 | + } |
|
| 279 | 300 | if ($globalDBdriver == 'mysql') { |
| 280 | 301 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 281 | 302 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -443,11 +464,15 @@ discard block |
||
| 443 | 464 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
| 444 | 465 | if ($globalDBdriver == 'mysql') { |
| 445 | 466 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 446 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 467 | + if ($liveinterval) { |
|
| 468 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 469 | + } |
|
| 447 | 470 | $query .= ' ORDER BY date'; |
| 448 | 471 | } else { |
| 449 | 472 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 450 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 473 | + if ($liveinterval) { |
|
| 474 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 475 | + } |
|
| 451 | 476 | $query .= ' ORDER BY date'; |
| 452 | 477 | } |
| 453 | 478 | |
@@ -542,7 +567,9 @@ discard block |
||
| 542 | 567 | $i++; |
| 543 | 568 | $j++; |
| 544 | 569 | if ($j == 30) { |
| 545 | - if ($globalDebug) echo "."; |
|
| 570 | + if ($globalDebug) { |
|
| 571 | + echo "."; |
|
| 572 | + } |
|
| 546 | 573 | try { |
| 547 | 574 | |
| 548 | 575 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -822,7 +849,9 @@ discard block |
||
| 822 | 849 | { |
| 823 | 850 | return false; |
| 824 | 851 | } |
| 825 | - } else return ''; |
|
| 852 | + } else { |
|
| 853 | + return ''; |
|
| 854 | + } |
|
| 826 | 855 | |
| 827 | 856 | if ($longitude != '') |
| 828 | 857 | { |
@@ -830,7 +859,9 @@ discard block |
||
| 830 | 859 | { |
| 831 | 860 | return false; |
| 832 | 861 | } |
| 833 | - } else return ''; |
|
| 862 | + } else { |
|
| 863 | + return ''; |
|
| 864 | + } |
|
| 834 | 865 | |
| 835 | 866 | |
| 836 | 867 | if ($heading != '') |
@@ -839,7 +870,9 @@ discard block |
||
| 839 | 870 | { |
| 840 | 871 | return false; |
| 841 | 872 | } |
| 842 | - } else $heading = 0; |
|
| 873 | + } else { |
|
| 874 | + $heading = 0; |
|
| 875 | + } |
|
| 843 | 876 | |
| 844 | 877 | if ($groundspeed != '') |
| 845 | 878 | { |
@@ -847,9 +880,13 @@ discard block |
||
| 847 | 880 | { |
| 848 | 881 | return false; |
| 849 | 882 | } |
| 850 | - } else $groundspeed = 0; |
|
| 883 | + } else { |
|
| 884 | + $groundspeed = 0; |
|
| 885 | + } |
|
| 851 | 886 | date_default_timezone_set('UTC'); |
| 852 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 887 | + if ($date == '') { |
|
| 888 | + $date = date("Y-m-d H:i:s", time()); |
|
| 889 | + } |
|
| 853 | 890 | |
| 854 | 891 | |
| 855 | 892 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -870,9 +907,15 @@ discard block |
||
| 870 | 907 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
| 871 | 908 | |
| 872 | 909 | |
| 873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 875 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 910 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 911 | + $groundspeed = 0; |
|
| 912 | + } |
|
| 913 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 914 | + $heading = 0; |
|
| 915 | + } |
|
| 916 | + if ($arrival_date == '') { |
|
| 917 | + $arrival_date = NULL; |
|
| 918 | + } |
|
| 876 | 919 | $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
| 877 | 920 | 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)'; |
| 878 | 921 | |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Get SQL query part for filter used |
|
| 16 | - * @param Array $filter the filter |
|
| 17 | - * @return Array the SQL part |
|
| 18 | - */ |
|
| 15 | + * Get SQL query part for filter used |
|
| 16 | + * @param Array $filter the filter |
|
| 17 | + * @return Array the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * Gets all the spotter information based on the latest data entry |
|
| 90 | - * |
|
| 91 | - * @return Array the spotter information |
|
| 92 | - * |
|
| 93 | - */ |
|
| 89 | + * Gets all the spotter information based on the latest data entry |
|
| 90 | + * |
|
| 91 | + * @return Array the spotter information |
|
| 92 | + * |
|
| 93 | + */ |
|
| 94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
| 95 | 95 | { |
| 96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * Gets Minimal Live Spotter data |
|
| 136 | - * |
|
| 137 | - * @return Array the spotter information |
|
| 138 | - * |
|
| 139 | - */ |
|
| 135 | + * Gets Minimal Live Spotter data |
|
| 136 | + * |
|
| 137 | + * @return Array the spotter information |
|
| 138 | + * |
|
| 139 | + */ |
|
| 140 | 140 | public function getMinLiveTrackerData($filter = array()) |
| 141 | 141 | { |
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 174 | - * |
|
| 175 | - * @return Array the spotter information |
|
| 176 | - * |
|
| 177 | - */ |
|
| 173 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 174 | + * |
|
| 175 | + * @return Array the spotter information |
|
| 176 | + * |
|
| 177 | + */ |
|
| 178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
| 179 | 179 | { |
| 180 | 180 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
| 189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 190 | - } else { |
|
| 190 | + } else { |
|
| 191 | 191 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
| 193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - try { |
|
| 196 | + try { |
|
| 197 | 197 | $sth = $this->db->prepare($query); |
| 198 | 198 | $sth->execute(); |
| 199 | 199 | } catch(PDOException $e) { |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | - * Gets number of latest data entry |
|
| 209 | - * |
|
| 210 | - * @return String number of entry |
|
| 211 | - * |
|
| 212 | - */ |
|
| 208 | + * Gets number of latest data entry |
|
| 209 | + * |
|
| 210 | + * @return String number of entry |
|
| 211 | + * |
|
| 212 | + */ |
|
| 213 | 213 | public function getLiveTrackerCount($filter = array()) |
| 214 | 214 | { |
| 215 | 215 | global $globalDBdriver, $globalLiveInterval; |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 238 | - * |
|
| 239 | - * @return Array the spotter information |
|
| 240 | - * |
|
| 241 | - */ |
|
| 237 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 238 | + * |
|
| 239 | + * @return Array the spotter information |
|
| 240 | + * |
|
| 241 | + */ |
|
| 242 | 242 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
| 243 | 243 | { |
| 244 | 244 | global $globalDBdriver, $globalLiveInterval; |
@@ -262,11 +262,11 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 266 | - * |
|
| 267 | - * @return Array the spotter information |
|
| 268 | - * |
|
| 269 | - */ |
|
| 265 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 266 | + * |
|
| 267 | + * @return Array the spotter information |
|
| 268 | + * |
|
| 269 | + */ |
|
| 270 | 270 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
| 271 | 271 | { |
| 272 | 272 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 297 | - * |
|
| 298 | - * @return Array the spotter information |
|
| 299 | - * |
|
| 300 | - */ |
|
| 296 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 297 | + * |
|
| 298 | + * @return Array the spotter information |
|
| 299 | + * |
|
| 300 | + */ |
|
| 301 | 301 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
| 302 | 302 | { |
| 303 | 303 | $Tracker = new Tracker($this->db); |
@@ -310,142 +310,142 @@ discard block |
||
| 310 | 310 | if ($lng != '') |
| 311 | 311 | { |
| 312 | 312 | if (!is_numeric($lng)) |
| 313 | - { |
|
| 314 | - return false; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - if ($radius != '') |
|
| 319 | - { |
|
| 320 | - if (!is_numeric($radius)) |
|
| 321 | - { |
|
| 322 | - return false; |
|
| 323 | - } |
|
| 324 | - } |
|
| 313 | + { |
|
| 314 | + return false; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + if ($radius != '') |
|
| 319 | + { |
|
| 320 | + if (!is_numeric($radius)) |
|
| 321 | + { |
|
| 322 | + return false; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | 325 | $additional_query = ''; |
| 326 | 326 | if ($interval != '') |
| 327 | - { |
|
| 328 | - if (!is_string($interval)) |
|
| 329 | - { |
|
| 330 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 331 | - return false; |
|
| 332 | - } else { |
|
| 333 | - if ($interval == '1m') |
|
| 334 | - { |
|
| 335 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 336 | - } else if ($interval == '15m'){ |
|
| 337 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - } else { |
|
| 341 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 327 | + { |
|
| 328 | + if (!is_string($interval)) |
|
| 329 | + { |
|
| 330 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 331 | + return false; |
|
| 332 | + } else { |
|
| 333 | + if ($interval == '1m') |
|
| 334 | + { |
|
| 335 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 336 | + } else if ($interval == '15m'){ |
|
| 337 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + } else { |
|
| 341 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 345 | 345 | WHERE tracker_live.latitude <> '' |
| 346 | 346 | AND tracker_live.longitude <> '' |
| 347 | 347 | ".$additional_query." |
| 348 | 348 | HAVING distance < :radius |
| 349 | 349 | ORDER BY distance"; |
| 350 | 350 | |
| 351 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 351 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 352 | 352 | |
| 353 | - return $spotter_array; |
|
| 354 | - } |
|
| 353 | + return $spotter_array; |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * Gets all the spotter information based on a particular callsign |
|
| 359 | - * |
|
| 360 | - * @return Array the spotter information |
|
| 361 | - * |
|
| 362 | - */ |
|
| 357 | + /** |
|
| 358 | + * Gets all the spotter information based on a particular callsign |
|
| 359 | + * |
|
| 360 | + * @return Array the spotter information |
|
| 361 | + * |
|
| 362 | + */ |
|
| 363 | 363 | public function getLastLiveTrackerDataByIdent($ident) |
| 364 | 364 | { |
| 365 | 365 | $Tracker = new Tracker($this->db); |
| 366 | 366 | date_default_timezone_set('UTC'); |
| 367 | 367 | |
| 368 | 368 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 369 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 369 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 370 | 370 | |
| 371 | 371 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 372 | 372 | |
| 373 | 373 | return $spotter_array; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - /** |
|
| 377 | - * Gets all the spotter information based on a particular callsign |
|
| 378 | - * |
|
| 379 | - * @return Array the spotter information |
|
| 380 | - * |
|
| 381 | - */ |
|
| 376 | + /** |
|
| 377 | + * Gets all the spotter information based on a particular callsign |
|
| 378 | + * |
|
| 379 | + * @return Array the spotter information |
|
| 380 | + * |
|
| 381 | + */ |
|
| 382 | 382 | public function getDateLiveTrackerDataByIdent($ident,$date) |
| 383 | 383 | { |
| 384 | 384 | $Tracker = new Tracker($this->db); |
| 385 | 385 | date_default_timezone_set('UTC'); |
| 386 | 386 | |
| 387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 388 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 388 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 389 | 389 | |
| 390 | - $date = date('c',$date); |
|
| 390 | + $date = date('c',$date); |
|
| 391 | 391 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 392 | 392 | |
| 393 | 393 | return $spotter_array; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - /** |
|
| 397 | - * Gets last spotter information based on a particular callsign |
|
| 398 | - * |
|
| 399 | - * @return Array the spotter information |
|
| 400 | - * |
|
| 401 | - */ |
|
| 396 | + /** |
|
| 397 | + * Gets last spotter information based on a particular callsign |
|
| 398 | + * |
|
| 399 | + * @return Array the spotter information |
|
| 400 | + * |
|
| 401 | + */ |
|
| 402 | 402 | public function getLastLiveTrackerDataById($id) |
| 403 | 403 | { |
| 404 | 404 | $Tracker = new Tracker($this->db); |
| 405 | 405 | date_default_timezone_set('UTC'); |
| 406 | 406 | |
| 407 | 407 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 408 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 408 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 409 | 409 | |
| 410 | 410 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
| 411 | 411 | |
| 412 | 412 | return $spotter_array; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - /** |
|
| 416 | - * Gets last spotter information based on a particular callsign |
|
| 417 | - * |
|
| 418 | - * @return Array the spotter information |
|
| 419 | - * |
|
| 420 | - */ |
|
| 415 | + /** |
|
| 416 | + * Gets last spotter information based on a particular callsign |
|
| 417 | + * |
|
| 418 | + * @return Array the spotter information |
|
| 419 | + * |
|
| 420 | + */ |
|
| 421 | 421 | public function getDateLiveTrackerDataById($id,$date) |
| 422 | 422 | { |
| 423 | 423 | $Tracker = new Tracker($this->db); |
| 424 | 424 | date_default_timezone_set('UTC'); |
| 425 | 425 | |
| 426 | 426 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 427 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 428 | - $date = date('c',$date); |
|
| 427 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 428 | + $date = date('c',$date); |
|
| 429 | 429 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 430 | 430 | |
| 431 | 431 | return $spotter_array; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - /** |
|
| 435 | - * Gets altitude information based on a particular callsign |
|
| 436 | - * |
|
| 437 | - * @return Array the spotter information |
|
| 438 | - * |
|
| 439 | - */ |
|
| 434 | + /** |
|
| 435 | + * Gets altitude information based on a particular callsign |
|
| 436 | + * |
|
| 437 | + * @return Array the spotter information |
|
| 438 | + * |
|
| 439 | + */ |
|
| 440 | 440 | public function getAltitudeLiveTrackerDataByIdent($ident) |
| 441 | 441 | { |
| 442 | 442 | |
| 443 | 443 | date_default_timezone_set('UTC'); |
| 444 | 444 | |
| 445 | 445 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 446 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 446 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 447 | 447 | |
| 448 | - try { |
|
| 448 | + try { |
|
| 449 | 449 | |
| 450 | 450 | $sth = $this->db->prepare($query); |
| 451 | 451 | $sth->execute(array(':ident' => $ident)); |
@@ -458,12 +458,12 @@ discard block |
||
| 458 | 458 | return $spotter_array; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - /** |
|
| 462 | - * Gets all the spotter information based on a particular id |
|
| 463 | - * |
|
| 464 | - * @return Array the spotter information |
|
| 465 | - * |
|
| 466 | - */ |
|
| 461 | + /** |
|
| 462 | + * Gets all the spotter information based on a particular id |
|
| 463 | + * |
|
| 464 | + * @return Array the spotter information |
|
| 465 | + * |
|
| 466 | + */ |
|
| 467 | 467 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
| 468 | 468 | { |
| 469 | 469 | global $globalDBdriver, $globalLiveInterval; |
@@ -491,18 +491,18 @@ discard block |
||
| 491 | 491 | return $spotter_array; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - /** |
|
| 495 | - * Gets all the spotter information based on a particular ident |
|
| 496 | - * |
|
| 497 | - * @return Array the spotter information |
|
| 498 | - * |
|
| 499 | - */ |
|
| 494 | + /** |
|
| 495 | + * Gets all the spotter information based on a particular ident |
|
| 496 | + * |
|
| 497 | + * @return Array the spotter information |
|
| 498 | + * |
|
| 499 | + */ |
|
| 500 | 500 | public function getAllLiveTrackerDataByIdent($ident) |
| 501 | 501 | { |
| 502 | 502 | date_default_timezone_set('UTC'); |
| 503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 504 | 504 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
| 505 | - try { |
|
| 505 | + try { |
|
| 506 | 506 | |
| 507 | 507 | $sth = $this->db->prepare($query); |
| 508 | 508 | $sth->execute(array(':ident' => $ident)); |
@@ -516,23 +516,23 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | |
| 518 | 518 | /** |
| 519 | - * Deletes all info in the table |
|
| 520 | - * |
|
| 521 | - * @return String success or false |
|
| 522 | - * |
|
| 523 | - */ |
|
| 519 | + * Deletes all info in the table |
|
| 520 | + * |
|
| 521 | + * @return String success or false |
|
| 522 | + * |
|
| 523 | + */ |
|
| 524 | 524 | public function deleteLiveTrackerData() |
| 525 | 525 | { |
| 526 | 526 | global $globalDBdriver; |
| 527 | 527 | if ($globalDBdriver == 'mysql') { |
| 528 | 528 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
| 529 | 529 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
| 530 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
| 530 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
| 531 | 531 | } else { |
| 532 | 532 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - try { |
|
| 535 | + try { |
|
| 536 | 536 | |
| 537 | 537 | $sth = $this->db->prepare($query); |
| 538 | 538 | $sth->execute(); |
@@ -544,18 +544,18 @@ discard block |
||
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
| 547 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 548 | - * |
|
| 549 | - * @return String success or false |
|
| 550 | - * |
|
| 551 | - */ |
|
| 547 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 548 | + * |
|
| 549 | + * @return String success or false |
|
| 550 | + * |
|
| 551 | + */ |
|
| 552 | 552 | public function deleteLiveTrackerDataNotUpdated() |
| 553 | 553 | { |
| 554 | 554 | global $globalDBdriver, $globalDebug; |
| 555 | 555 | if ($globalDBdriver == 'mysql') { |
| 556 | 556 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
| 557 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 558 | - try { |
|
| 557 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 558 | + try { |
|
| 559 | 559 | |
| 560 | 560 | $sth = $this->db->prepare($query); |
| 561 | 561 | $sth->execute(); |
@@ -563,8 +563,8 @@ discard block |
||
| 563 | 563 | return "error"; |
| 564 | 564 | } |
| 565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 566 | - $i = 0; |
|
| 567 | - $j =0; |
|
| 566 | + $i = 0; |
|
| 567 | + $j =0; |
|
| 568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 569 | 569 | foreach($all as $row) |
| 570 | 570 | { |
@@ -572,20 +572,20 @@ discard block |
||
| 572 | 572 | $j++; |
| 573 | 573 | if ($j == 30) { |
| 574 | 574 | if ($globalDebug) echo "."; |
| 575 | - try { |
|
| 575 | + try { |
|
| 576 | 576 | |
| 577 | 577 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 578 | 578 | $sth->execute(); |
| 579 | 579 | } catch(PDOException $e) { |
| 580 | 580 | return "error"; |
| 581 | 581 | } |
| 582 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 583 | - $j = 0; |
|
| 582 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 583 | + $j = 0; |
|
| 584 | 584 | } |
| 585 | 585 | $query_delete .= "'".$row['famtrackid']."',"; |
| 586 | 586 | } |
| 587 | 587 | if ($i > 0) { |
| 588 | - try { |
|
| 588 | + try { |
|
| 589 | 589 | |
| 590 | 590 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 591 | 591 | $sth->execute(); |
@@ -596,9 +596,9 @@ discard block |
||
| 596 | 596 | return "success"; |
| 597 | 597 | } elseif ($globalDBdriver == 'pgsql') { |
| 598 | 598 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
| 599 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 600 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 601 | - try { |
|
| 599 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 600 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 601 | + try { |
|
| 602 | 602 | |
| 603 | 603 | $sth = $this->db->prepare($query); |
| 604 | 604 | $sth->execute(); |
@@ -642,17 +642,17 @@ discard block |
||
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
| 645 | - * Deletes all info in the table for an ident |
|
| 646 | - * |
|
| 647 | - * @return String success or false |
|
| 648 | - * |
|
| 649 | - */ |
|
| 645 | + * Deletes all info in the table for an ident |
|
| 646 | + * |
|
| 647 | + * @return String success or false |
|
| 648 | + * |
|
| 649 | + */ |
|
| 650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
| 651 | 651 | { |
| 652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 653 | 653 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
| 654 | 654 | |
| 655 | - try { |
|
| 655 | + try { |
|
| 656 | 656 | |
| 657 | 657 | $sth = $this->db->prepare($query); |
| 658 | 658 | $sth->execute(array(':ident' => $ident)); |
@@ -664,17 +664,17 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | /** |
| 667 | - * Deletes all info in the table for an id |
|
| 668 | - * |
|
| 669 | - * @return String success or false |
|
| 670 | - * |
|
| 671 | - */ |
|
| 667 | + * Deletes all info in the table for an id |
|
| 668 | + * |
|
| 669 | + * @return String success or false |
|
| 670 | + * |
|
| 671 | + */ |
|
| 672 | 672 | public function deleteLiveTrackerDataById($id) |
| 673 | 673 | { |
| 674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 675 | 675 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
| 676 | 676 | |
| 677 | - try { |
|
| 677 | + try { |
|
| 678 | 678 | |
| 679 | 679 | $sth = $this->db->prepare($query); |
| 680 | 680 | $sth->execute(array(':id' => $id)); |
@@ -687,11 +687,11 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | |
| 689 | 689 | /** |
| 690 | - * Gets the aircraft ident within the last hour |
|
| 691 | - * |
|
| 692 | - * @return String the ident |
|
| 693 | - * |
|
| 694 | - */ |
|
| 690 | + * Gets the aircraft ident within the last hour |
|
| 691 | + * |
|
| 692 | + * @return String the ident |
|
| 693 | + * |
|
| 694 | + */ |
|
| 695 | 695 | public function getIdentFromLastHour($ident) |
| 696 | 696 | { |
| 697 | 697 | global $globalDBdriver, $globalTimezone; |
@@ -717,14 +717,14 @@ discard block |
||
| 717 | 717 | $ident_result = $row['ident']; |
| 718 | 718 | } |
| 719 | 719 | return $ident_result; |
| 720 | - } |
|
| 720 | + } |
|
| 721 | 721 | |
| 722 | 722 | /** |
| 723 | - * Check recent aircraft |
|
| 724 | - * |
|
| 725 | - * @return String the ident |
|
| 726 | - * |
|
| 727 | - */ |
|
| 723 | + * Check recent aircraft |
|
| 724 | + * |
|
| 725 | + * @return String the ident |
|
| 726 | + * |
|
| 727 | + */ |
|
| 728 | 728 | public function checkIdentRecent($ident) |
| 729 | 729 | { |
| 730 | 730 | global $globalDBdriver, $globalTimezone; |
@@ -750,14 +750,14 @@ discard block |
||
| 750 | 750 | $ident_result = $row['famtrackid']; |
| 751 | 751 | } |
| 752 | 752 | return $ident_result; |
| 753 | - } |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | 755 | /** |
| 756 | - * Check recent aircraft by id |
|
| 757 | - * |
|
| 758 | - * @return String the ident |
|
| 759 | - * |
|
| 760 | - */ |
|
| 756 | + * Check recent aircraft by id |
|
| 757 | + * |
|
| 758 | + * @return String the ident |
|
| 759 | + * |
|
| 760 | + */ |
|
| 761 | 761 | public function checkIdRecent($id) |
| 762 | 762 | { |
| 763 | 763 | global $globalDBdriver, $globalTimezone; |
@@ -783,19 +783,19 @@ discard block |
||
| 783 | 783 | $ident_result = $row['famtrackid']; |
| 784 | 784 | } |
| 785 | 785 | return $ident_result; |
| 786 | - } |
|
| 786 | + } |
|
| 787 | 787 | |
| 788 | 788 | /** |
| 789 | - * Adds a new spotter data |
|
| 790 | - * |
|
| 791 | - * @param String $famtrackid the ID from flightaware |
|
| 792 | - * @param String $ident the flight ident |
|
| 793 | - * @param String $aircraft_icao the aircraft type |
|
| 794 | - * @param String $departure_airport_icao the departure airport |
|
| 795 | - * @param String $arrival_airport_icao the arrival airport |
|
| 796 | - * @return String success or false |
|
| 797 | - * |
|
| 798 | - */ |
|
| 789 | + * Adds a new spotter data |
|
| 790 | + * |
|
| 791 | + * @param String $famtrackid the ID from flightaware |
|
| 792 | + * @param String $ident the flight ident |
|
| 793 | + * @param String $aircraft_icao the aircraft type |
|
| 794 | + * @param String $departure_airport_icao the departure airport |
|
| 795 | + * @param String $arrival_airport_icao the arrival airport |
|
| 796 | + * @return String success or false |
|
| 797 | + * |
|
| 798 | + */ |
|
| 799 | 799 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 800 | 800 | { |
| 801 | 801 | global $globalURL, $globalArchive, $globalDebug; |
@@ -868,8 +868,8 @@ discard block |
||
| 868 | 868 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 869 | 869 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 870 | 870 | |
| 871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 872 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 873 | 873 | |
| 874 | 874 | $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 875 | 875 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -879,9 +879,9 @@ discard block |
||
| 879 | 879 | |
| 880 | 880 | $sth = $this->db->prepare($query); |
| 881 | 881 | $sth->execute($query_values); |
| 882 | - } catch(PDOException $e) { |
|
| 883 | - return "error : ".$e->getMessage(); |
|
| 884 | - } |
|
| 882 | + } catch(PDOException $e) { |
|
| 883 | + return "error : ".$e->getMessage(); |
|
| 884 | + } |
|
| 885 | 885 | /* |
| 886 | 886 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 887 | 887 | if ($globalDebug) echo '(Add to SBS archive : '; |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 75 | 75 | } |
| 76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 78 | 78 | } |
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 81 | 81 | if ($filter_query_where != '') { |
| 82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 83 | 83 | } |
| 84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
| 85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | if ($limit != '') |
| 103 | 103 | { |
| 104 | 104 | $limit_array = explode(',', $limit); |
| 105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 108 | 108 | { |
| 109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } else { |
| 127 | 127 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
| 128 | 128 | } |
| 129 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 129 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 130 | 130 | |
| 131 | 131 | return $spotter_array; |
| 132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
| 143 | 143 | date_default_timezone_set('UTC'); |
| 144 | 144 | |
| 145 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 145 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 146 | 146 | |
| 147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | try { |
| 161 | 161 | $sth = $this->db->prepare($query); |
| 162 | 162 | $sth->execute(); |
| 163 | - } catch(PDOException $e) { |
|
| 163 | + } catch (PDOException $e) { |
|
| 164 | 164 | echo $e->getMessage(); |
| 165 | 165 | die; |
| 166 | 166 | } |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | global $globalDBdriver, $globalLiveInterval; |
| 181 | 181 | date_default_timezone_set('UTC'); |
| 182 | 182 | |
| 183 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 183 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 184 | 184 | |
| 185 | 185 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 186 | 186 | if ($globalDBdriver == 'mysql') { |
| 187 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 187 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
| 189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 190 | 190 | } else { |
| 191 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 191 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
| 193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 194 | 194 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | try { |
| 197 | 197 | $sth = $this->db->prepare($query); |
| 198 | 198 | $sth->execute(); |
| 199 | - } catch(PDOException $e) { |
|
| 199 | + } catch (PDOException $e) { |
|
| 200 | 200 | echo $e->getMessage(); |
| 201 | 201 | die; |
| 202 | 202 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | public function getLiveTrackerCount($filter = array()) |
| 214 | 214 | { |
| 215 | 215 | global $globalDBdriver, $globalLiveInterval; |
| 216 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 216 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 217 | 217 | |
| 218 | 218 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 219 | 219 | if ($globalDBdriver == 'mysql') { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | try { |
| 225 | 225 | $sth = $this->db->prepare($query); |
| 226 | 226 | $sth->execute(); |
| 227 | - } catch(PDOException $e) { |
|
| 227 | + } catch (PDOException $e) { |
|
| 228 | 228 | echo $e->getMessage(); |
| 229 | 229 | die; |
| 230 | 230 | } |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | $filter_query = $this->getFilter($filter); |
| 248 | 248 | |
| 249 | 249 | if (is_array($coord)) { |
| 250 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 251 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 252 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 253 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 251 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 252 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 253 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 254 | 254 | } else return array(); |
| 255 | 255 | if ($globalDBdriver == 'mysql') { |
| 256 | 256 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -275,17 +275,17 @@ discard block |
||
| 275 | 275 | $filter_query = $this->getFilter($filter); |
| 276 | 276 | |
| 277 | 277 | if (is_array($coord)) { |
| 278 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 279 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 280 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 281 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 278 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 279 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 280 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 281 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 282 | 282 | } else return array(); |
| 283 | 283 | if ($globalDBdriver == 'mysql') { |
| 284 | 284 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 285 | 285 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
| 286 | 286 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 287 | 287 | } else { |
| 288 | - $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 288 | + $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 289 | 289 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'"; |
| 290 | 290 | } |
| 291 | 291 | $spotter_array = $Spotter->getDataFromDB($query); |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | if ($interval == '1m') |
| 334 | 334 | { |
| 335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 336 | - } else if ($interval == '15m'){ |
|
| 336 | + } else if ($interval == '15m') { |
|
| 337 | 337 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 344 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 345 | 345 | WHERE tracker_live.latitude <> '' |
| 346 | 346 | AND tracker_live.longitude <> '' |
| 347 | 347 | ".$additional_query." |
| 348 | 348 | HAVING distance < :radius |
| 349 | 349 | ORDER BY distance"; |
| 350 | 350 | |
| 351 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 351 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 352 | 352 | |
| 353 | 353 | return $spotter_array; |
| 354 | 354 | } |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | date_default_timezone_set('UTC'); |
| 367 | 367 | |
| 368 | 368 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 369 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 369 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 370 | 370 | |
| 371 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 371 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 372 | 372 | |
| 373 | 373 | return $spotter_array; |
| 374 | 374 | } |
@@ -379,16 +379,16 @@ discard block |
||
| 379 | 379 | * @return Array the spotter information |
| 380 | 380 | * |
| 381 | 381 | */ |
| 382 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
| 382 | + public function getDateLiveTrackerDataByIdent($ident, $date) |
|
| 383 | 383 | { |
| 384 | 384 | $Tracker = new Tracker($this->db); |
| 385 | 385 | date_default_timezone_set('UTC'); |
| 386 | 386 | |
| 387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 388 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 388 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 389 | 389 | |
| 390 | - $date = date('c',$date); |
|
| 391 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 390 | + $date = date('c', $date); |
|
| 391 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 392 | 392 | |
| 393 | 393 | return $spotter_array; |
| 394 | 394 | } |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | date_default_timezone_set('UTC'); |
| 406 | 406 | |
| 407 | 407 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 408 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 408 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 409 | 409 | |
| 410 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 410 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 411 | 411 | |
| 412 | 412 | return $spotter_array; |
| 413 | 413 | } |
@@ -418,15 +418,15 @@ discard block |
||
| 418 | 418 | * @return Array the spotter information |
| 419 | 419 | * |
| 420 | 420 | */ |
| 421 | - public function getDateLiveTrackerDataById($id,$date) |
|
| 421 | + public function getDateLiveTrackerDataById($id, $date) |
|
| 422 | 422 | { |
| 423 | 423 | $Tracker = new Tracker($this->db); |
| 424 | 424 | date_default_timezone_set('UTC'); |
| 425 | 425 | |
| 426 | 426 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 427 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 428 | - $date = date('c',$date); |
|
| 429 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 427 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 428 | + $date = date('c', $date); |
|
| 429 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 430 | 430 | |
| 431 | 431 | return $spotter_array; |
| 432 | 432 | } |
@@ -443,13 +443,13 @@ discard block |
||
| 443 | 443 | date_default_timezone_set('UTC'); |
| 444 | 444 | |
| 445 | 445 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 446 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 446 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 447 | 447 | |
| 448 | 448 | try { |
| 449 | 449 | |
| 450 | 450 | $sth = $this->db->prepare($query); |
| 451 | 451 | $sth->execute(array(':ident' => $ident)); |
| 452 | - } catch(PDOException $e) { |
|
| 452 | + } catch (PDOException $e) { |
|
| 453 | 453 | echo $e->getMessage(); |
| 454 | 454 | die; |
| 455 | 455 | } |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * @return Array the spotter information |
| 465 | 465 | * |
| 466 | 466 | */ |
| 467 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
| 467 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
| 468 | 468 | { |
| 469 | 469 | global $globalDBdriver, $globalLiveInterval; |
| 470 | 470 | date_default_timezone_set('UTC'); |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | try { |
| 484 | 484 | $sth = $this->db->prepare($query); |
| 485 | 485 | $sth->execute(array(':id' => $id)); |
| 486 | - } catch(PDOException $e) { |
|
| 486 | + } catch (PDOException $e) { |
|
| 487 | 487 | echo $e->getMessage(); |
| 488 | 488 | die; |
| 489 | 489 | } |
@@ -501,12 +501,12 @@ discard block |
||
| 501 | 501 | { |
| 502 | 502 | date_default_timezone_set('UTC'); |
| 503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 504 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 504 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 505 | 505 | try { |
| 506 | 506 | |
| 507 | 507 | $sth = $this->db->prepare($query); |
| 508 | 508 | $sth->execute(array(':ident' => $ident)); |
| 509 | - } catch(PDOException $e) { |
|
| 509 | + } catch (PDOException $e) { |
|
| 510 | 510 | echo $e->getMessage(); |
| 511 | 511 | die; |
| 512 | 512 | } |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | $sth = $this->db->prepare($query); |
| 538 | 538 | $sth->execute(); |
| 539 | - } catch(PDOException $e) { |
|
| 539 | + } catch (PDOException $e) { |
|
| 540 | 540 | return "error"; |
| 541 | 541 | } |
| 542 | 542 | |
@@ -559,14 +559,14 @@ discard block |
||
| 559 | 559 | |
| 560 | 560 | $sth = $this->db->prepare($query); |
| 561 | 561 | $sth->execute(); |
| 562 | - } catch(PDOException $e) { |
|
| 562 | + } catch (PDOException $e) { |
|
| 563 | 563 | return "error"; |
| 564 | 564 | } |
| 565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 566 | 566 | $i = 0; |
| 567 | - $j =0; |
|
| 567 | + $j = 0; |
|
| 568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 569 | - foreach($all as $row) |
|
| 569 | + foreach ($all as $row) |
|
| 570 | 570 | { |
| 571 | 571 | $i++; |
| 572 | 572 | $j++; |
@@ -574,9 +574,9 @@ discard block |
||
| 574 | 574 | if ($globalDebug) echo "."; |
| 575 | 575 | try { |
| 576 | 576 | |
| 577 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 577 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 578 | 578 | $sth->execute(); |
| 579 | - } catch(PDOException $e) { |
|
| 579 | + } catch (PDOException $e) { |
|
| 580 | 580 | return "error"; |
| 581 | 581 | } |
| 582 | 582 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -587,9 +587,9 @@ discard block |
||
| 587 | 587 | if ($i > 0) { |
| 588 | 588 | try { |
| 589 | 589 | |
| 590 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 590 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 591 | 591 | $sth->execute(); |
| 592 | - } catch(PDOException $e) { |
|
| 592 | + } catch (PDOException $e) { |
|
| 593 | 593 | return "error"; |
| 594 | 594 | } |
| 595 | 595 | } |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | $sth = $this->db->prepare($query); |
| 604 | 604 | $sth->execute(); |
| 605 | - } catch(PDOException $e) { |
|
| 605 | + } catch (PDOException $e) { |
|
| 606 | 606 | return "error"; |
| 607 | 607 | } |
| 608 | 608 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -650,13 +650,13 @@ discard block |
||
| 650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
| 651 | 651 | { |
| 652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 653 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 653 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 654 | 654 | |
| 655 | 655 | try { |
| 656 | 656 | |
| 657 | 657 | $sth = $this->db->prepare($query); |
| 658 | 658 | $sth->execute(array(':ident' => $ident)); |
| 659 | - } catch(PDOException $e) { |
|
| 659 | + } catch (PDOException $e) { |
|
| 660 | 660 | return "error"; |
| 661 | 661 | } |
| 662 | 662 | |
@@ -672,13 +672,13 @@ discard block |
||
| 672 | 672 | public function deleteLiveTrackerDataById($id) |
| 673 | 673 | { |
| 674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 675 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 675 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 676 | 676 | |
| 677 | 677 | try { |
| 678 | 678 | |
| 679 | 679 | $sth = $this->db->prepare($query); |
| 680 | 680 | $sth->execute(array(':id' => $id)); |
| 681 | - } catch(PDOException $e) { |
|
| 681 | + } catch (PDOException $e) { |
|
| 682 | 682 | return "error"; |
| 683 | 683 | } |
| 684 | 684 | |
@@ -696,13 +696,13 @@ discard block |
||
| 696 | 696 | { |
| 697 | 697 | global $globalDBdriver, $globalTimezone; |
| 698 | 698 | if ($globalDBdriver == 'mysql') { |
| 699 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 699 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 700 | 700 | WHERE tracker_live.ident = :ident |
| 701 | 701 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 702 | 702 | AND tracker_live.date < UTC_TIMESTAMP()'; |
| 703 | 703 | $query_data = array(':ident' => $ident); |
| 704 | 704 | } else { |
| 705 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 705 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 706 | 706 | WHERE tracker_live.ident = :ident |
| 707 | 707 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 708 | 708 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -711,8 +711,8 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | $sth = $this->db->prepare($query); |
| 713 | 713 | $sth->execute($query_data); |
| 714 | - $ident_result=''; |
|
| 715 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 714 | + $ident_result = ''; |
|
| 715 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 716 | 716 | { |
| 717 | 717 | $ident_result = $row['ident']; |
| 718 | 718 | } |
@@ -729,13 +729,13 @@ discard block |
||
| 729 | 729 | { |
| 730 | 730 | global $globalDBdriver, $globalTimezone; |
| 731 | 731 | if ($globalDBdriver == 'mysql') { |
| 732 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 732 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 733 | 733 | WHERE tracker_live.ident = :ident |
| 734 | 734 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 735 | 735 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 736 | 736 | $query_data = array(':ident' => $ident); |
| 737 | 737 | } else { |
| 738 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 738 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 739 | 739 | WHERE tracker_live.ident = :ident |
| 740 | 740 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 741 | 741 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -744,8 +744,8 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | $sth = $this->db->prepare($query); |
| 746 | 746 | $sth->execute($query_data); |
| 747 | - $ident_result=''; |
|
| 748 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 747 | + $ident_result = ''; |
|
| 748 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 749 | 749 | { |
| 750 | 750 | $ident_result = $row['famtrackid']; |
| 751 | 751 | } |
@@ -762,13 +762,13 @@ discard block |
||
| 762 | 762 | { |
| 763 | 763 | global $globalDBdriver, $globalTimezone; |
| 764 | 764 | if ($globalDBdriver == 'mysql') { |
| 765 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 765 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 766 | 766 | WHERE tracker_live.famtrackid = :id |
| 767 | 767 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 768 | 768 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 769 | 769 | $query_data = array(':id' => $id); |
| 770 | 770 | } else { |
| 771 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 771 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 772 | 772 | WHERE tracker_live.famtrackid = :id |
| 773 | 773 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 774 | 774 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | $sth = $this->db->prepare($query); |
| 779 | 779 | $sth->execute($query_data); |
| 780 | - $ident_result=''; |
|
| 781 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 780 | + $ident_result = ''; |
|
| 781 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 782 | 782 | { |
| 783 | 783 | $ident_result = $row['famtrackid']; |
| 784 | 784 | } |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | * @return String success or false |
| 797 | 797 | * |
| 798 | 798 | */ |
| 799 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 799 | + public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 800 | 800 | { |
| 801 | 801 | global $globalURL, $globalArchive, $globalDebug; |
| 802 | 802 | $Common = new Common(); |
@@ -855,31 +855,31 @@ discard block |
||
| 855 | 855 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 856 | 856 | |
| 857 | 857 | |
| 858 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 859 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 860 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 861 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 862 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 863 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 865 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 866 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 867 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 868 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
| 869 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 870 | - |
|
| 871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 858 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 859 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 860 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 861 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 862 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 863 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 865 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 866 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 867 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 868 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
| 869 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 870 | + |
|
| 871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 872 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 873 | 873 | |
| 874 | - $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 874 | + $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 875 | 875 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 876 | 876 | |
| 877 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
| 877 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
| 878 | 878 | try { |
| 879 | 879 | |
| 880 | 880 | $sth = $this->db->prepare($query); |
| 881 | 881 | $sth->execute($query_values); |
| 882 | - } catch(PDOException $e) { |
|
| 882 | + } catch (PDOException $e) { |
|
| 883 | 883 | return "error : ".$e->getMessage(); |
| 884 | 884 | } |
| 885 | 885 | /* |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | |
| 897 | 897 | public function getOrderBy() |
| 898 | 898 | { |
| 899 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
| 899 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
| 900 | 900 | return $orderby; |
| 901 | 901 | } |
| 902 | 902 | |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
| 76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 78 | 80 | } |
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 81 | + if ($filter_query_where == '' && $where) { |
|
| 82 | + $filter_query_where = ' WHERE'; |
|
| 83 | + } elseif ($filter_query_where != '' && $and) { |
|
| 84 | + $filter_query_where .= ' AND'; |
|
| 85 | + } |
|
| 81 | 86 | if ($filter_query_where != '') { |
| 82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 83 | 88 | } |
@@ -119,7 +124,9 @@ discard block |
||
| 119 | 124 | } |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 127 | + if (!isset($globalLiveInterval)) { |
|
| 128 | + $globalLiveInterval = '200'; |
|
| 129 | + } |
|
| 123 | 130 | if ($globalDBdriver == 'mysql') { |
| 124 | 131 | //$query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate"; |
| 125 | 132 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
| 144 | 151 | |
| 145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
| 146 | 153 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 154 | + if (!isset($globalLiveInterval)) { |
|
| 155 | + $globalLiveInterval = '200'; |
|
| 156 | + } |
|
| 148 | 157 | if ($globalDBdriver == 'mysql') { |
| 149 | 158 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 150 | 159 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0"; |
@@ -182,7 +191,9 @@ discard block |
||
| 182 | 191 | |
| 183 | 192 | $filter_query = $this->getFilter($filter,true,true); |
| 184 | 193 | |
| 185 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 194 | + if (!isset($globalLiveInterval)) { |
|
| 195 | + $globalLiveInterval = '200'; |
|
| 196 | + } |
|
| 186 | 197 | if ($globalDBdriver == 'mysql') { |
| 187 | 198 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 188 | 199 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
@@ -215,7 +226,9 @@ discard block |
||
| 215 | 226 | global $globalDBdriver, $globalLiveInterval; |
| 216 | 227 | $filter_query = $this->getFilter($filter,true,true); |
| 217 | 228 | |
| 218 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 229 | + if (!isset($globalLiveInterval)) { |
|
| 230 | + $globalLiveInterval = '200'; |
|
| 231 | + } |
|
| 219 | 232 | if ($globalDBdriver == 'mysql') { |
| 220 | 233 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 221 | 234 | } else { |
@@ -243,7 +256,9 @@ discard block |
||
| 243 | 256 | { |
| 244 | 257 | global $globalDBdriver, $globalLiveInterval; |
| 245 | 258 | $Spotter = new Spotter($this->db); |
| 246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 259 | + if (!isset($globalLiveInterval)) { |
|
| 260 | + $globalLiveInterval = '200'; |
|
| 261 | + } |
|
| 247 | 262 | $filter_query = $this->getFilter($filter); |
| 248 | 263 | |
| 249 | 264 | if (is_array($coord)) { |
@@ -251,7 +266,9 @@ discard block |
||
| 251 | 266 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 252 | 267 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 253 | 268 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 254 | - } else return array(); |
|
| 269 | + } else { |
|
| 270 | + return array(); |
|
| 271 | + } |
|
| 255 | 272 | if ($globalDBdriver == 'mysql') { |
| 256 | 273 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
| 257 | 274 | } else { |
@@ -271,7 +288,9 @@ discard block |
||
| 271 | 288 | { |
| 272 | 289 | global $globalDBdriver, $globalLiveInterval; |
| 273 | 290 | $Spotter = new Spotter($this->db); |
| 274 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 291 | + if (!isset($globalLiveInterval)) { |
|
| 292 | + $globalLiveInterval = '200'; |
|
| 293 | + } |
|
| 275 | 294 | $filter_query = $this->getFilter($filter); |
| 276 | 295 | |
| 277 | 296 | if (is_array($coord)) { |
@@ -279,7 +298,9 @@ discard block |
||
| 279 | 298 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 280 | 299 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 281 | 300 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 282 | - } else return array(); |
|
| 301 | + } else { |
|
| 302 | + return array(); |
|
| 303 | + } |
|
| 283 | 304 | if ($globalDBdriver == 'mysql') { |
| 284 | 305 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 285 | 306 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -472,11 +493,15 @@ discard block |
||
| 472 | 493 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date'; |
| 473 | 494 | if ($globalDBdriver == 'mysql') { |
| 474 | 495 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 475 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 496 | + if ($liveinterval) { |
|
| 497 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 498 | + } |
|
| 476 | 499 | $query .= ' ORDER BY date'; |
| 477 | 500 | } else { |
| 478 | 501 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 479 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 502 | + if ($liveinterval) { |
|
| 503 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 504 | + } |
|
| 480 | 505 | $query .= ' ORDER BY date'; |
| 481 | 506 | } |
| 482 | 507 | |
@@ -571,7 +596,9 @@ discard block |
||
| 571 | 596 | $i++; |
| 572 | 597 | $j++; |
| 573 | 598 | if ($j == 30) { |
| 574 | - if ($globalDebug) echo "."; |
|
| 599 | + if ($globalDebug) { |
|
| 600 | + echo "."; |
|
| 601 | + } |
|
| 575 | 602 | try { |
| 576 | 603 | |
| 577 | 604 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -818,7 +845,9 @@ discard block |
||
| 818 | 845 | { |
| 819 | 846 | return false; |
| 820 | 847 | } |
| 821 | - } else return ''; |
|
| 848 | + } else { |
|
| 849 | + return ''; |
|
| 850 | + } |
|
| 822 | 851 | |
| 823 | 852 | if ($longitude != '') |
| 824 | 853 | { |
@@ -826,7 +855,9 @@ discard block |
||
| 826 | 855 | { |
| 827 | 856 | return false; |
| 828 | 857 | } |
| 829 | - } else return ''; |
|
| 858 | + } else { |
|
| 859 | + return ''; |
|
| 860 | + } |
|
| 830 | 861 | |
| 831 | 862 | if ($altitude != '') |
| 832 | 863 | { |
@@ -834,7 +865,9 @@ discard block |
||
| 834 | 865 | { |
| 835 | 866 | return false; |
| 836 | 867 | } |
| 837 | - } else $altitude = 0; |
|
| 868 | + } else { |
|
| 869 | + $altitude = 0; |
|
| 870 | + } |
|
| 838 | 871 | |
| 839 | 872 | if ($heading != '') |
| 840 | 873 | { |
@@ -842,7 +875,9 @@ discard block |
||
| 842 | 875 | { |
| 843 | 876 | return false; |
| 844 | 877 | } |
| 845 | - } else $heading = 0; |
|
| 878 | + } else { |
|
| 879 | + $heading = 0; |
|
| 880 | + } |
|
| 846 | 881 | |
| 847 | 882 | if ($groundspeed != '') |
| 848 | 883 | { |
@@ -850,9 +885,13 @@ discard block |
||
| 850 | 885 | { |
| 851 | 886 | return false; |
| 852 | 887 | } |
| 853 | - } else $groundspeed = 0; |
|
| 888 | + } else { |
|
| 889 | + $groundspeed = 0; |
|
| 890 | + } |
|
| 854 | 891 | date_default_timezone_set('UTC'); |
| 855 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 892 | + if ($date == '') { |
|
| 893 | + $date = date("Y-m-d H:i:s", time()); |
|
| 894 | + } |
|
| 856 | 895 | |
| 857 | 896 | |
| 858 | 897 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -868,8 +907,12 @@ discard block |
||
| 868 | 907 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 869 | 908 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 870 | 909 | |
| 871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 910 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 911 | + $groundspeed = 0; |
|
| 912 | + } |
|
| 913 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 914 | + $heading = 0; |
|
| 915 | + } |
|
| 873 | 916 | |
| 874 | 917 | $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 875 | 918 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -11,10 +11,10 @@ discard block |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * Get SQL query part for filter used |
|
| 15 | - * @param Array $filter the filter |
|
| 16 | - * @return Array the SQL part |
|
| 17 | - */ |
|
| 14 | + * Get SQL query part for filter used |
|
| 15 | + * @param Array $filter the filter |
|
| 16 | + * @return Array the SQL part |
|
| 17 | + */ |
|
| 18 | 18 | |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * Executes the SQL statements to get the spotter information |
|
| 82 | - * |
|
| 83 | - * @param String $query the SQL query |
|
| 84 | - * @param Array $params parameter of the query |
|
| 85 | - * @param String $limitQuery the limit query |
|
| 86 | - * @return Array the spotter information |
|
| 87 | - * |
|
| 88 | - */ |
|
| 81 | + * Executes the SQL statements to get the spotter information |
|
| 82 | + * |
|
| 83 | + * @param String $query the SQL query |
|
| 84 | + * @param Array $params parameter of the query |
|
| 85 | + * @param String $limitQuery the limit query |
|
| 86 | + * @return Array the spotter information |
|
| 87 | + * |
|
| 88 | + */ |
|
| 89 | 89 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
| 90 | 90 | { |
| 91 | 91 | date_default_timezone_set('UTC'); |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | - * Gets all the spotter information based on the latest data entry |
|
| 216 | - * |
|
| 217 | - * @return Array the spotter information |
|
| 218 | - * |
|
| 219 | - */ |
|
| 215 | + * Gets all the spotter information based on the latest data entry |
|
| 216 | + * |
|
| 217 | + * @return Array the spotter information |
|
| 218 | + * |
|
| 219 | + */ |
|
| 220 | 220 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
| 221 | 221 | { |
| 222 | 222 | global $global_query; |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | - * Gets all the spotter information based on the callsign |
|
| 278 | - * |
|
| 279 | - * @return Array the spotter information |
|
| 280 | - * |
|
| 281 | - */ |
|
| 277 | + * Gets all the spotter information based on the callsign |
|
| 278 | + * |
|
| 279 | + * @return Array the spotter information |
|
| 280 | + * |
|
| 281 | + */ |
|
| 282 | 282 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
| 283 | 283 | { |
| 284 | 284 | global $global_query; |
@@ -389,12 +389,12 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | - * Gets all source name |
|
| 393 | - * |
|
| 394 | - * @param String type format of source |
|
| 395 | - * @return Array list of source name |
|
| 396 | - * |
|
| 397 | - */ |
|
| 392 | + * Gets all source name |
|
| 393 | + * |
|
| 394 | + * @param String type format of source |
|
| 395 | + * @return Array list of source name |
|
| 396 | + * |
|
| 397 | + */ |
|
| 398 | 398 | public function getAllSourceName($type = '',$filters = array()) |
| 399 | 399 | { |
| 400 | 400 | $filter_query = $this->getFilter($filters,true,true); |
@@ -424,11 +424,11 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | - * Gets a list of all idents/callsigns |
|
| 428 | - * |
|
| 429 | - * @return Array list of ident/callsign names |
|
| 430 | - * |
|
| 431 | - */ |
|
| 427 | + * Gets a list of all idents/callsigns |
|
| 428 | + * |
|
| 429 | + * @return Array list of ident/callsign names |
|
| 430 | + * |
|
| 431 | + */ |
|
| 432 | 432 | public function getAllIdents($filters = array()) |
| 433 | 433 | { |
| 434 | 434 | $filter_query = $this->getFilter($filters,true,true); |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
| 455 | - * Gets all info from a mmsi |
|
| 456 | - * |
|
| 457 | - * @return Array list of mmsi info |
|
| 458 | - * |
|
| 459 | - */ |
|
| 455 | + * Gets all info from a mmsi |
|
| 456 | + * |
|
| 457 | + * @return Array list of mmsi info |
|
| 458 | + * |
|
| 459 | + */ |
|
| 460 | 460 | public function getIdentity($mmsi) |
| 461 | 461 | { |
| 462 | 462 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -513,18 +513,18 @@ discard block |
||
| 513 | 513 | |
| 514 | 514 | |
| 515 | 515 | /** |
| 516 | - * Update ident tracker data |
|
| 517 | - * |
|
| 518 | - * @param String $fammarine_id the ID |
|
| 519 | - * @param String $ident the marine ident |
|
| 520 | - * @return String success or false |
|
| 521 | - * |
|
| 522 | - */ |
|
| 516 | + * Update ident tracker data |
|
| 517 | + * |
|
| 518 | + * @param String $fammarine_id the ID |
|
| 519 | + * @param String $ident the marine ident |
|
| 520 | + * @return String success or false |
|
| 521 | + * |
|
| 522 | + */ |
|
| 523 | 523 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
| 524 | 524 | { |
| 525 | 525 | |
| 526 | 526 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 527 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 527 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 528 | 528 | |
| 529 | 529 | try { |
| 530 | 530 | $sth = $this->db->prepare($query); |
@@ -537,17 +537,17 @@ discard block |
||
| 537 | 537 | |
| 538 | 538 | } |
| 539 | 539 | /** |
| 540 | - * Update latest marine data |
|
| 541 | - * |
|
| 542 | - * @param String $fammarine_id the ID |
|
| 543 | - * @param String $ident the marine ident |
|
| 544 | - * @return String success or false |
|
| 545 | - * |
|
| 546 | - */ |
|
| 540 | + * Update latest marine data |
|
| 541 | + * |
|
| 542 | + * @param String $fammarine_id the ID |
|
| 543 | + * @param String $ident the marine ident |
|
| 544 | + * @return String success or false |
|
| 545 | + * |
|
| 546 | + */ |
|
| 547 | 547 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 548 | 548 | { |
| 549 | 549 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 550 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 550 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 551 | 551 | |
| 552 | 552 | try { |
| 553 | 553 | $sth = $this->db->prepare($query); |
@@ -561,30 +561,30 @@ discard block |
||
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
| 564 | - * Adds a new spotter data |
|
| 565 | - * |
|
| 566 | - * @param String $fammarine_id the ID |
|
| 567 | - * @param String $ident the marine ident |
|
| 568 | - * @param String $departure_airport_icao the departure airport |
|
| 569 | - * @param String $arrival_airport_icao the arrival airport |
|
| 570 | - * @param String $latitude latitude of flight |
|
| 571 | - * @param String $longitude latitude of flight |
|
| 572 | - * @param String $waypoints waypoints of flight |
|
| 573 | - * @param String $heading heading of flight |
|
| 574 | - * @param String $groundspeed speed of flight |
|
| 575 | - * @param String $date date of flight |
|
| 576 | - * @param String $departure_airport_time departure time of flight |
|
| 577 | - * @param String $arrival_airport_time arrival time of flight |
|
| 578 | - * @param String $squawk squawk code of flight |
|
| 579 | - * @param String $route_stop route stop of flight |
|
| 580 | - * @param String $highlight highlight or not |
|
| 581 | - * @param String $ModeS ModesS code of flight |
|
| 582 | - * @param String $registration registration code of flight |
|
| 583 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 584 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 585 | - * @param String $verticalrate vertival rate of flight |
|
| 586 | - * @return String success or false |
|
| 587 | - */ |
|
| 564 | + * Adds a new spotter data |
|
| 565 | + * |
|
| 566 | + * @param String $fammarine_id the ID |
|
| 567 | + * @param String $ident the marine ident |
|
| 568 | + * @param String $departure_airport_icao the departure airport |
|
| 569 | + * @param String $arrival_airport_icao the arrival airport |
|
| 570 | + * @param String $latitude latitude of flight |
|
| 571 | + * @param String $longitude latitude of flight |
|
| 572 | + * @param String $waypoints waypoints of flight |
|
| 573 | + * @param String $heading heading of flight |
|
| 574 | + * @param String $groundspeed speed of flight |
|
| 575 | + * @param String $date date of flight |
|
| 576 | + * @param String $departure_airport_time departure time of flight |
|
| 577 | + * @param String $arrival_airport_time arrival time of flight |
|
| 578 | + * @param String $squawk squawk code of flight |
|
| 579 | + * @param String $route_stop route stop of flight |
|
| 580 | + * @param String $highlight highlight or not |
|
| 581 | + * @param String $ModeS ModesS code of flight |
|
| 582 | + * @param String $registration registration code of flight |
|
| 583 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 584 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 585 | + * @param String $verticalrate vertival rate of flight |
|
| 586 | + * @return String success or false |
|
| 587 | + */ |
|
| 588 | 588 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '') |
| 589 | 589 | { |
| 590 | 590 | global $globalURL, $globalMarineImageFetch; |
@@ -681,13 +681,13 @@ discard block |
||
| 681 | 681 | unset($Image); |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - if ($latitude == '' && $longitude == '') { |
|
| 685 | - $latitude = 0; |
|
| 686 | - $longitude = 0; |
|
| 687 | - } |
|
| 688 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 689 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 690 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 684 | + if ($latitude == '' && $longitude == '') { |
|
| 685 | + $latitude = 0; |
|
| 686 | + $longitude = 0; |
|
| 687 | + } |
|
| 688 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 689 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 690 | + if ($arrival_date == '') $arrival_date = NULL; |
|
| 691 | 691 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
| 692 | 692 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 693 | 693 | |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | $sth->execute($query_values); |
| 699 | 699 | $this->db = null; |
| 700 | 700 | } catch (PDOException $e) { |
| 701 | - return "error : ".$e->getMessage(); |
|
| 701 | + return "error : ".$e->getMessage(); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | return "success"; |
@@ -707,11 +707,11 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | |
| 709 | 709 | /** |
| 710 | - * Gets the aircraft ident within the last hour |
|
| 711 | - * |
|
| 712 | - * @return String the ident |
|
| 713 | - * |
|
| 714 | - */ |
|
| 710 | + * Gets the aircraft ident within the last hour |
|
| 711 | + * |
|
| 712 | + * @return String the ident |
|
| 713 | + * |
|
| 714 | + */ |
|
| 715 | 715 | public function getIdentFromLastHour($ident) |
| 716 | 716 | { |
| 717 | 717 | global $globalDBdriver, $globalTimezone; |
@@ -727,11 +727,11 @@ discard block |
||
| 727 | 727 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 728 | 728 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
| 729 | 729 | $query_data = array(':ident' => $ident); |
| 730 | - } |
|
| 730 | + } |
|
| 731 | 731 | |
| 732 | 732 | $sth = $this->db->prepare($query); |
| 733 | 733 | $sth->execute($query_data); |
| 734 | - $ident_result=''; |
|
| 734 | + $ident_result=''; |
|
| 735 | 735 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 736 | 736 | { |
| 737 | 737 | $ident_result = $row['ident']; |
@@ -742,11 +742,11 @@ discard block |
||
| 742 | 742 | |
| 743 | 743 | |
| 744 | 744 | /** |
| 745 | - * Gets the aircraft data from the last 20 seconds |
|
| 746 | - * |
|
| 747 | - * @return Array the spotter data |
|
| 748 | - * |
|
| 749 | - */ |
|
| 745 | + * Gets the aircraft data from the last 20 seconds |
|
| 746 | + * |
|
| 747 | + * @return Array the spotter data |
|
| 748 | + * |
|
| 749 | + */ |
|
| 750 | 750 | public function getRealTimeData($q = '') |
| 751 | 751 | { |
| 752 | 752 | global $globalDBdriver; |
@@ -784,11 +784,11 @@ discard block |
||
| 784 | 784 | |
| 785 | 785 | |
| 786 | 786 | /** |
| 787 | - * Gets all number of flight over countries |
|
| 788 | - * |
|
| 789 | - * @return Array the airline country list |
|
| 790 | - * |
|
| 791 | - */ |
|
| 787 | + * Gets all number of flight over countries |
|
| 788 | + * |
|
| 789 | + * @return Array the airline country list |
|
| 790 | + * |
|
| 791 | + */ |
|
| 792 | 792 | /* |
| 793 | 793 | public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 794 | 794 | { |
@@ -839,11 +839,11 @@ discard block |
||
| 839 | 839 | |
| 840 | 840 | |
| 841 | 841 | /** |
| 842 | - * Gets all callsigns that have flown over |
|
| 843 | - * |
|
| 844 | - * @return Array the callsign list |
|
| 845 | - * |
|
| 846 | - */ |
|
| 842 | + * Gets all callsigns that have flown over |
|
| 843 | + * |
|
| 844 | + * @return Array the callsign list |
|
| 845 | + * |
|
| 846 | + */ |
|
| 847 | 847 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 848 | 848 | { |
| 849 | 849 | global $globalDBdriver; |
@@ -910,11 +910,11 @@ discard block |
||
| 910 | 910 | |
| 911 | 911 | |
| 912 | 912 | /** |
| 913 | - * Counts all dates |
|
| 914 | - * |
|
| 915 | - * @return Array the date list |
|
| 916 | - * |
|
| 917 | - */ |
|
| 913 | + * Counts all dates |
|
| 914 | + * |
|
| 915 | + * @return Array the date list |
|
| 916 | + * |
|
| 917 | + */ |
|
| 918 | 918 | public function countAllDates($filters = array()) |
| 919 | 919 | { |
| 920 | 920 | global $globalTimezone, $globalDBdriver; |
@@ -960,11 +960,11 @@ discard block |
||
| 960 | 960 | |
| 961 | 961 | |
| 962 | 962 | /** |
| 963 | - * Counts all dates during the last 7 days |
|
| 964 | - * |
|
| 965 | - * @return Array the date list |
|
| 966 | - * |
|
| 967 | - */ |
|
| 963 | + * Counts all dates during the last 7 days |
|
| 964 | + * |
|
| 965 | + * @return Array the date list |
|
| 966 | + * |
|
| 967 | + */ |
|
| 968 | 968 | public function countAllDatesLast7Days($filters = array()) |
| 969 | 969 | { |
| 970 | 970 | global $globalTimezone, $globalDBdriver; |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | $query .= " GROUP BY date_name |
| 987 | 987 | ORDER BY date_name ASC"; |
| 988 | 988 | $query_data = array(':offset' => $offset); |
| 989 | - } |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | 991 | $sth = $this->db->prepare($query); |
| 992 | 992 | $sth->execute($query_data); |
@@ -1006,11 +1006,11 @@ discard block |
||
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | /** |
| 1009 | - * Counts all dates during the last month |
|
| 1010 | - * |
|
| 1011 | - * @return Array the date list |
|
| 1012 | - * |
|
| 1013 | - */ |
|
| 1009 | + * Counts all dates during the last month |
|
| 1010 | + * |
|
| 1011 | + * @return Array the date list |
|
| 1012 | + * |
|
| 1013 | + */ |
|
| 1014 | 1014 | public function countAllDatesLastMonth($filters = array()) |
| 1015 | 1015 | { |
| 1016 | 1016 | global $globalTimezone, $globalDBdriver; |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | $query .= " GROUP BY date_name |
| 1033 | 1033 | ORDER BY date_name ASC"; |
| 1034 | 1034 | $query_data = array(':offset' => $offset); |
| 1035 | - } |
|
| 1035 | + } |
|
| 1036 | 1036 | |
| 1037 | 1037 | $sth = $this->db->prepare($query); |
| 1038 | 1038 | $sth->execute($query_data); |
@@ -1054,11 +1054,11 @@ discard block |
||
| 1054 | 1054 | |
| 1055 | 1055 | |
| 1056 | 1056 | /** |
| 1057 | - * Counts all month |
|
| 1058 | - * |
|
| 1059 | - * @return Array the month list |
|
| 1060 | - * |
|
| 1061 | - */ |
|
| 1057 | + * Counts all month |
|
| 1058 | + * |
|
| 1059 | + * @return Array the month list |
|
| 1060 | + * |
|
| 1061 | + */ |
|
| 1062 | 1062 | public function countAllMonths($filters = array()) |
| 1063 | 1063 | { |
| 1064 | 1064 | global $globalTimezone, $globalDBdriver; |
@@ -1103,11 +1103,11 @@ discard block |
||
| 1103 | 1103 | |
| 1104 | 1104 | |
| 1105 | 1105 | /** |
| 1106 | - * Counts all dates during the last year |
|
| 1107 | - * |
|
| 1108 | - * @return Array the date list |
|
| 1109 | - * |
|
| 1110 | - */ |
|
| 1106 | + * Counts all dates during the last year |
|
| 1107 | + * |
|
| 1108 | + * @return Array the date list |
|
| 1109 | + * |
|
| 1110 | + */ |
|
| 1111 | 1111 | public function countAllMonthsLastYear($filters) |
| 1112 | 1112 | { |
| 1113 | 1113 | global $globalTimezone, $globalDBdriver; |
@@ -1129,7 +1129,7 @@ discard block |
||
| 1129 | 1129 | $query .= " GROUP BY year_name, month_name |
| 1130 | 1130 | ORDER BY year_name, month_name ASC"; |
| 1131 | 1131 | $query_data = array(':offset' => $offset); |
| 1132 | - } |
|
| 1132 | + } |
|
| 1133 | 1133 | |
| 1134 | 1134 | $sth = $this->db->prepare($query); |
| 1135 | 1135 | $sth->execute($query_data); |
@@ -1152,11 +1152,11 @@ discard block |
||
| 1152 | 1152 | |
| 1153 | 1153 | |
| 1154 | 1154 | /** |
| 1155 | - * Counts all hours |
|
| 1156 | - * |
|
| 1157 | - * @return Array the hour list |
|
| 1158 | - * |
|
| 1159 | - */ |
|
| 1155 | + * Counts all hours |
|
| 1156 | + * |
|
| 1157 | + * @return Array the hour list |
|
| 1158 | + * |
|
| 1159 | + */ |
|
| 1160 | 1160 | public function countAllHours($orderby,$filters = array()) |
| 1161 | 1161 | { |
| 1162 | 1162 | global $globalTimezone, $globalDBdriver; |
@@ -1219,11 +1219,11 @@ discard block |
||
| 1219 | 1219 | |
| 1220 | 1220 | |
| 1221 | 1221 | /** |
| 1222 | - * Counts all hours by date |
|
| 1223 | - * |
|
| 1224 | - * @return Array the hour list |
|
| 1225 | - * |
|
| 1226 | - */ |
|
| 1222 | + * Counts all hours by date |
|
| 1223 | + * |
|
| 1224 | + * @return Array the hour list |
|
| 1225 | + * |
|
| 1226 | + */ |
|
| 1227 | 1227 | public function countAllHoursByDate($date, $filters = array()) |
| 1228 | 1228 | { |
| 1229 | 1229 | global $globalTimezone, $globalDBdriver; |
@@ -1267,11 +1267,11 @@ discard block |
||
| 1267 | 1267 | |
| 1268 | 1268 | |
| 1269 | 1269 | /** |
| 1270 | - * Counts all hours by a ident/callsign |
|
| 1271 | - * |
|
| 1272 | - * @return Array the hour list |
|
| 1273 | - * |
|
| 1274 | - */ |
|
| 1270 | + * Counts all hours by a ident/callsign |
|
| 1271 | + * |
|
| 1272 | + * @return Array the hour list |
|
| 1273 | + * |
|
| 1274 | + */ |
|
| 1275 | 1275 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1276 | 1276 | { |
| 1277 | 1277 | global $globalTimezone, $globalDBdriver; |
@@ -1316,11 +1316,11 @@ discard block |
||
| 1316 | 1316 | |
| 1317 | 1317 | |
| 1318 | 1318 | /** |
| 1319 | - * Counts all flights that have flown over |
|
| 1320 | - * |
|
| 1321 | - * @return Integer the number of flights |
|
| 1322 | - * |
|
| 1323 | - */ |
|
| 1319 | + * Counts all flights that have flown over |
|
| 1320 | + * |
|
| 1321 | + * @return Integer the number of flights |
|
| 1322 | + * |
|
| 1323 | + */ |
|
| 1324 | 1324 | public function countOverallTracked($filters = array(),$year = '',$month = '') |
| 1325 | 1325 | { |
| 1326 | 1326 | global $globalDBdriver; |
@@ -1355,11 +1355,11 @@ discard block |
||
| 1355 | 1355 | |
| 1356 | 1356 | |
| 1357 | 1357 | /** |
| 1358 | - * Counts all hours of today |
|
| 1359 | - * |
|
| 1360 | - * @return Array the hour list |
|
| 1361 | - * |
|
| 1362 | - */ |
|
| 1358 | + * Counts all hours of today |
|
| 1359 | + * |
|
| 1360 | + * @return Array the hour list |
|
| 1361 | + * |
|
| 1362 | + */ |
|
| 1363 | 1363 | public function countAllHoursFromToday($filters = array()) |
| 1364 | 1364 | { |
| 1365 | 1365 | global $globalTimezone, $globalDBdriver; |
@@ -1399,12 +1399,12 @@ discard block |
||
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | |
| 1402 | - /** |
|
| 1403 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1404 | - * |
|
| 1405 | - * @return Integer the Barrie Spotter ID |
|
| 1402 | + /** |
|
| 1403 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1404 | + * |
|
| 1405 | + * @return Integer the Barrie Spotter ID |
|
| 1406 | 1406 | q * |
| 1407 | - */ |
|
| 1407 | + */ |
|
| 1408 | 1408 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1409 | 1409 | { |
| 1410 | 1410 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1425,13 +1425,13 @@ discard block |
||
| 1425 | 1425 | |
| 1426 | 1426 | |
| 1427 | 1427 | /** |
| 1428 | - * Parses a date string |
|
| 1429 | - * |
|
| 1430 | - * @param String $dateString the date string |
|
| 1431 | - * @param String $timezone the timezone of a user |
|
| 1432 | - * @return Array the time information |
|
| 1433 | - * |
|
| 1434 | - */ |
|
| 1428 | + * Parses a date string |
|
| 1429 | + * |
|
| 1430 | + * @param String $dateString the date string |
|
| 1431 | + * @param String $timezone the timezone of a user |
|
| 1432 | + * @return Array the time information |
|
| 1433 | + * |
|
| 1434 | + */ |
|
| 1435 | 1435 | public function parseDateString($dateString, $timezone = '') |
| 1436 | 1436 | { |
| 1437 | 1437 | $time_array = array(); |
@@ -1464,12 +1464,12 @@ discard block |
||
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | /** |
| 1467 | - * Parses the direction degrees to working |
|
| 1468 | - * |
|
| 1469 | - * @param Float $direction the direction in degrees |
|
| 1470 | - * @return Array the direction information |
|
| 1471 | - * |
|
| 1472 | - */ |
|
| 1467 | + * Parses the direction degrees to working |
|
| 1468 | + * |
|
| 1469 | + * @param Float $direction the direction in degrees |
|
| 1470 | + * @return Array the direction information |
|
| 1471 | + * |
|
| 1472 | + */ |
|
| 1473 | 1473 | public function parseDirection($direction = 0) |
| 1474 | 1474 | { |
| 1475 | 1475 | if ($direction == '') $direction = 0; |
@@ -1548,12 +1548,12 @@ discard block |
||
| 1548 | 1548 | |
| 1549 | 1549 | |
| 1550 | 1550 | /** |
| 1551 | - * Gets Country from latitude/longitude |
|
| 1552 | - * |
|
| 1553 | - * @param Float $latitude latitute of the flight |
|
| 1554 | - * @param Float $longitude longitute of the flight |
|
| 1555 | - * @return String the countrie |
|
| 1556 | - */ |
|
| 1551 | + * Gets Country from latitude/longitude |
|
| 1552 | + * |
|
| 1553 | + * @param Float $latitude latitute of the flight |
|
| 1554 | + * @param Float $longitude longitute of the flight |
|
| 1555 | + * @return String the countrie |
|
| 1556 | + */ |
|
| 1557 | 1557 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 1558 | 1558 | { |
| 1559 | 1559 | global $globalDBdriver, $globalDebug; |
@@ -1590,11 +1590,11 @@ discard block |
||
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | 1592 | /** |
| 1593 | - * Gets Country from iso2 |
|
| 1594 | - * |
|
| 1595 | - * @param String $iso2 ISO2 country code |
|
| 1596 | - * @return String the countrie |
|
| 1597 | - */ |
|
| 1593 | + * Gets Country from iso2 |
|
| 1594 | + * |
|
| 1595 | + * @param String $iso2 ISO2 country code |
|
| 1596 | + * @return String the countrie |
|
| 1597 | + */ |
|
| 1598 | 1598 | public function getCountryFromISO2($iso2) |
| 1599 | 1599 | { |
| 1600 | 1600 | global $globalDBdriver, $globalDebug; |
@@ -1623,12 +1623,12 @@ discard block |
||
| 1623 | 1623 | |
| 1624 | 1624 | |
| 1625 | 1625 | /** |
| 1626 | - * Gets the short url from bit.ly |
|
| 1627 | - * |
|
| 1628 | - * @param String $url the full url |
|
| 1629 | - * @return String the bit.ly url |
|
| 1630 | - * |
|
| 1631 | - */ |
|
| 1626 | + * Gets the short url from bit.ly |
|
| 1627 | + * |
|
| 1628 | + * @param String $url the full url |
|
| 1629 | + * @return String the bit.ly url |
|
| 1630 | + * |
|
| 1631 | + */ |
|
| 1632 | 1632 | public function getBitlyURL($url) |
| 1633 | 1633 | { |
| 1634 | 1634 | global $globalBitlyAccessToken; |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
| 4 | 4 | |
| 5 | -class Marine{ |
|
| 5 | +class Marine { |
|
| 6 | 6 | public $db; |
| 7 | 7 | |
| 8 | 8 | public function __construct($dbc = null) { |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @return Array the SQL part |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 72 | 72 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 73 | 73 | if ($filter_query_where != '') { |
| 74 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 74 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 75 | 75 | } |
| 76 | 76 | $filter_query = $filter_query_join.$filter_query_where; |
| 77 | 77 | return $filter_query; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return Array the spotter information |
| 87 | 87 | * |
| 88 | 88 | */ |
| 89 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 89 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 90 | 90 | { |
| 91 | 91 | date_default_timezone_set('UTC'); |
| 92 | 92 | if (!is_string($query)) |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | $sth = $this->db->prepare($query.$limitQuery); |
| 107 | 107 | $sth->execute($params); |
| 108 | 108 | } catch (PDOException $e) { |
| 109 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 109 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 110 | 110 | exit(); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $num_rows = 0; |
| 114 | 114 | $spotter_array = array(); |
| 115 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 115 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 116 | 116 | { |
| 117 | 117 | $num_rows++; |
| 118 | 118 | $temp_array = array(); |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 145 | 145 | |
| 146 | - if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) |
|
| 146 | + if ($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) |
|
| 147 | 147 | { |
| 148 | 148 | $Image = new Image($this->db); |
| 149 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 149 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 150 | 150 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 151 | 151 | unset($Image); |
| 152 | 152 | if (count($image_array) > 0) { |
@@ -182,17 +182,17 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 184 | 184 | } else { |
| 185 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 185 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 186 | 186 | } |
| 187 | 187 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 188 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 189 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 188 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 189 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 190 | 190 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 191 | 191 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 192 | 192 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 193 | 193 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 194 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 195 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 194 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 195 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 196 | 196 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | $limit_array = explode(",", $limit); |
| 231 | 231 | |
| 232 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 233 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 232 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 233 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 234 | 234 | |
| 235 | 235 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 236 | 236 | { |
@@ -247,9 +247,9 @@ discard block |
||
| 247 | 247 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 250 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 251 | 251 | |
| 252 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 252 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 253 | 253 | |
| 254 | 254 | return $spotter_array; |
| 255 | 255 | } |
@@ -268,8 +268,8 @@ discard block |
||
| 268 | 268 | if ($id == '') return array(); |
| 269 | 269 | $additional_query = "marine_output.fammarine_id = :id"; |
| 270 | 270 | $query_values = array(':id' => $id); |
| 271 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 272 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 271 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 272 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 273 | 273 | return $spotter_array; |
| 274 | 274 | } |
| 275 | 275 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $query_values = array(); |
| 289 | 289 | $limit_query = ''; |
| 290 | 290 | $additional_query = ''; |
| 291 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 291 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 292 | 292 | if ($ident != "") |
| 293 | 293 | { |
| 294 | 294 | if (!is_string($ident)) |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | $limit_array = explode(",", $limit); |
| 306 | 306 | |
| 307 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 308 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 307 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 308 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 309 | 309 | |
| 310 | 310 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 311 | 311 | { |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | return $spotter_array; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 332 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 333 | 333 | { |
| 334 | 334 | global $global_query, $globalTimezone, $globalDBdriver; |
| 335 | 335 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $limit_query = ''; |
| 338 | 338 | $additional_query = ''; |
| 339 | 339 | |
| 340 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 340 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 341 | 341 | |
| 342 | 342 | if ($date != "") |
| 343 | 343 | { |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | { |
| 364 | 364 | $limit_array = explode(",", $limit); |
| 365 | 365 | |
| 366 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 367 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 366 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 367 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 368 | 368 | |
| 369 | 369 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 370 | 370 | { |
@@ -395,11 +395,11 @@ discard block |
||
| 395 | 395 | * @return Array list of source name |
| 396 | 396 | * |
| 397 | 397 | */ |
| 398 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 398 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 399 | 399 | { |
| 400 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 400 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 401 | 401 | $query_values = array(); |
| 402 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 402 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 403 | 403 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 404 | 404 | if ($type != '') { |
| 405 | 405 | $query_values = array(':type' => $type); |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $source_array = array(); |
| 415 | 415 | $temp_array = array(); |
| 416 | 416 | |
| 417 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 417 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 418 | 418 | { |
| 419 | 419 | $temp_array['source_name'] = $row['source_name']; |
| 420 | 420 | $source_array[] = $temp_array; |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | */ |
| 432 | 432 | public function getAllIdents($filters = array()) |
| 433 | 433 | { |
| 434 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 435 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 434 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 435 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 436 | 436 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 437 | 437 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 438 | 438 | |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | $ident_array = array(); |
| 443 | 443 | $temp_array = array(); |
| 444 | 444 | |
| 445 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 445 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 446 | 446 | { |
| 447 | 447 | $temp_array['ident'] = $row['ident']; |
| 448 | 448 | $ident_array[] = $temp_array; |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | public function getIdentity($mmsi) |
| 461 | 461 | { |
| 462 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 462 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 463 | 463 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 464 | 464 | $sth = $this->db->prepare($query); |
| 465 | 465 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -484,12 +484,12 @@ discard block |
||
| 484 | 484 | } else $offset = '+00:00'; |
| 485 | 485 | |
| 486 | 486 | if ($globalDBdriver == 'mysql') { |
| 487 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 487 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 488 | 488 | FROM marine_output |
| 489 | 489 | WHERE marine_output.date <> '' |
| 490 | 490 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
| 491 | 491 | } else { |
| 492 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 492 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 493 | 493 | FROM marine_output |
| 494 | 494 | WHERE marine_output.date <> '' |
| 495 | 495 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $date_array = array(); |
| 502 | 502 | $temp_array = array(); |
| 503 | 503 | |
| 504 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 504 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 505 | 505 | { |
| 506 | 506 | $temp_array['date'] = $row['date']; |
| 507 | 507 | |
@@ -520,11 +520,11 @@ discard block |
||
| 520 | 520 | * @return String success or false |
| 521 | 521 | * |
| 522 | 522 | */ |
| 523 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 523 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 524 | 524 | { |
| 525 | 525 | |
| 526 | 526 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 527 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 527 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 528 | 528 | |
| 529 | 529 | try { |
| 530 | 530 | $sth = $this->db->prepare($query); |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 548 | 548 | { |
| 549 | 549 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 550 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 550 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 551 | 551 | |
| 552 | 552 | try { |
| 553 | 553 | $sth = $this->db->prepare($query); |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * @param String $verticalrate vertival rate of flight |
| 586 | 586 | * @return String success or false |
| 587 | 587 | */ |
| 588 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '') |
|
| 588 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $format_source = '', $source_name = '') |
|
| 589 | 589 | { |
| 590 | 590 | global $globalURL, $globalMarineImageFetch; |
| 591 | 591 | |
@@ -652,31 +652,31 @@ discard block |
||
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | |
| 655 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 655 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 656 | 656 | { |
| 657 | 657 | $date = date("Y-m-d H:i:s", time()); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 661 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 662 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 663 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 664 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 665 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 666 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 667 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 668 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 669 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 670 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 671 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 672 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 673 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 660 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 661 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 662 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 663 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 664 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 665 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 666 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 667 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 668 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 669 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 670 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 671 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 672 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 673 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 674 | 674 | |
| 675 | 675 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 676 | 676 | $Image = new Image($this->db); |
| 677 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 677 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 678 | 678 | if (!isset($image_array[0]['mmsi'])) { |
| 679 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 679 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 680 | 680 | } |
| 681 | 681 | unset($Image); |
| 682 | 682 | } |
@@ -688,10 +688,10 @@ discard block |
||
| 688 | 688 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 689 | 689 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 690 | 690 | if ($arrival_date == '') $arrival_date = NULL; |
| 691 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 691 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 692 | 692 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 693 | 693 | |
| 694 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 694 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 695 | 695 | try { |
| 696 | 696 | |
| 697 | 697 | $sth = $this->db->prepare($query); |
@@ -716,13 +716,13 @@ discard block |
||
| 716 | 716 | { |
| 717 | 717 | global $globalDBdriver, $globalTimezone; |
| 718 | 718 | if ($globalDBdriver == 'mysql') { |
| 719 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 719 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 720 | 720 | WHERE marine_output.ident = :ident |
| 721 | 721 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 722 | 722 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 723 | 723 | $query_data = array(':ident' => $ident); |
| 724 | 724 | } else { |
| 725 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 725 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 726 | 726 | WHERE marine_output.ident = :ident |
| 727 | 727 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 728 | 728 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -731,8 +731,8 @@ discard block |
||
| 731 | 731 | |
| 732 | 732 | $sth = $this->db->prepare($query); |
| 733 | 733 | $sth->execute($query_data); |
| 734 | - $ident_result=''; |
|
| 735 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 734 | + $ident_result = ''; |
|
| 735 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 736 | 736 | { |
| 737 | 737 | $ident_result = $row['ident']; |
| 738 | 738 | } |
@@ -758,8 +758,8 @@ discard block |
||
| 758 | 758 | return false; |
| 759 | 759 | } else { |
| 760 | 760 | $q_array = explode(" ", $q); |
| 761 | - foreach ($q_array as $q_item){ |
|
| 762 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 761 | + foreach ($q_array as $q_item) { |
|
| 762 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 763 | 763 | $additional_query .= " AND ("; |
| 764 | 764 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 765 | 765 | $additional_query .= ")"; |
@@ -767,11 +767,11 @@ discard block |
||
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | if ($globalDBdriver == 'mysql') { |
| 770 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 770 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 771 | 771 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 772 | 772 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 773 | 773 | } else { |
| 774 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 774 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 775 | 775 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 776 | 776 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 777 | 777 | } |
@@ -844,11 +844,11 @@ discard block |
||
| 844 | 844 | * @return Array the callsign list |
| 845 | 845 | * |
| 846 | 846 | */ |
| 847 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 847 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 848 | 848 | { |
| 849 | 849 | global $globalDBdriver; |
| 850 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 851 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 850 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 851 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 852 | 852 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 853 | 853 | if ($olderthanmonths > 0) { |
| 854 | 854 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -862,28 +862,28 @@ discard block |
||
| 862 | 862 | if ($year != '') { |
| 863 | 863 | if ($globalDBdriver == 'mysql') { |
| 864 | 864 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 865 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 865 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 866 | 866 | } else { |
| 867 | 867 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 868 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 868 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | if ($month != '') { |
| 872 | 872 | if ($globalDBdriver == 'mysql') { |
| 873 | 873 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 874 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 874 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 875 | 875 | } else { |
| 876 | 876 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 877 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 877 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 878 | 878 | } |
| 879 | 879 | } |
| 880 | 880 | if ($day != '') { |
| 881 | 881 | if ($globalDBdriver == 'mysql') { |
| 882 | 882 | $query .= " AND DAY(marine_output.date) = :day"; |
| 883 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 883 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 884 | 884 | } else { |
| 885 | 885 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 886 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 886 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 887 | 887 | } |
| 888 | 888 | } |
| 889 | 889 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | $callsign_array = array(); |
| 896 | 896 | $temp_array = array(); |
| 897 | 897 | |
| 898 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 898 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 899 | 899 | { |
| 900 | 900 | $temp_array['callsign_icao'] = $row['ident']; |
| 901 | 901 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | $date_array = array(); |
| 948 | 948 | $temp_array = array(); |
| 949 | 949 | |
| 950 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 950 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 951 | 951 | { |
| 952 | 952 | $temp_array['date_name'] = $row['date_name']; |
| 953 | 953 | $temp_array['date_count'] = $row['date_count']; |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | $datetime = new DateTime(); |
| 974 | 974 | $offset = $datetime->format('P'); |
| 975 | 975 | } else $offset = '+00:00'; |
| 976 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 976 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 977 | 977 | if ($globalDBdriver == 'mysql') { |
| 978 | 978 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 979 | 979 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | $date_array = array(); |
| 995 | 995 | $temp_array = array(); |
| 996 | 996 | |
| 997 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 997 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 998 | 998 | { |
| 999 | 999 | $temp_array['date_name'] = $row['date_name']; |
| 1000 | 1000 | $temp_array['date_count'] = $row['date_count']; |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | $datetime = new DateTime(); |
| 1020 | 1020 | $offset = $datetime->format('P'); |
| 1021 | 1021 | } else $offset = '+00:00'; |
| 1022 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1022 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1023 | 1023 | if ($globalDBdriver == 'mysql') { |
| 1024 | 1024 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1025 | 1025 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | $date_array = array(); |
| 1041 | 1041 | $temp_array = array(); |
| 1042 | 1042 | |
| 1043 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1043 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1044 | 1044 | { |
| 1045 | 1045 | $temp_array['date_name'] = $row['date_name']; |
| 1046 | 1046 | $temp_array['date_count'] = $row['date_count']; |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | $date_array = array(); |
| 1088 | 1088 | $temp_array = array(); |
| 1089 | 1089 | |
| 1090 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1090 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1091 | 1091 | { |
| 1092 | 1092 | $temp_array['month_name'] = $row['month_name']; |
| 1093 | 1093 | $temp_array['year_name'] = $row['year_name']; |
@@ -1116,7 +1116,7 @@ discard block |
||
| 1116 | 1116 | $datetime = new DateTime(); |
| 1117 | 1117 | $offset = $datetime->format('P'); |
| 1118 | 1118 | } else $offset = '+00:00'; |
| 1119 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1119 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1120 | 1120 | if ($globalDBdriver == 'mysql') { |
| 1121 | 1121 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1122 | 1122 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1137,7 +1137,7 @@ discard block |
||
| 1137 | 1137 | $date_array = array(); |
| 1138 | 1138 | $temp_array = array(); |
| 1139 | 1139 | |
| 1140 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1140 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1141 | 1141 | { |
| 1142 | 1142 | $temp_array['year_name'] = $row['year_name']; |
| 1143 | 1143 | $temp_array['month_name'] = $row['month_name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | * @return Array the hour list |
| 1158 | 1158 | * |
| 1159 | 1159 | */ |
| 1160 | - public function countAllHours($orderby,$filters = array()) |
|
| 1160 | + public function countAllHours($orderby, $filters = array()) |
|
| 1161 | 1161 | { |
| 1162 | 1162 | global $globalTimezone, $globalDBdriver; |
| 1163 | 1163 | if ($globalTimezone != '') { |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | $hour_array = array(); |
| 1206 | 1206 | $temp_array = array(); |
| 1207 | 1207 | |
| 1208 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1208 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1209 | 1209 | { |
| 1210 | 1210 | $temp_array['hour_name'] = $row['hour_name']; |
| 1211 | 1211 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1227,8 +1227,8 @@ discard block |
||
| 1227 | 1227 | public function countAllHoursByDate($date, $filters = array()) |
| 1228 | 1228 | { |
| 1229 | 1229 | global $globalTimezone, $globalDBdriver; |
| 1230 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1231 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1230 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1231 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1232 | 1232 | if ($globalTimezone != '') { |
| 1233 | 1233 | date_default_timezone_set($globalTimezone); |
| 1234 | 1234 | $datetime = new DateTime($date); |
@@ -1236,12 +1236,12 @@ discard block |
||
| 1236 | 1236 | } else $offset = '+00:00'; |
| 1237 | 1237 | |
| 1238 | 1238 | if ($globalDBdriver == 'mysql') { |
| 1239 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1239 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1240 | 1240 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1241 | 1241 | GROUP BY hour_name |
| 1242 | 1242 | ORDER BY hour_name ASC"; |
| 1243 | 1243 | } else { |
| 1244 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1244 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1245 | 1245 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1246 | 1246 | GROUP BY hour_name |
| 1247 | 1247 | ORDER BY hour_name ASC"; |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | $hour_array = array(); |
| 1254 | 1254 | $temp_array = array(); |
| 1255 | 1255 | |
| 1256 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1256 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1257 | 1257 | { |
| 1258 | 1258 | $temp_array['hour_name'] = $row['hour_name']; |
| 1259 | 1259 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1275,8 +1275,8 @@ discard block |
||
| 1275 | 1275 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1276 | 1276 | { |
| 1277 | 1277 | global $globalTimezone, $globalDBdriver; |
| 1278 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1279 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1278 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1279 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1280 | 1280 | if ($globalTimezone != '') { |
| 1281 | 1281 | date_default_timezone_set($globalTimezone); |
| 1282 | 1282 | $datetime = new DateTime(); |
@@ -1284,12 +1284,12 @@ discard block |
||
| 1284 | 1284 | } else $offset = '+00:00'; |
| 1285 | 1285 | |
| 1286 | 1286 | if ($globalDBdriver == 'mysql') { |
| 1287 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1287 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1288 | 1288 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1289 | 1289 | GROUP BY hour_name |
| 1290 | 1290 | ORDER BY hour_name ASC"; |
| 1291 | 1291 | } else { |
| 1292 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1292 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1293 | 1293 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1294 | 1294 | GROUP BY hour_name |
| 1295 | 1295 | ORDER BY hour_name ASC"; |
@@ -1297,12 +1297,12 @@ discard block |
||
| 1297 | 1297 | |
| 1298 | 1298 | |
| 1299 | 1299 | $sth = $this->db->prepare($query); |
| 1300 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1300 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1301 | 1301 | |
| 1302 | 1302 | $hour_array = array(); |
| 1303 | 1303 | $temp_array = array(); |
| 1304 | 1304 | |
| 1305 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1305 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1306 | 1306 | { |
| 1307 | 1307 | $temp_array['hour_name'] = $row['hour_name']; |
| 1308 | 1308 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1321,32 +1321,32 @@ discard block |
||
| 1321 | 1321 | * @return Integer the number of flights |
| 1322 | 1322 | * |
| 1323 | 1323 | */ |
| 1324 | - public function countOverallTracked($filters = array(),$year = '',$month = '') |
|
| 1324 | + public function countOverallTracked($filters = array(), $year = '', $month = '') |
|
| 1325 | 1325 | { |
| 1326 | 1326 | global $globalDBdriver; |
| 1327 | - $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1327 | + $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1328 | 1328 | $query_values = array(); |
| 1329 | 1329 | $query = ''; |
| 1330 | 1330 | if ($year != '') { |
| 1331 | 1331 | if ($globalDBdriver == 'mysql') { |
| 1332 | 1332 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1333 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1333 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1334 | 1334 | } else { |
| 1335 | 1335 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1336 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1336 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1337 | 1337 | } |
| 1338 | 1338 | } |
| 1339 | 1339 | if ($month != '') { |
| 1340 | 1340 | if ($globalDBdriver == 'mysql') { |
| 1341 | 1341 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1342 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1342 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1343 | 1343 | } else { |
| 1344 | 1344 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1345 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1345 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1346 | 1346 | } |
| 1347 | 1347 | } |
| 1348 | 1348 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1349 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1349 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1350 | 1350 | |
| 1351 | 1351 | $sth = $this->db->prepare($queryi); |
| 1352 | 1352 | $sth->execute($query_values); |
@@ -1363,7 +1363,7 @@ discard block |
||
| 1363 | 1363 | public function countAllHoursFromToday($filters = array()) |
| 1364 | 1364 | { |
| 1365 | 1365 | global $globalTimezone, $globalDBdriver; |
| 1366 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1366 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1367 | 1367 | if ($globalTimezone != '') { |
| 1368 | 1368 | date_default_timezone_set($globalTimezone); |
| 1369 | 1369 | $datetime = new DateTime(); |
@@ -1371,12 +1371,12 @@ discard block |
||
| 1371 | 1371 | } else $offset = '+00:00'; |
| 1372 | 1372 | |
| 1373 | 1373 | if ($globalDBdriver == 'mysql') { |
| 1374 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1374 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1375 | 1375 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1376 | 1376 | GROUP BY hour_name |
| 1377 | 1377 | ORDER BY hour_name ASC"; |
| 1378 | 1378 | } else { |
| 1379 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1379 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1380 | 1380 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1381 | 1381 | GROUP BY hour_name |
| 1382 | 1382 | ORDER BY hour_name ASC"; |
@@ -1388,7 +1388,7 @@ discard block |
||
| 1388 | 1388 | $hour_array = array(); |
| 1389 | 1389 | $temp_array = array(); |
| 1390 | 1390 | |
| 1391 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1391 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1392 | 1392 | { |
| 1393 | 1393 | $temp_array['hour_name'] = $row['hour_name']; |
| 1394 | 1394 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1407,9 +1407,9 @@ discard block |
||
| 1407 | 1407 | */ |
| 1408 | 1408 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1409 | 1409 | { |
| 1410 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1410 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1411 | 1411 | |
| 1412 | - $query = "SELECT marine_output.marine_id |
|
| 1412 | + $query = "SELECT marine_output.marine_id |
|
| 1413 | 1413 | FROM marine_output |
| 1414 | 1414 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1415 | 1415 | |
@@ -1417,7 +1417,7 @@ discard block |
||
| 1417 | 1417 | $sth = $this->db->prepare($query); |
| 1418 | 1418 | $sth->execute(); |
| 1419 | 1419 | |
| 1420 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1420 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1421 | 1421 | { |
| 1422 | 1422 | return $row['marine_id']; |
| 1423 | 1423 | } |
@@ -1442,23 +1442,23 @@ discard block |
||
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | $current_date = date("Y-m-d H:i:s"); |
| 1445 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1445 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1446 | 1446 | |
| 1447 | 1447 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1448 | 1448 | |
| 1449 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1449 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1450 | 1450 | $years = $time_array['years']; |
| 1451 | 1451 | |
| 1452 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1452 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1453 | 1453 | $months = $time_array['months']; |
| 1454 | 1454 | |
| 1455 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1455 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1456 | 1456 | $days = $time_array['days']; |
| 1457 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1457 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1458 | 1458 | $hours = $time_array['hours']; |
| 1459 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1459 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1460 | 1460 | $minutes = $time_array['minutes']; |
| 1461 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1461 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1462 | 1462 | |
| 1463 | 1463 | return $time_array; |
| 1464 | 1464 | } |
@@ -1481,63 +1481,63 @@ discard block |
||
| 1481 | 1481 | $temp_array['direction_degree'] = $direction; |
| 1482 | 1482 | $temp_array['direction_shortname'] = "N"; |
| 1483 | 1483 | $temp_array['direction_fullname'] = "North"; |
| 1484 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1484 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1485 | 1485 | $temp_array['direction_degree'] = $direction; |
| 1486 | 1486 | $temp_array['direction_shortname'] = "NNE"; |
| 1487 | 1487 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1488 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1488 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1489 | 1489 | $temp_array['direction_degree'] = $direction; |
| 1490 | 1490 | $temp_array['direction_shortname'] = "NE"; |
| 1491 | 1491 | $temp_array['direction_fullname'] = "Northeast"; |
| 1492 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1492 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1493 | 1493 | $temp_array['direction_degree'] = $direction; |
| 1494 | 1494 | $temp_array['direction_shortname'] = "ENE"; |
| 1495 | 1495 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1496 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1496 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1497 | 1497 | $temp_array['direction_degree'] = $direction; |
| 1498 | 1498 | $temp_array['direction_shortname'] = "E"; |
| 1499 | 1499 | $temp_array['direction_fullname'] = "East"; |
| 1500 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1500 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1501 | 1501 | $temp_array['direction_degree'] = $direction; |
| 1502 | 1502 | $temp_array['direction_shortname'] = "ESE"; |
| 1503 | 1503 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1504 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1504 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1505 | 1505 | $temp_array['direction_degree'] = $direction; |
| 1506 | 1506 | $temp_array['direction_shortname'] = "SE"; |
| 1507 | 1507 | $temp_array['direction_fullname'] = "Southeast"; |
| 1508 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1508 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1509 | 1509 | $temp_array['direction_degree'] = $direction; |
| 1510 | 1510 | $temp_array['direction_shortname'] = "SSE"; |
| 1511 | 1511 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1512 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1512 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1513 | 1513 | $temp_array['direction_degree'] = $direction; |
| 1514 | 1514 | $temp_array['direction_shortname'] = "S"; |
| 1515 | 1515 | $temp_array['direction_fullname'] = "South"; |
| 1516 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1516 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1517 | 1517 | $temp_array['direction_degree'] = $direction; |
| 1518 | 1518 | $temp_array['direction_shortname'] = "SSW"; |
| 1519 | 1519 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1520 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1520 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1521 | 1521 | $temp_array['direction_degree'] = $direction; |
| 1522 | 1522 | $temp_array['direction_shortname'] = "SW"; |
| 1523 | 1523 | $temp_array['direction_fullname'] = "Southwest"; |
| 1524 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1524 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1525 | 1525 | $temp_array['direction_degree'] = $direction; |
| 1526 | 1526 | $temp_array['direction_shortname'] = "WSW"; |
| 1527 | 1527 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1528 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1528 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1529 | 1529 | $temp_array['direction_degree'] = $direction; |
| 1530 | 1530 | $temp_array['direction_shortname'] = "W"; |
| 1531 | 1531 | $temp_array['direction_fullname'] = "West"; |
| 1532 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1532 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1533 | 1533 | $temp_array['direction_degree'] = $direction; |
| 1534 | 1534 | $temp_array['direction_shortname'] = "WNW"; |
| 1535 | 1535 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1536 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1536 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1537 | 1537 | $temp_array['direction_degree'] = $direction; |
| 1538 | 1538 | $temp_array['direction_shortname'] = "NW"; |
| 1539 | 1539 | $temp_array['direction_fullname'] = "Northwest"; |
| 1540 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1540 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1541 | 1541 | $temp_array['direction_degree'] = $direction; |
| 1542 | 1542 | $temp_array['direction_shortname'] = "NNW"; |
| 1543 | 1543 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1554,11 +1554,11 @@ discard block |
||
| 1554 | 1554 | * @param Float $longitude longitute of the flight |
| 1555 | 1555 | * @return String the countrie |
| 1556 | 1556 | */ |
| 1557 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1557 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1558 | 1558 | { |
| 1559 | 1559 | global $globalDBdriver, $globalDebug; |
| 1560 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1561 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1560 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1561 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1562 | 1562 | |
| 1563 | 1563 | $Connection = new Connection($this->db); |
| 1564 | 1564 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1598,7 +1598,7 @@ discard block |
||
| 1598 | 1598 | public function getCountryFromISO2($iso2) |
| 1599 | 1599 | { |
| 1600 | 1600 | global $globalDBdriver, $globalDebug; |
| 1601 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1601 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1602 | 1602 | |
| 1603 | 1603 | $Connection = new Connection($this->db); |
| 1604 | 1604 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1646,7 +1646,7 @@ discard block |
||
| 1646 | 1646 | |
| 1647 | 1647 | $bitly_data = json_decode($bitly_data); |
| 1648 | 1648 | $bitly_url = ''; |
| 1649 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1649 | + if ($bitly_data->status_txt = "OK") { |
|
| 1650 | 1650 | $bitly_url = $bitly_data->data->url; |
| 1651 | 1651 | } |
| 1652 | 1652 | |
@@ -1656,7 +1656,7 @@ discard block |
||
| 1656 | 1656 | |
| 1657 | 1657 | public function getOrderBy() |
| 1658 | 1658 | { |
| 1659 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 1659 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 1660 | 1660 | |
| 1661 | 1661 | return $orderby; |
| 1662 | 1662 | |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -68,8 +70,11 @@ discard block |
||
| 68 | 70 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 69 | 71 | } |
| 70 | 72 | } |
| 71 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 72 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 73 | + if ($filter_query_where == '' && $where) { |
|
| 74 | + $filter_query_where = ' WHERE'; |
|
| 75 | + } elseif ($filter_query_where != '' && $and) { |
|
| 76 | + $filter_query_where .= ' AND'; |
|
| 77 | + } |
|
| 73 | 78 | if ($filter_query_where != '') { |
| 74 | 79 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 75 | 80 | } |
@@ -123,31 +128,51 @@ discard block |
||
| 123 | 128 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 124 | 129 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 126 | - */} |
|
| 127 | - elseif (isset($row['marineid'])) { |
|
| 131 | + */} elseif (isset($row['marineid'])) { |
|
| 128 | 132 | $temp_array['marineid'] = $row['marineid']; |
| 129 | 133 | } else { |
| 130 | 134 | $temp_array['marineid'] = ''; |
| 131 | 135 | } |
| 132 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 133 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 134 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 135 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 136 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 137 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 138 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 136 | + if (isset($row['fammarine_id'])) { |
|
| 137 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 138 | + } |
|
| 139 | + if (isset($row['mmsi'])) { |
|
| 140 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 141 | + } |
|
| 142 | + if (isset($row['type'])) { |
|
| 143 | + $temp_array['type'] = $row['type']; |
|
| 144 | + } |
|
| 145 | + if (isset($row['ident'])) { |
|
| 146 | + $temp_array['ident'] = $row['ident']; |
|
| 147 | + } |
|
| 148 | + if (isset($row['latitude'])) { |
|
| 149 | + $temp_array['latitude'] = $row['latitude']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['longitude'])) { |
|
| 152 | + $temp_array['longitude'] = $row['longitude']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['format_source'])) { |
|
| 155 | + $temp_array['format_source'] = $row['format_source']; |
|
| 156 | + } |
|
| 139 | 157 | if (isset($row['heading'])) { |
| 140 | 158 | $temp_array['heading'] = $row['heading']; |
| 141 | 159 | $heading_direction = $this->parseDirection($row['heading']); |
| 142 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 160 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 161 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + if (isset($row['ground_speed'])) { |
|
| 165 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 143 | 166 | } |
| 144 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 145 | 167 | |
| 146 | 168 | if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) |
| 147 | 169 | { |
| 148 | 170 | $Image = new Image($this->db); |
| 149 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 150 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 171 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 172 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 173 | + } else { |
|
| 174 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 175 | + } |
|
| 151 | 176 | unset($Image); |
| 152 | 177 | if (count($image_array) > 0) { |
| 153 | 178 | $temp_array['image'] = $image_array[0]['image']; |
@@ -199,13 +224,21 @@ discard block |
||
| 199 | 224 | } |
| 200 | 225 | |
| 201 | 226 | $fromsource = NULL; |
| 202 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 203 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 204 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 227 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 228 | + $temp_array['source_name'] = $row['source_name']; |
|
| 229 | + } |
|
| 230 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 231 | + $temp_array['over_country'] = $row['over_country']; |
|
| 232 | + } |
|
| 233 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 234 | + $temp_array['distance'] = $row['distance']; |
|
| 235 | + } |
|
| 205 | 236 | $temp_array['query_number_rows'] = $num_rows; |
| 206 | 237 | $spotter_array[] = $temp_array; |
| 207 | 238 | } |
| 208 | - if ($num_rows == 0) return array(); |
|
| 239 | + if ($num_rows == 0) { |
|
| 240 | + return array(); |
|
| 241 | + } |
|
| 209 | 242 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 210 | 243 | return $spotter_array; |
| 211 | 244 | } |
@@ -236,8 +269,12 @@ discard block |
||
| 236 | 269 | { |
| 237 | 270 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 238 | 271 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 239 | - } else $limit_query = ""; |
|
| 240 | - } else $limit_query = ""; |
|
| 272 | + } else { |
|
| 273 | + $limit_query = ""; |
|
| 274 | + } |
|
| 275 | + } else { |
|
| 276 | + $limit_query = ""; |
|
| 277 | + } |
|
| 241 | 278 | |
| 242 | 279 | if ($sort != "") |
| 243 | 280 | { |
@@ -265,7 +302,9 @@ discard block |
||
| 265 | 302 | global $global_query; |
| 266 | 303 | |
| 267 | 304 | date_default_timezone_set('UTC'); |
| 268 | - if ($id == '') return array(); |
|
| 305 | + if ($id == '') { |
|
| 306 | + return array(); |
|
| 307 | + } |
|
| 269 | 308 | $additional_query = "marine_output.fammarine_id = :id"; |
| 270 | 309 | $query_values = array(':id' => $id); |
| 271 | 310 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -408,8 +447,11 @@ discard block |
||
| 408 | 447 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 409 | 448 | |
| 410 | 449 | $sth = $this->db->prepare($query); |
| 411 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 412 | - else $sth->execute(); |
|
| 450 | + if (!empty($query_values)) { |
|
| 451 | + $sth->execute($query_values); |
|
| 452 | + } else { |
|
| 453 | + $sth->execute(); |
|
| 454 | + } |
|
| 413 | 455 | |
| 414 | 456 | $source_array = array(); |
| 415 | 457 | $temp_array = array(); |
@@ -464,8 +506,11 @@ discard block |
||
| 464 | 506 | $sth = $this->db->prepare($query); |
| 465 | 507 | $sth->execute(array(':mmsi' => $mmsi)); |
| 466 | 508 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 467 | - if (isset($result[0])) return $result[0]; |
|
| 468 | - else return array(); |
|
| 509 | + if (isset($result[0])) { |
|
| 510 | + return $result[0]; |
|
| 511 | + } else { |
|
| 512 | + return array(); |
|
| 513 | + } |
|
| 469 | 514 | } |
| 470 | 515 | |
| 471 | 516 | /* |
@@ -481,7 +526,9 @@ discard block |
||
| 481 | 526 | date_default_timezone_set($globalTimezone); |
| 482 | 527 | $datetime = new DateTime(); |
| 483 | 528 | $offset = $datetime->format('P'); |
| 484 | - } else $offset = '+00:00'; |
|
| 529 | + } else { |
|
| 530 | + $offset = '+00:00'; |
|
| 531 | + } |
|
| 485 | 532 | |
| 486 | 533 | if ($globalDBdriver == 'mysql') { |
| 487 | 534 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -685,9 +732,15 @@ discard block |
||
| 685 | 732 | $latitude = 0; |
| 686 | 733 | $longitude = 0; |
| 687 | 734 | } |
| 688 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 689 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 690 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 735 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 736 | + $heading = 0; |
|
| 737 | + } |
|
| 738 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 739 | + $groundspeed = 0; |
|
| 740 | + } |
|
| 741 | + if ($arrival_date == '') { |
|
| 742 | + $arrival_date = NULL; |
|
| 743 | + } |
|
| 691 | 744 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
| 692 | 745 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 693 | 746 | |
@@ -851,12 +904,18 @@ discard block |
||
| 851 | 904 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 852 | 905 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 853 | 906 | if ($olderthanmonths > 0) { |
| 854 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 855 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 907 | + if ($globalDBdriver == 'mysql') { |
|
| 908 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 909 | + } else { |
|
| 910 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 911 | + } |
|
| 856 | 912 | } |
| 857 | 913 | if ($sincedate != '') { |
| 858 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 859 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 914 | + if ($globalDBdriver == 'mysql') { |
|
| 915 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 916 | + } else { |
|
| 917 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 918 | + } |
|
| 860 | 919 | } |
| 861 | 920 | $query_values = array(); |
| 862 | 921 | if ($year != '') { |
@@ -887,7 +946,9 @@ discard block |
||
| 887 | 946 | } |
| 888 | 947 | } |
| 889 | 948 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 890 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 949 | + if ($limit) { |
|
| 950 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 951 | + } |
|
| 891 | 952 | |
| 892 | 953 | $sth = $this->db->prepare($query); |
| 893 | 954 | $sth->execute($query_values); |
@@ -922,7 +983,9 @@ discard block |
||
| 922 | 983 | date_default_timezone_set($globalTimezone); |
| 923 | 984 | $datetime = new DateTime(); |
| 924 | 985 | $offset = $datetime->format('P'); |
| 925 | - } else $offset = '+00:00'; |
|
| 986 | + } else { |
|
| 987 | + $offset = '+00:00'; |
|
| 988 | + } |
|
| 926 | 989 | |
| 927 | 990 | if ($globalDBdriver == 'mysql') { |
| 928 | 991 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -972,7 +1035,9 @@ discard block |
||
| 972 | 1035 | date_default_timezone_set($globalTimezone); |
| 973 | 1036 | $datetime = new DateTime(); |
| 974 | 1037 | $offset = $datetime->format('P'); |
| 975 | - } else $offset = '+00:00'; |
|
| 1038 | + } else { |
|
| 1039 | + $offset = '+00:00'; |
|
| 1040 | + } |
|
| 976 | 1041 | $filter_query = $this->getFilter($filters,true,true); |
| 977 | 1042 | if ($globalDBdriver == 'mysql') { |
| 978 | 1043 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1018,7 +1083,9 @@ discard block |
||
| 1018 | 1083 | date_default_timezone_set($globalTimezone); |
| 1019 | 1084 | $datetime = new DateTime(); |
| 1020 | 1085 | $offset = $datetime->format('P'); |
| 1021 | - } else $offset = '+00:00'; |
|
| 1086 | + } else { |
|
| 1087 | + $offset = '+00:00'; |
|
| 1088 | + } |
|
| 1022 | 1089 | $filter_query = $this->getFilter($filters,true,true); |
| 1023 | 1090 | if ($globalDBdriver == 'mysql') { |
| 1024 | 1091 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1066,7 +1133,9 @@ discard block |
||
| 1066 | 1133 | date_default_timezone_set($globalTimezone); |
| 1067 | 1134 | $datetime = new DateTime(); |
| 1068 | 1135 | $offset = $datetime->format('P'); |
| 1069 | - } else $offset = '+00:00'; |
|
| 1136 | + } else { |
|
| 1137 | + $offset = '+00:00'; |
|
| 1138 | + } |
|
| 1070 | 1139 | |
| 1071 | 1140 | if ($globalDBdriver == 'mysql') { |
| 1072 | 1141 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1115,7 +1184,9 @@ discard block |
||
| 1115 | 1184 | date_default_timezone_set($globalTimezone); |
| 1116 | 1185 | $datetime = new DateTime(); |
| 1117 | 1186 | $offset = $datetime->format('P'); |
| 1118 | - } else $offset = '+00:00'; |
|
| 1187 | + } else { |
|
| 1188 | + $offset = '+00:00'; |
|
| 1189 | + } |
|
| 1119 | 1190 | $filter_query = $this->getFilter($filters,true,true); |
| 1120 | 1191 | if ($globalDBdriver == 'mysql') { |
| 1121 | 1192 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1164,7 +1235,9 @@ discard block |
||
| 1164 | 1235 | date_default_timezone_set($globalTimezone); |
| 1165 | 1236 | $datetime = new DateTime(); |
| 1166 | 1237 | $offset = $datetime->format('P'); |
| 1167 | - } else $offset = '+00:00'; |
|
| 1238 | + } else { |
|
| 1239 | + $offset = '+00:00'; |
|
| 1240 | + } |
|
| 1168 | 1241 | |
| 1169 | 1242 | $orderby_sql = ''; |
| 1170 | 1243 | if ($orderby == "hour") |
@@ -1233,7 +1306,9 @@ discard block |
||
| 1233 | 1306 | date_default_timezone_set($globalTimezone); |
| 1234 | 1307 | $datetime = new DateTime($date); |
| 1235 | 1308 | $offset = $datetime->format('P'); |
| 1236 | - } else $offset = '+00:00'; |
|
| 1309 | + } else { |
|
| 1310 | + $offset = '+00:00'; |
|
| 1311 | + } |
|
| 1237 | 1312 | |
| 1238 | 1313 | if ($globalDBdriver == 'mysql') { |
| 1239 | 1314 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1281,7 +1356,9 @@ discard block |
||
| 1281 | 1356 | date_default_timezone_set($globalTimezone); |
| 1282 | 1357 | $datetime = new DateTime(); |
| 1283 | 1358 | $offset = $datetime->format('P'); |
| 1284 | - } else $offset = '+00:00'; |
|
| 1359 | + } else { |
|
| 1360 | + $offset = '+00:00'; |
|
| 1361 | + } |
|
| 1285 | 1362 | |
| 1286 | 1363 | if ($globalDBdriver == 'mysql') { |
| 1287 | 1364 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1345,8 +1422,11 @@ discard block |
||
| 1345 | 1422 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1346 | 1423 | } |
| 1347 | 1424 | } |
| 1348 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1349 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1425 | + if (empty($query_values)) { |
|
| 1426 | + $queryi .= $this->getFilter($filters); |
|
| 1427 | + } else { |
|
| 1428 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1429 | + } |
|
| 1350 | 1430 | |
| 1351 | 1431 | $sth = $this->db->prepare($queryi); |
| 1352 | 1432 | $sth->execute($query_values); |
@@ -1368,7 +1448,9 @@ discard block |
||
| 1368 | 1448 | date_default_timezone_set($globalTimezone); |
| 1369 | 1449 | $datetime = new DateTime(); |
| 1370 | 1450 | $offset = $datetime->format('P'); |
| 1371 | - } else $offset = '+00:00'; |
|
| 1451 | + } else { |
|
| 1452 | + $offset = '+00:00'; |
|
| 1453 | + } |
|
| 1372 | 1454 | |
| 1373 | 1455 | if ($globalDBdriver == 'mysql') { |
| 1374 | 1456 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1472,7 +1554,9 @@ discard block |
||
| 1472 | 1554 | */ |
| 1473 | 1555 | public function parseDirection($direction = 0) |
| 1474 | 1556 | { |
| 1475 | - if ($direction == '') $direction = 0; |
|
| 1557 | + if ($direction == '') { |
|
| 1558 | + $direction = 0; |
|
| 1559 | + } |
|
| 1476 | 1560 | $direction_array = array(); |
| 1477 | 1561 | $temp_array = array(); |
| 1478 | 1562 | |
@@ -1561,7 +1645,9 @@ discard block |
||
| 1561 | 1645 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1562 | 1646 | |
| 1563 | 1647 | $Connection = new Connection($this->db); |
| 1564 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1648 | + if (!$Connection->tableExists('countries')) { |
|
| 1649 | + return ''; |
|
| 1650 | + } |
|
| 1565 | 1651 | |
| 1566 | 1652 | try { |
| 1567 | 1653 | /* |
@@ -1581,9 +1667,13 @@ discard block |
||
| 1581 | 1667 | $sth->closeCursor(); |
| 1582 | 1668 | if (count($row) > 0) { |
| 1583 | 1669 | return $row; |
| 1584 | - } else return ''; |
|
| 1670 | + } else { |
|
| 1671 | + return ''; |
|
| 1672 | + } |
|
| 1585 | 1673 | } catch (PDOException $e) { |
| 1586 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1674 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1675 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1676 | + } |
|
| 1587 | 1677 | return ''; |
| 1588 | 1678 | } |
| 1589 | 1679 | |
@@ -1601,7 +1691,9 @@ discard block |
||
| 1601 | 1691 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1602 | 1692 | |
| 1603 | 1693 | $Connection = new Connection($this->db); |
| 1604 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1694 | + if (!$Connection->tableExists('countries')) { |
|
| 1695 | + return ''; |
|
| 1696 | + } |
|
| 1605 | 1697 | |
| 1606 | 1698 | try { |
| 1607 | 1699 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1613,9 +1705,13 @@ discard block |
||
| 1613 | 1705 | $sth->closeCursor(); |
| 1614 | 1706 | if (count($row) > 0) { |
| 1615 | 1707 | return $row; |
| 1616 | - } else return ''; |
|
| 1708 | + } else { |
|
| 1709 | + return ''; |
|
| 1710 | + } |
|
| 1617 | 1711 | } catch (PDOException $e) { |
| 1618 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1712 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1713 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1714 | + } |
|
| 1619 | 1715 | return ''; |
| 1620 | 1716 | } |
| 1621 | 1717 | |
@@ -1633,7 +1729,9 @@ discard block |
||
| 1633 | 1729 | { |
| 1634 | 1730 | global $globalBitlyAccessToken; |
| 1635 | 1731 | |
| 1636 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1732 | + if ($globalBitlyAccessToken == '') { |
|
| 1733 | + return $url; |
|
| 1734 | + } |
|
| 1637 | 1735 | |
| 1638 | 1736 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1639 | 1737 | |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Get SQL query part for filter used |
|
| 16 | - * @param Array $filter the filter |
|
| 17 | - * @return Array the SQL part |
|
| 18 | - */ |
|
| 15 | + * Get SQL query part for filter used |
|
| 16 | + * @param Array $filter the filter |
|
| 17 | + * @return Array the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * Gets all the spotter information based on the latest data entry |
|
| 132 | - * |
|
| 133 | - * @return Array the spotter information |
|
| 134 | - * |
|
| 135 | - */ |
|
| 131 | + * Gets all the spotter information based on the latest data entry |
|
| 132 | + * |
|
| 133 | + * @return Array the spotter information |
|
| 134 | + * |
|
| 135 | + */ |
|
| 136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 137 | 137 | { |
| 138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Gets Minimal Live Spotter data |
|
| 178 | - * |
|
| 179 | - * @return Array the spotter information |
|
| 180 | - * |
|
| 181 | - */ |
|
| 177 | + * Gets Minimal Live Spotter data |
|
| 178 | + * |
|
| 179 | + * @return Array the spotter information |
|
| 180 | + * |
|
| 181 | + */ |
|
| 182 | 182 | public function getMinLiveSpotterData($filter = array()) |
| 183 | 183 | { |
| 184 | 184 | global $globalDBdriver, $globalLiveInterval; |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 235 | - * |
|
| 236 | - * @return Array the spotter information |
|
| 237 | - * |
|
| 238 | - */ |
|
| 234 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 235 | + * |
|
| 236 | + * @return Array the spotter information |
|
| 237 | + * |
|
| 238 | + */ |
|
| 239 | 239 | public function getMinLastLiveSpotterData($filter = array()) |
| 240 | 240 | { |
| 241 | 241 | global $globalDBdriver, $globalLiveInterval; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 254 | 254 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 255 | 255 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 256 | - } else { |
|
| 256 | + } else { |
|
| 257 | 257 | /* |
| 258 | 258 | $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 259 | 259 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | // echo $query; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - try { |
|
| 268 | + try { |
|
| 269 | 269 | $sth = $this->db->prepare($query); |
| 270 | 270 | $sth->execute(); |
| 271 | 271 | } catch(PDOException $e) { |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | - * Gets number of latest data entry |
|
| 281 | - * |
|
| 282 | - * @return String number of entry |
|
| 283 | - * |
|
| 284 | - */ |
|
| 280 | + * Gets number of latest data entry |
|
| 281 | + * |
|
| 282 | + * @return String number of entry |
|
| 283 | + * |
|
| 284 | + */ |
|
| 285 | 285 | public function getLiveSpotterCount($filter = array()) |
| 286 | 286 | { |
| 287 | 287 | global $globalDBdriver, $globalLiveInterval; |
@@ -308,11 +308,11 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 312 | - * |
|
| 313 | - * @return Array the spotter information |
|
| 314 | - * |
|
| 315 | - */ |
|
| 311 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 312 | + * |
|
| 313 | + * @return Array the spotter information |
|
| 314 | + * |
|
| 315 | + */ |
|
| 316 | 316 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 317 | 317 | { |
| 318 | 318 | global $globalDBdriver, $globalLiveInterval; |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
| 340 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 341 | - * |
|
| 342 | - * @return Array the spotter information |
|
| 343 | - * |
|
| 344 | - */ |
|
| 340 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 341 | + * |
|
| 342 | + * @return Array the spotter information |
|
| 343 | + * |
|
| 344 | + */ |
|
| 345 | 345 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
| 346 | 346 | { |
| 347 | 347 | global $globalDBdriver, $globalLiveInterval; |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 393 | - * |
|
| 394 | - * @return Array the spotter information |
|
| 395 | - * |
|
| 396 | - */ |
|
| 392 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 393 | + * |
|
| 394 | + * @return Array the spotter information |
|
| 395 | + * |
|
| 396 | + */ |
|
| 397 | 397 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 398 | 398 | { |
| 399 | 399 | $Spotter = new Spotter($this->db); |
@@ -403,145 +403,145 @@ discard block |
||
| 403 | 403 | return false; |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | - if ($lng != '') |
|
| 407 | - { |
|
| 408 | - if (!is_numeric($lng)) |
|
| 409 | - { |
|
| 410 | - return false; |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - if ($radius != '') |
|
| 415 | - { |
|
| 416 | - if (!is_numeric($radius)) |
|
| 417 | - { |
|
| 418 | - return false; |
|
| 419 | - } |
|
| 420 | - } |
|
| 406 | + if ($lng != '') |
|
| 407 | + { |
|
| 408 | + if (!is_numeric($lng)) |
|
| 409 | + { |
|
| 410 | + return false; |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + if ($radius != '') |
|
| 415 | + { |
|
| 416 | + if (!is_numeric($radius)) |
|
| 417 | + { |
|
| 418 | + return false; |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | 421 | $additional_query = ''; |
| 422 | - if ($interval != '') |
|
| 423 | - { |
|
| 424 | - if (!is_string($interval)) |
|
| 425 | - { |
|
| 426 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 427 | - return false; |
|
| 428 | - } else { |
|
| 429 | - if ($interval == '1m') |
|
| 430 | - { |
|
| 431 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 432 | - } else if ($interval == '15m'){ |
|
| 433 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - } else { |
|
| 437 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 422 | + if ($interval != '') |
|
| 423 | + { |
|
| 424 | + if (!is_string($interval)) |
|
| 425 | + { |
|
| 426 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 427 | + return false; |
|
| 428 | + } else { |
|
| 429 | + if ($interval == '1m') |
|
| 430 | + { |
|
| 431 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 432 | + } else if ($interval == '15m'){ |
|
| 433 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + } else { |
|
| 437 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 441 | 441 | WHERE spotter_live.latitude <> '' |
| 442 | 442 | AND spotter_live.longitude <> '' |
| 443 | 443 | ".$additional_query." |
| 444 | 444 | HAVING distance < :radius |
| 445 | 445 | ORDER BY distance"; |
| 446 | 446 | |
| 447 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 447 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 448 | 448 | |
| 449 | - return $spotter_array; |
|
| 450 | - } |
|
| 449 | + return $spotter_array; |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | 452 | |
| 453 | - /** |
|
| 454 | - * Gets all the spotter information based on a particular callsign |
|
| 455 | - * |
|
| 456 | - * @return Array the spotter information |
|
| 457 | - * |
|
| 458 | - */ |
|
| 453 | + /** |
|
| 454 | + * Gets all the spotter information based on a particular callsign |
|
| 455 | + * |
|
| 456 | + * @return Array the spotter information |
|
| 457 | + * |
|
| 458 | + */ |
|
| 459 | 459 | public function getLastLiveSpotterDataByIdent($ident) |
| 460 | 460 | { |
| 461 | 461 | $Spotter = new Spotter($this->db); |
| 462 | 462 | date_default_timezone_set('UTC'); |
| 463 | 463 | |
| 464 | 464 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 465 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 465 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 466 | 466 | |
| 467 | 467 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 468 | 468 | |
| 469 | 469 | return $spotter_array; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - /** |
|
| 473 | - * Gets all the spotter information based on a particular callsign |
|
| 474 | - * |
|
| 475 | - * @return Array the spotter information |
|
| 476 | - * |
|
| 477 | - */ |
|
| 472 | + /** |
|
| 473 | + * Gets all the spotter information based on a particular callsign |
|
| 474 | + * |
|
| 475 | + * @return Array the spotter information |
|
| 476 | + * |
|
| 477 | + */ |
|
| 478 | 478 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 479 | 479 | { |
| 480 | 480 | $Spotter = new Spotter($this->db); |
| 481 | 481 | date_default_timezone_set('UTC'); |
| 482 | 482 | |
| 483 | 483 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 484 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 484 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 485 | 485 | |
| 486 | - $date = date('c',$date); |
|
| 486 | + $date = date('c',$date); |
|
| 487 | 487 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 488 | 488 | |
| 489 | 489 | return $spotter_array; |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - /** |
|
| 493 | - * Gets last spotter information based on a particular callsign |
|
| 494 | - * |
|
| 495 | - * @return Array the spotter information |
|
| 496 | - * |
|
| 497 | - */ |
|
| 492 | + /** |
|
| 493 | + * Gets last spotter information based on a particular callsign |
|
| 494 | + * |
|
| 495 | + * @return Array the spotter information |
|
| 496 | + * |
|
| 497 | + */ |
|
| 498 | 498 | public function getLastLiveSpotterDataById($id) |
| 499 | 499 | { |
| 500 | 500 | $Spotter = new Spotter($this->db); |
| 501 | 501 | date_default_timezone_set('UTC'); |
| 502 | 502 | |
| 503 | 503 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 504 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 504 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 505 | 505 | |
| 506 | 506 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
| 507 | 507 | |
| 508 | 508 | return $spotter_array; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - /** |
|
| 512 | - * Gets last spotter information based on a particular callsign |
|
| 513 | - * |
|
| 514 | - * @return Array the spotter information |
|
| 515 | - * |
|
| 516 | - */ |
|
| 511 | + /** |
|
| 512 | + * Gets last spotter information based on a particular callsign |
|
| 513 | + * |
|
| 514 | + * @return Array the spotter information |
|
| 515 | + * |
|
| 516 | + */ |
|
| 517 | 517 | public function getDateLiveSpotterDataById($id,$date) |
| 518 | 518 | { |
| 519 | 519 | $Spotter = new Spotter($this->db); |
| 520 | 520 | date_default_timezone_set('UTC'); |
| 521 | 521 | |
| 522 | 522 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 523 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 524 | - $date = date('c',$date); |
|
| 523 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 524 | + $date = date('c',$date); |
|
| 525 | 525 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 526 | 526 | |
| 527 | 527 | return $spotter_array; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - /** |
|
| 531 | - * Gets altitude information based on a particular callsign |
|
| 532 | - * |
|
| 533 | - * @return Array the spotter information |
|
| 534 | - * |
|
| 535 | - */ |
|
| 530 | + /** |
|
| 531 | + * Gets altitude information based on a particular callsign |
|
| 532 | + * |
|
| 533 | + * @return Array the spotter information |
|
| 534 | + * |
|
| 535 | + */ |
|
| 536 | 536 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 537 | 537 | { |
| 538 | 538 | |
| 539 | 539 | date_default_timezone_set('UTC'); |
| 540 | 540 | |
| 541 | 541 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 542 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 542 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 543 | 543 | |
| 544 | - try { |
|
| 544 | + try { |
|
| 545 | 545 | |
| 546 | 546 | $sth = $this->db->prepare($query); |
| 547 | 547 | $sth->execute(array(':ident' => $ident)); |
@@ -554,12 +554,12 @@ discard block |
||
| 554 | 554 | return $spotter_array; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - /** |
|
| 558 | - * Gets all the spotter information based on a particular id |
|
| 559 | - * |
|
| 560 | - * @return Array the spotter information |
|
| 561 | - * |
|
| 562 | - */ |
|
| 557 | + /** |
|
| 558 | + * Gets all the spotter information based on a particular id |
|
| 559 | + * |
|
| 560 | + * @return Array the spotter information |
|
| 561 | + * |
|
| 562 | + */ |
|
| 563 | 563 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 564 | 564 | { |
| 565 | 565 | global $globalDBdriver, $globalLiveInterval; |
@@ -587,18 +587,18 @@ discard block |
||
| 587 | 587 | return $spotter_array; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - /** |
|
| 591 | - * Gets all the spotter information based on a particular ident |
|
| 592 | - * |
|
| 593 | - * @return Array the spotter information |
|
| 594 | - * |
|
| 595 | - */ |
|
| 590 | + /** |
|
| 591 | + * Gets all the spotter information based on a particular ident |
|
| 592 | + * |
|
| 593 | + * @return Array the spotter information |
|
| 594 | + * |
|
| 595 | + */ |
|
| 596 | 596 | public function getAllLiveSpotterDataByIdent($ident) |
| 597 | 597 | { |
| 598 | 598 | date_default_timezone_set('UTC'); |
| 599 | 599 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 600 | 600 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 601 | - try { |
|
| 601 | + try { |
|
| 602 | 602 | |
| 603 | 603 | $sth = $this->db->prepare($query); |
| 604 | 604 | $sth->execute(array(':ident' => $ident)); |
@@ -612,23 +612,23 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | |
| 614 | 614 | /** |
| 615 | - * Deletes all info in the table |
|
| 616 | - * |
|
| 617 | - * @return String success or false |
|
| 618 | - * |
|
| 619 | - */ |
|
| 615 | + * Deletes all info in the table |
|
| 616 | + * |
|
| 617 | + * @return String success or false |
|
| 618 | + * |
|
| 619 | + */ |
|
| 620 | 620 | public function deleteLiveSpotterData() |
| 621 | 621 | { |
| 622 | 622 | global $globalDBdriver; |
| 623 | 623 | if ($globalDBdriver == 'mysql') { |
| 624 | 624 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 625 | 625 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 626 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 626 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 627 | 627 | } else { |
| 628 | 628 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - try { |
|
| 631 | + try { |
|
| 632 | 632 | |
| 633 | 633 | $sth = $this->db->prepare($query); |
| 634 | 634 | $sth->execute(); |
@@ -640,18 +640,18 @@ discard block |
||
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | /** |
| 643 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 644 | - * |
|
| 645 | - * @return String success or false |
|
| 646 | - * |
|
| 647 | - */ |
|
| 643 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 644 | + * |
|
| 645 | + * @return String success or false |
|
| 646 | + * |
|
| 647 | + */ |
|
| 648 | 648 | public function deleteLiveSpotterDataNotUpdated() |
| 649 | 649 | { |
| 650 | 650 | global $globalDBdriver, $globalDebug; |
| 651 | 651 | if ($globalDBdriver == 'mysql') { |
| 652 | 652 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
| 653 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
| 654 | - try { |
|
| 653 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
| 654 | + try { |
|
| 655 | 655 | |
| 656 | 656 | $sth = $this->db->prepare($query); |
| 657 | 657 | $sth->execute(); |
@@ -659,8 +659,8 @@ discard block |
||
| 659 | 659 | return "error"; |
| 660 | 660 | } |
| 661 | 661 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 662 | - $i = 0; |
|
| 663 | - $j =0; |
|
| 662 | + $i = 0; |
|
| 663 | + $j =0; |
|
| 664 | 664 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 665 | 665 | foreach($all as $row) |
| 666 | 666 | { |
@@ -668,20 +668,20 @@ discard block |
||
| 668 | 668 | $j++; |
| 669 | 669 | if ($j == 30) { |
| 670 | 670 | if ($globalDebug) echo "."; |
| 671 | - try { |
|
| 671 | + try { |
|
| 672 | 672 | |
| 673 | 673 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 674 | 674 | $sth->execute(); |
| 675 | 675 | } catch(PDOException $e) { |
| 676 | 676 | return "error"; |
| 677 | 677 | } |
| 678 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 679 | - $j = 0; |
|
| 678 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 679 | + $j = 0; |
|
| 680 | 680 | } |
| 681 | 681 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 682 | 682 | } |
| 683 | 683 | if ($i > 0) { |
| 684 | - try { |
|
| 684 | + try { |
|
| 685 | 685 | |
| 686 | 686 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 687 | 687 | $sth->execute(); |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | return "success"; |
| 693 | 693 | } elseif ($globalDBdriver == 'pgsql') { |
| 694 | 694 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
| 695 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 696 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
| 697 | - try { |
|
| 695 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 696 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
| 697 | + try { |
|
| 698 | 698 | |
| 699 | 699 | $sth = $this->db->prepare($query); |
| 700 | 700 | $sth->execute(); |
@@ -738,17 +738,17 @@ discard block |
||
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
| 741 | - * Deletes all info in the table for an ident |
|
| 742 | - * |
|
| 743 | - * @return String success or false |
|
| 744 | - * |
|
| 745 | - */ |
|
| 741 | + * Deletes all info in the table for an ident |
|
| 742 | + * |
|
| 743 | + * @return String success or false |
|
| 744 | + * |
|
| 745 | + */ |
|
| 746 | 746 | public function deleteLiveSpotterDataByIdent($ident) |
| 747 | 747 | { |
| 748 | 748 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 749 | 749 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 750 | 750 | |
| 751 | - try { |
|
| 751 | + try { |
|
| 752 | 752 | |
| 753 | 753 | $sth = $this->db->prepare($query); |
| 754 | 754 | $sth->execute(array(':ident' => $ident)); |
@@ -760,17 +760,17 @@ discard block |
||
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
| 763 | - * Deletes all info in the table for an id |
|
| 764 | - * |
|
| 765 | - * @return String success or false |
|
| 766 | - * |
|
| 767 | - */ |
|
| 763 | + * Deletes all info in the table for an id |
|
| 764 | + * |
|
| 765 | + * @return String success or false |
|
| 766 | + * |
|
| 767 | + */ |
|
| 768 | 768 | public function deleteLiveSpotterDataById($id) |
| 769 | 769 | { |
| 770 | 770 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 771 | 771 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 772 | 772 | |
| 773 | - try { |
|
| 773 | + try { |
|
| 774 | 774 | |
| 775 | 775 | $sth = $this->db->prepare($query); |
| 776 | 776 | $sth->execute(array(':id' => $id)); |
@@ -783,11 +783,11 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | |
| 785 | 785 | /** |
| 786 | - * Gets the aircraft ident within the last hour |
|
| 787 | - * |
|
| 788 | - * @return String the ident |
|
| 789 | - * |
|
| 790 | - */ |
|
| 786 | + * Gets the aircraft ident within the last hour |
|
| 787 | + * |
|
| 788 | + * @return String the ident |
|
| 789 | + * |
|
| 790 | + */ |
|
| 791 | 791 | public function getIdentFromLastHour($ident) |
| 792 | 792 | { |
| 793 | 793 | global $globalDBdriver, $globalTimezone; |
@@ -813,14 +813,14 @@ discard block |
||
| 813 | 813 | $ident_result = $row['ident']; |
| 814 | 814 | } |
| 815 | 815 | return $ident_result; |
| 816 | - } |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | 818 | /** |
| 819 | - * Check recent aircraft |
|
| 820 | - * |
|
| 821 | - * @return String the ident |
|
| 822 | - * |
|
| 823 | - */ |
|
| 819 | + * Check recent aircraft |
|
| 820 | + * |
|
| 821 | + * @return String the ident |
|
| 822 | + * |
|
| 823 | + */ |
|
| 824 | 824 | public function checkIdentRecent($ident) |
| 825 | 825 | { |
| 826 | 826 | global $globalDBdriver, $globalTimezone; |
@@ -846,14 +846,14 @@ discard block |
||
| 846 | 846 | $ident_result = $row['flightaware_id']; |
| 847 | 847 | } |
| 848 | 848 | return $ident_result; |
| 849 | - } |
|
| 849 | + } |
|
| 850 | 850 | |
| 851 | 851 | /** |
| 852 | - * Check recent aircraft by id |
|
| 853 | - * |
|
| 854 | - * @return String the ident |
|
| 855 | - * |
|
| 856 | - */ |
|
| 852 | + * Check recent aircraft by id |
|
| 853 | + * |
|
| 854 | + * @return String the ident |
|
| 855 | + * |
|
| 856 | + */ |
|
| 857 | 857 | public function checkIdRecent($id) |
| 858 | 858 | { |
| 859 | 859 | global $globalDBdriver, $globalTimezone; |
@@ -879,14 +879,14 @@ discard block |
||
| 879 | 879 | $ident_result = $row['flightaware_id']; |
| 880 | 880 | } |
| 881 | 881 | return $ident_result; |
| 882 | - } |
|
| 882 | + } |
|
| 883 | 883 | |
| 884 | 884 | /** |
| 885 | - * Check recent aircraft by ModeS |
|
| 886 | - * |
|
| 887 | - * @return String the ModeS |
|
| 888 | - * |
|
| 889 | - */ |
|
| 885 | + * Check recent aircraft by ModeS |
|
| 886 | + * |
|
| 887 | + * @return String the ModeS |
|
| 888 | + * |
|
| 889 | + */ |
|
| 890 | 890 | public function checkModeSRecent($modes) |
| 891 | 891 | { |
| 892 | 892 | global $globalDBdriver, $globalTimezone; |
@@ -913,19 +913,19 @@ discard block |
||
| 913 | 913 | $ident_result = $row['flightaware_id']; |
| 914 | 914 | } |
| 915 | 915 | return $ident_result; |
| 916 | - } |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | 918 | /** |
| 919 | - * Adds a new spotter data |
|
| 920 | - * |
|
| 921 | - * @param String $flightaware_id the ID from flightaware |
|
| 922 | - * @param String $ident the flight ident |
|
| 923 | - * @param String $aircraft_icao the aircraft type |
|
| 924 | - * @param String $departure_airport_icao the departure airport |
|
| 925 | - * @param String $arrival_airport_icao the arrival airport |
|
| 926 | - * @return String success or false |
|
| 927 | - * |
|
| 928 | - */ |
|
| 919 | + * Adds a new spotter data |
|
| 920 | + * |
|
| 921 | + * @param String $flightaware_id the ID from flightaware |
|
| 922 | + * @param String $ident the flight ident |
|
| 923 | + * @param String $aircraft_icao the aircraft type |
|
| 924 | + * @param String $departure_airport_icao the departure airport |
|
| 925 | + * @param String $arrival_airport_icao the arrival airport |
|
| 926 | + * @return String success or false |
|
| 927 | + * |
|
| 928 | + */ |
|
| 929 | 929 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
| 930 | 930 | { |
| 931 | 931 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1060,10 +1060,10 @@ discard block |
||
| 1060 | 1060 | $arrival_airport_country = ''; |
| 1061 | 1061 | |
| 1062 | 1062 | |
| 1063 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1064 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1065 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1066 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1063 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1064 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1065 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1066 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1067 | 1067 | |
| 1068 | 1068 | $query = ''; |
| 1069 | 1069 | if ($globalArchive) { |
@@ -1083,10 +1083,10 @@ discard block |
||
| 1083 | 1083 | return "error : ".$e->getMessage(); |
| 1084 | 1084 | } |
| 1085 | 1085 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1086 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1087 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1088 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1089 | - if ($globalDebug) echo $result.')'; |
|
| 1086 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1087 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1088 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1089 | + if ($globalDebug) echo $result.')'; |
|
| 1090 | 1090 | } |
| 1091 | 1091 | return "success"; |
| 1092 | 1092 | |
@@ -16,62 +16,62 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 37 | 37 | if ($flt['airlines'][0] != '') { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 46 | 46 | if (isset($flt['source'])) { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 48 | 48 | } else { |
| 49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 53 | 53 | if (isset($flt['source'])) { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 55 | 55 | } else { |
| 56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 60 | 60 | if (isset($flt['source'])) { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 62 | 62 | } else { |
| 63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 67 | 67 | if (isset($flt['source'])) { |
| 68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 73 | 73 | if ($filter['airlines'][0] != '') { |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 82 | 82 | } |
| 83 | 83 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 84 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 84 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 85 | 85 | } |
| 86 | 86 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 88 | 88 | } |
| 89 | 89 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 90 | 90 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 116 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 117 | 117 | } |
| 118 | 118 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 119 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 119 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 120 | 120 | } |
| 121 | 121 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 122 | 122 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 123 | 123 | if ($filter_query_where != '') { |
| 124 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 124 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 125 | 125 | } |
| 126 | 126 | $filter_query = $filter_query_join.$filter_query_where; |
| 127 | 127 | return $filter_query; |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | if ($limit != '') |
| 145 | 145 | { |
| 146 | 146 | $limit_array = explode(',', $limit); |
| 147 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 147 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 149 | 149 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 150 | 150 | { |
| 151 | 151 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | } else { |
| 169 | 169 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
| 170 | 170 | } |
| 171 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 171 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 172 | 172 | |
| 173 | 173 | return $spotter_array; |
| 174 | 174 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | global $globalDBdriver, $globalLiveInterval; |
| 185 | 185 | date_default_timezone_set('UTC'); |
| 186 | 186 | |
| 187 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 187 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 188 | 188 | |
| 189 | 189 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 190 | 190 | if ($globalDBdriver == 'mysql') { |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 196 | 196 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
| 197 | 197 | */ |
| 198 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 198 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 199 | 199 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
| 200 | 200 | |
| 201 | 201 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 211 | 211 | */ |
| 212 | 212 | |
| 213 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 213 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 214 | 214 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 215 | 215 | |
| 216 | 216 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | try { |
| 222 | 222 | $sth = $this->db->prepare($query); |
| 223 | 223 | $sth->execute(); |
| 224 | - } catch(PDOException $e) { |
|
| 224 | + } catch (PDOException $e) { |
|
| 225 | 225 | echo $e->getMessage(); |
| 226 | 226 | die; |
| 227 | 227 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | global $globalDBdriver, $globalLiveInterval; |
| 242 | 242 | date_default_timezone_set('UTC'); |
| 243 | 243 | |
| 244 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 244 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 245 | 245 | |
| 246 | 246 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 247 | 247 | if ($globalDBdriver == 'mysql') { |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 251 | 251 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 252 | 252 | */ |
| 253 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 253 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 254 | 254 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 255 | 255 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 256 | 256 | } else { |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 260 | 260 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 261 | 261 | */ |
| 262 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 262 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 263 | 263 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 264 | 264 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 265 | 265 | // echo $query; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | try { |
| 269 | 269 | $sth = $this->db->prepare($query); |
| 270 | 270 | $sth->execute(); |
| 271 | - } catch(PDOException $e) { |
|
| 271 | + } catch (PDOException $e) { |
|
| 272 | 272 | echo $e->getMessage(); |
| 273 | 273 | die; |
| 274 | 274 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | public function getLiveSpotterCount($filter = array()) |
| 286 | 286 | { |
| 287 | 287 | global $globalDBdriver, $globalLiveInterval; |
| 288 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 288 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 289 | 289 | |
| 290 | 290 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 291 | 291 | if ($globalDBdriver == 'mysql') { |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | try { |
| 299 | 299 | $sth = $this->db->prepare($query); |
| 300 | 300 | $sth->execute(); |
| 301 | - } catch(PDOException $e) { |
|
| 301 | + } catch (PDOException $e) { |
|
| 302 | 302 | echo $e->getMessage(); |
| 303 | 303 | die; |
| 304 | 304 | } |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | $filter_query = $this->getFilter($filter); |
| 322 | 322 | |
| 323 | 323 | if (is_array($coord)) { |
| 324 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 325 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 326 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 327 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 324 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 325 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 326 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 327 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 328 | 328 | } else return array(); |
| 329 | 329 | if ($globalDBdriver == 'mysql') { |
| 330 | 330 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | global $globalDBdriver, $globalLiveInterval; |
| 348 | 348 | $Spotter = new Spotter($this->db); |
| 349 | 349 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 350 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 350 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 351 | 351 | |
| 352 | 352 | if (is_array($coord)) { |
| 353 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 354 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 355 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 356 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 353 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 354 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 355 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 356 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 357 | 357 | } else return array(); |
| 358 | 358 | if ($globalDBdriver == 'mysql') { |
| 359 | 359 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | ) s on spotter_live.flightaware_id = s.flightaware_id |
| 367 | 367 | AND spotter_live.date = s.maxdate'.$filter_query.' spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
| 368 | 368 | } else { |
| 369 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 369 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 370 | 370 | FROM spotter_live |
| 371 | 371 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 372 | 372 | FROM spotter_live l |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | try { |
| 381 | 381 | $sth = $this->db->prepare($query); |
| 382 | 382 | $sth->execute(); |
| 383 | - } catch(PDOException $e) { |
|
| 383 | + } catch (PDOException $e) { |
|
| 384 | 384 | echo $e->getMessage(); |
| 385 | 385 | die; |
| 386 | 386 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | if ($interval == '1m') |
| 430 | 430 | { |
| 431 | 431 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 432 | - } else if ($interval == '15m'){ |
|
| 432 | + } else if ($interval == '15m') { |
|
| 433 | 433 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 434 | 434 | } |
| 435 | 435 | } |
@@ -437,14 +437,14 @@ discard block |
||
| 437 | 437 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 440 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 441 | 441 | WHERE spotter_live.latitude <> '' |
| 442 | 442 | AND spotter_live.longitude <> '' |
| 443 | 443 | ".$additional_query." |
| 444 | 444 | HAVING distance < :radius |
| 445 | 445 | ORDER BY distance"; |
| 446 | 446 | |
| 447 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 447 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 448 | 448 | |
| 449 | 449 | return $spotter_array; |
| 450 | 450 | } |
@@ -462,9 +462,9 @@ discard block |
||
| 462 | 462 | date_default_timezone_set('UTC'); |
| 463 | 463 | |
| 464 | 464 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 465 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 465 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 466 | 466 | |
| 467 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 467 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 468 | 468 | |
| 469 | 469 | return $spotter_array; |
| 470 | 470 | } |
@@ -475,16 +475,16 @@ discard block |
||
| 475 | 475 | * @return Array the spotter information |
| 476 | 476 | * |
| 477 | 477 | */ |
| 478 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 478 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 479 | 479 | { |
| 480 | 480 | $Spotter = new Spotter($this->db); |
| 481 | 481 | date_default_timezone_set('UTC'); |
| 482 | 482 | |
| 483 | 483 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 484 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 484 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 485 | 485 | |
| 486 | - $date = date('c',$date); |
|
| 487 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 486 | + $date = date('c', $date); |
|
| 487 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 488 | 488 | |
| 489 | 489 | return $spotter_array; |
| 490 | 490 | } |
@@ -501,9 +501,9 @@ discard block |
||
| 501 | 501 | date_default_timezone_set('UTC'); |
| 502 | 502 | |
| 503 | 503 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 504 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 504 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 505 | 505 | |
| 506 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 506 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 507 | 507 | |
| 508 | 508 | return $spotter_array; |
| 509 | 509 | } |
@@ -514,15 +514,15 @@ discard block |
||
| 514 | 514 | * @return Array the spotter information |
| 515 | 515 | * |
| 516 | 516 | */ |
| 517 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 517 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 518 | 518 | { |
| 519 | 519 | $Spotter = new Spotter($this->db); |
| 520 | 520 | date_default_timezone_set('UTC'); |
| 521 | 521 | |
| 522 | 522 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 523 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 524 | - $date = date('c',$date); |
|
| 525 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 523 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 524 | + $date = date('c', $date); |
|
| 525 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 526 | 526 | |
| 527 | 527 | return $spotter_array; |
| 528 | 528 | } |
@@ -539,13 +539,13 @@ discard block |
||
| 539 | 539 | date_default_timezone_set('UTC'); |
| 540 | 540 | |
| 541 | 541 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 542 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 542 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 543 | 543 | |
| 544 | 544 | try { |
| 545 | 545 | |
| 546 | 546 | $sth = $this->db->prepare($query); |
| 547 | 547 | $sth->execute(array(':ident' => $ident)); |
| 548 | - } catch(PDOException $e) { |
|
| 548 | + } catch (PDOException $e) { |
|
| 549 | 549 | echo $e->getMessage(); |
| 550 | 550 | die; |
| 551 | 551 | } |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | * @return Array the spotter information |
| 561 | 561 | * |
| 562 | 562 | */ |
| 563 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 563 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 564 | 564 | { |
| 565 | 565 | global $globalDBdriver, $globalLiveInterval; |
| 566 | 566 | date_default_timezone_set('UTC'); |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | try { |
| 580 | 580 | $sth = $this->db->prepare($query); |
| 581 | 581 | $sth->execute(array(':id' => $id)); |
| 582 | - } catch(PDOException $e) { |
|
| 582 | + } catch (PDOException $e) { |
|
| 583 | 583 | echo $e->getMessage(); |
| 584 | 584 | die; |
| 585 | 585 | } |
@@ -597,12 +597,12 @@ discard block |
||
| 597 | 597 | { |
| 598 | 598 | date_default_timezone_set('UTC'); |
| 599 | 599 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 600 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 600 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 601 | 601 | try { |
| 602 | 602 | |
| 603 | 603 | $sth = $this->db->prepare($query); |
| 604 | 604 | $sth->execute(array(':ident' => $ident)); |
| 605 | - } catch(PDOException $e) { |
|
| 605 | + } catch (PDOException $e) { |
|
| 606 | 606 | echo $e->getMessage(); |
| 607 | 607 | die; |
| 608 | 608 | } |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | |
| 633 | 633 | $sth = $this->db->prepare($query); |
| 634 | 634 | $sth->execute(); |
| 635 | - } catch(PDOException $e) { |
|
| 635 | + } catch (PDOException $e) { |
|
| 636 | 636 | return "error"; |
| 637 | 637 | } |
| 638 | 638 | |
@@ -655,14 +655,14 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | $sth = $this->db->prepare($query); |
| 657 | 657 | $sth->execute(); |
| 658 | - } catch(PDOException $e) { |
|
| 658 | + } catch (PDOException $e) { |
|
| 659 | 659 | return "error"; |
| 660 | 660 | } |
| 661 | 661 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 662 | 662 | $i = 0; |
| 663 | - $j =0; |
|
| 663 | + $j = 0; |
|
| 664 | 664 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 665 | - foreach($all as $row) |
|
| 665 | + foreach ($all as $row) |
|
| 666 | 666 | { |
| 667 | 667 | $i++; |
| 668 | 668 | $j++; |
@@ -670,9 +670,9 @@ discard block |
||
| 670 | 670 | if ($globalDebug) echo "."; |
| 671 | 671 | try { |
| 672 | 672 | |
| 673 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 673 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 674 | 674 | $sth->execute(); |
| 675 | - } catch(PDOException $e) { |
|
| 675 | + } catch (PDOException $e) { |
|
| 676 | 676 | return "error"; |
| 677 | 677 | } |
| 678 | 678 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -683,9 +683,9 @@ discard block |
||
| 683 | 683 | if ($i > 0) { |
| 684 | 684 | try { |
| 685 | 685 | |
| 686 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 686 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 687 | 687 | $sth->execute(); |
| 688 | - } catch(PDOException $e) { |
|
| 688 | + } catch (PDOException $e) { |
|
| 689 | 689 | return "error"; |
| 690 | 690 | } |
| 691 | 691 | } |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | $sth = $this->db->prepare($query); |
| 700 | 700 | $sth->execute(); |
| 701 | - } catch(PDOException $e) { |
|
| 701 | + } catch (PDOException $e) { |
|
| 702 | 702 | return "error"; |
| 703 | 703 | } |
| 704 | 704 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -746,13 +746,13 @@ discard block |
||
| 746 | 746 | public function deleteLiveSpotterDataByIdent($ident) |
| 747 | 747 | { |
| 748 | 748 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 749 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 749 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 750 | 750 | |
| 751 | 751 | try { |
| 752 | 752 | |
| 753 | 753 | $sth = $this->db->prepare($query); |
| 754 | 754 | $sth->execute(array(':ident' => $ident)); |
| 755 | - } catch(PDOException $e) { |
|
| 755 | + } catch (PDOException $e) { |
|
| 756 | 756 | return "error"; |
| 757 | 757 | } |
| 758 | 758 | |
@@ -768,13 +768,13 @@ discard block |
||
| 768 | 768 | public function deleteLiveSpotterDataById($id) |
| 769 | 769 | { |
| 770 | 770 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 771 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 771 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 772 | 772 | |
| 773 | 773 | try { |
| 774 | 774 | |
| 775 | 775 | $sth = $this->db->prepare($query); |
| 776 | 776 | $sth->execute(array(':id' => $id)); |
| 777 | - } catch(PDOException $e) { |
|
| 777 | + } catch (PDOException $e) { |
|
| 778 | 778 | return "error"; |
| 779 | 779 | } |
| 780 | 780 | |
@@ -792,13 +792,13 @@ discard block |
||
| 792 | 792 | { |
| 793 | 793 | global $globalDBdriver, $globalTimezone; |
| 794 | 794 | if ($globalDBdriver == 'mysql') { |
| 795 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 795 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 796 | 796 | WHERE spotter_live.ident = :ident |
| 797 | 797 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 798 | 798 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 799 | 799 | $query_data = array(':ident' => $ident); |
| 800 | 800 | } else { |
| 801 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 801 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 802 | 802 | WHERE spotter_live.ident = :ident |
| 803 | 803 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 804 | 804 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -807,8 +807,8 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | $sth = $this->db->prepare($query); |
| 809 | 809 | $sth->execute($query_data); |
| 810 | - $ident_result=''; |
|
| 811 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 810 | + $ident_result = ''; |
|
| 811 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 812 | 812 | { |
| 813 | 813 | $ident_result = $row['ident']; |
| 814 | 814 | } |
@@ -825,13 +825,13 @@ discard block |
||
| 825 | 825 | { |
| 826 | 826 | global $globalDBdriver, $globalTimezone; |
| 827 | 827 | if ($globalDBdriver == 'mysql') { |
| 828 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 828 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 829 | 829 | WHERE spotter_live.ident = :ident |
| 830 | 830 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 831 | 831 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 832 | 832 | $query_data = array(':ident' => $ident); |
| 833 | 833 | } else { |
| 834 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 834 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 835 | 835 | WHERE spotter_live.ident = :ident |
| 836 | 836 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 837 | 837 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -840,8 +840,8 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | $sth = $this->db->prepare($query); |
| 842 | 842 | $sth->execute($query_data); |
| 843 | - $ident_result=''; |
|
| 844 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 843 | + $ident_result = ''; |
|
| 844 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 845 | 845 | { |
| 846 | 846 | $ident_result = $row['flightaware_id']; |
| 847 | 847 | } |
@@ -858,13 +858,13 @@ discard block |
||
| 858 | 858 | { |
| 859 | 859 | global $globalDBdriver, $globalTimezone; |
| 860 | 860 | if ($globalDBdriver == 'mysql') { |
| 861 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 861 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 862 | 862 | WHERE spotter_live.flightaware_id = :id |
| 863 | 863 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 864 | 864 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 865 | 865 | $query_data = array(':id' => $id); |
| 866 | 866 | } else { |
| 867 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 867 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 868 | 868 | WHERE spotter_live.flightaware_id = :id |
| 869 | 869 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 870 | 870 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -873,8 +873,8 @@ discard block |
||
| 873 | 873 | |
| 874 | 874 | $sth = $this->db->prepare($query); |
| 875 | 875 | $sth->execute($query_data); |
| 876 | - $ident_result=''; |
|
| 877 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 876 | + $ident_result = ''; |
|
| 877 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 878 | 878 | { |
| 879 | 879 | $ident_result = $row['flightaware_id']; |
| 880 | 880 | } |
@@ -891,13 +891,13 @@ discard block |
||
| 891 | 891 | { |
| 892 | 892 | global $globalDBdriver, $globalTimezone; |
| 893 | 893 | if ($globalDBdriver == 'mysql') { |
| 894 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 894 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 895 | 895 | WHERE spotter_live.ModeS = :modes |
| 896 | 896 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 897 | 897 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 898 | 898 | $query_data = array(':modes' => $modes); |
| 899 | 899 | } else { |
| 900 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 900 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 901 | 901 | WHERE spotter_live.ModeS = :modes |
| 902 | 902 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
| 903 | 903 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -906,8 +906,8 @@ discard block |
||
| 906 | 906 | |
| 907 | 907 | $sth = $this->db->prepare($query); |
| 908 | 908 | $sth->execute($query_data); |
| 909 | - $ident_result=''; |
|
| 910 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 909 | + $ident_result = ''; |
|
| 910 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 911 | 911 | { |
| 912 | 912 | //$ident_result = $row['spotter_live_id']; |
| 913 | 913 | $ident_result = $row['flightaware_id']; |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | * @return String success or false |
| 927 | 927 | * |
| 928 | 928 | */ |
| 929 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 929 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 930 | 930 | { |
| 931 | 931 | global $globalURL, $globalArchive, $globalDebug; |
| 932 | 932 | $Common = new Common(); |
@@ -1019,26 +1019,26 @@ discard block |
||
| 1019 | 1019 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1020 | 1020 | |
| 1021 | 1021 | |
| 1022 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1023 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1024 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1025 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1026 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1027 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1028 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1029 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1030 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1031 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1032 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1033 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1034 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1035 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1036 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1037 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1038 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1039 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1040 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1041 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1022 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1023 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1024 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1025 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1026 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1027 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1028 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1029 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1030 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1031 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1032 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1033 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1034 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1035 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1036 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1037 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1038 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1039 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1040 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1041 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | 1042 | |
| 1043 | 1043 | $airline_name = ''; |
| 1044 | 1044 | $airline_icao = ''; |
@@ -1060,10 +1060,10 @@ discard block |
||
| 1060 | 1060 | $arrival_airport_country = ''; |
| 1061 | 1061 | |
| 1062 | 1062 | |
| 1063 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1064 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1065 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1066 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1063 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1064 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1065 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1066 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1067 | 1067 | |
| 1068 | 1068 | $query = ''; |
| 1069 | 1069 | if ($globalArchive) { |
@@ -1074,18 +1074,18 @@ discard block |
||
| 1074 | 1074 | $query .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
| 1075 | 1075 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
| 1076 | 1076 | |
| 1077 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
| 1077 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
| 1078 | 1078 | try { |
| 1079 | 1079 | |
| 1080 | 1080 | $sth = $this->db->prepare($query); |
| 1081 | 1081 | $sth->execute($query_values); |
| 1082 | - } catch(PDOException $e) { |
|
| 1082 | + } catch (PDOException $e) { |
|
| 1083 | 1083 | return "error : ".$e->getMessage(); |
| 1084 | 1084 | } |
| 1085 | 1085 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1086 | 1086 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 1087 | 1087 | $SpotterArchive = new SpotterArchive($this->db); |
| 1088 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1088 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 1089 | 1089 | if ($globalDebug) echo $result.')'; |
| 1090 | 1090 | } |
| 1091 | 1091 | return "success"; |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | |
| 1095 | 1095 | public function getOrderBy() |
| 1096 | 1096 | { |
| 1097 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1097 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1098 | 1098 | return $orderby; |
| 1099 | 1099 | } |
| 1100 | 1100 | |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -118,8 +120,11 @@ discard block |
||
| 118 | 120 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 119 | 121 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 120 | 122 | } |
| 121 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 122 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 123 | + if ($filter_query_where == '' && $where) { |
|
| 124 | + $filter_query_where = ' WHERE'; |
|
| 125 | + } elseif ($filter_query_where != '' && $and) { |
|
| 126 | + $filter_query_where .= ' AND'; |
|
| 127 | + } |
|
| 123 | 128 | if ($filter_query_where != '') { |
| 124 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 125 | 130 | } |
@@ -161,7 +166,9 @@ discard block |
||
| 161 | 166 | } |
| 162 | 167 | } |
| 163 | 168 | |
| 164 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 169 | + if (!isset($globalLiveInterval)) { |
|
| 170 | + $globalLiveInterval = '200'; |
|
| 171 | + } |
|
| 165 | 172 | if ($globalDBdriver == 'mysql') { |
| 166 | 173 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 167 | 174 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -186,7 +193,9 @@ discard block |
||
| 186 | 193 | |
| 187 | 194 | $filter_query = $this->getFilter($filter,true,true); |
| 188 | 195 | |
| 189 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 196 | + if (!isset($globalLiveInterval)) { |
|
| 197 | + $globalLiveInterval = '200'; |
|
| 198 | + } |
|
| 190 | 199 | if ($globalDBdriver == 'mysql') { |
| 191 | 200 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
| 192 | 201 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -243,7 +252,9 @@ discard block |
||
| 243 | 252 | |
| 244 | 253 | $filter_query = $this->getFilter($filter,true,true); |
| 245 | 254 | |
| 246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 255 | + if (!isset($globalLiveInterval)) { |
|
| 256 | + $globalLiveInterval = '200'; |
|
| 257 | + } |
|
| 247 | 258 | if ($globalDBdriver == 'mysql') { |
| 248 | 259 | /* |
| 249 | 260 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -287,7 +298,9 @@ discard block |
||
| 287 | 298 | global $globalDBdriver, $globalLiveInterval; |
| 288 | 299 | $filter_query = $this->getFilter($filter,true,true); |
| 289 | 300 | |
| 290 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 301 | + if (!isset($globalLiveInterval)) { |
|
| 302 | + $globalLiveInterval = '200'; |
|
| 303 | + } |
|
| 291 | 304 | if ($globalDBdriver == 'mysql') { |
| 292 | 305 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 293 | 306 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -317,7 +330,9 @@ discard block |
||
| 317 | 330 | { |
| 318 | 331 | global $globalDBdriver, $globalLiveInterval; |
| 319 | 332 | $Spotter = new Spotter($this->db); |
| 320 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 333 | + if (!isset($globalLiveInterval)) { |
|
| 334 | + $globalLiveInterval = '200'; |
|
| 335 | + } |
|
| 321 | 336 | $filter_query = $this->getFilter($filter); |
| 322 | 337 | |
| 323 | 338 | if (is_array($coord)) { |
@@ -325,7 +340,9 @@ discard block |
||
| 325 | 340 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 326 | 341 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 327 | 342 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 328 | - } else return array(); |
|
| 343 | + } else { |
|
| 344 | + return array(); |
|
| 345 | + } |
|
| 329 | 346 | if ($globalDBdriver == 'mysql') { |
| 330 | 347 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 331 | 348 | } else { |
@@ -346,7 +363,9 @@ discard block |
||
| 346 | 363 | { |
| 347 | 364 | global $globalDBdriver, $globalLiveInterval; |
| 348 | 365 | $Spotter = new Spotter($this->db); |
| 349 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 366 | + if (!isset($globalLiveInterval)) { |
|
| 367 | + $globalLiveInterval = '200'; |
|
| 368 | + } |
|
| 350 | 369 | $filter_query = $this->getFilter($filter,true,true); |
| 351 | 370 | |
| 352 | 371 | if (is_array($coord)) { |
@@ -354,7 +373,9 @@ discard block |
||
| 354 | 373 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 355 | 374 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 356 | 375 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 357 | - } else return array(); |
|
| 376 | + } else { |
|
| 377 | + return array(); |
|
| 378 | + } |
|
| 358 | 379 | if ($globalDBdriver == 'mysql') { |
| 359 | 380 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 360 | 381 | FROM spotter_live |
@@ -568,11 +589,15 @@ discard block |
||
| 568 | 589 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 569 | 590 | if ($globalDBdriver == 'mysql') { |
| 570 | 591 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 571 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 592 | + if ($liveinterval) { |
|
| 593 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 594 | + } |
|
| 572 | 595 | $query .= ' ORDER BY date'; |
| 573 | 596 | } else { |
| 574 | 597 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 575 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 598 | + if ($liveinterval) { |
|
| 599 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 600 | + } |
|
| 576 | 601 | $query .= ' ORDER BY date'; |
| 577 | 602 | } |
| 578 | 603 | |
@@ -667,7 +692,9 @@ discard block |
||
| 667 | 692 | $i++; |
| 668 | 693 | $j++; |
| 669 | 694 | if ($j == 30) { |
| 670 | - if ($globalDebug) echo "."; |
|
| 695 | + if ($globalDebug) { |
|
| 696 | + echo "."; |
|
| 697 | + } |
|
| 671 | 698 | try { |
| 672 | 699 | |
| 673 | 700 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -974,7 +1001,9 @@ discard block |
||
| 974 | 1001 | { |
| 975 | 1002 | return false; |
| 976 | 1003 | } |
| 977 | - } else return ''; |
|
| 1004 | + } else { |
|
| 1005 | + return ''; |
|
| 1006 | + } |
|
| 978 | 1007 | |
| 979 | 1008 | if ($longitude != '') |
| 980 | 1009 | { |
@@ -982,7 +1011,9 @@ discard block |
||
| 982 | 1011 | { |
| 983 | 1012 | return false; |
| 984 | 1013 | } |
| 985 | - } else return ''; |
|
| 1014 | + } else { |
|
| 1015 | + return ''; |
|
| 1016 | + } |
|
| 986 | 1017 | |
| 987 | 1018 | if ($waypoints != '') |
| 988 | 1019 | { |
@@ -998,7 +1029,9 @@ discard block |
||
| 998 | 1029 | { |
| 999 | 1030 | return false; |
| 1000 | 1031 | } |
| 1001 | - } else $altitude = 0; |
|
| 1032 | + } else { |
|
| 1033 | + $altitude = 0; |
|
| 1034 | + } |
|
| 1002 | 1035 | |
| 1003 | 1036 | if ($heading != '') |
| 1004 | 1037 | { |
@@ -1006,7 +1039,9 @@ discard block |
||
| 1006 | 1039 | { |
| 1007 | 1040 | return false; |
| 1008 | 1041 | } |
| 1009 | - } else $heading = 0; |
|
| 1042 | + } else { |
|
| 1043 | + $heading = 0; |
|
| 1044 | + } |
|
| 1010 | 1045 | |
| 1011 | 1046 | if ($groundspeed != '') |
| 1012 | 1047 | { |
@@ -1014,9 +1049,13 @@ discard block |
||
| 1014 | 1049 | { |
| 1015 | 1050 | return false; |
| 1016 | 1051 | } |
| 1017 | - } else $groundspeed = 0; |
|
| 1052 | + } else { |
|
| 1053 | + $groundspeed = 0; |
|
| 1054 | + } |
|
| 1018 | 1055 | date_default_timezone_set('UTC'); |
| 1019 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1056 | + if ($date == '') { |
|
| 1057 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1058 | + } |
|
| 1020 | 1059 | |
| 1021 | 1060 | |
| 1022 | 1061 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1060,14 +1099,24 @@ discard block |
||
| 1060 | 1099 | $arrival_airport_country = ''; |
| 1061 | 1100 | |
| 1062 | 1101 | |
| 1063 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1064 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1065 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1066 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1102 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1103 | + $squawk = NULL; |
|
| 1104 | + } |
|
| 1105 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1106 | + $verticalrate = NULL; |
|
| 1107 | + } |
|
| 1108 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1109 | + $groundspeed = 0; |
|
| 1110 | + } |
|
| 1111 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1112 | + $heading = 0; |
|
| 1113 | + } |
|
| 1067 | 1114 | |
| 1068 | 1115 | $query = ''; |
| 1069 | 1116 | if ($globalArchive) { |
| 1070 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1117 | + if ($globalDebug) { |
|
| 1118 | + echo '-- Delete previous data -- '; |
|
| 1119 | + } |
|
| 1071 | 1120 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1072 | 1121 | } |
| 1073 | 1122 | |
@@ -1083,10 +1132,14 @@ discard block |
||
| 1083 | 1132 | return "error : ".$e->getMessage(); |
| 1084 | 1133 | } |
| 1085 | 1134 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1086 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1135 | + if ($globalDebug) { |
|
| 1136 | + echo '(Add to SBS archive : '; |
|
| 1137 | + } |
|
| 1087 | 1138 | $SpotterArchive = new SpotterArchive($this->db); |
| 1088 | 1139 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1089 | - if ($globalDebug) echo $result.')'; |
|
| 1140 | + if ($globalDebug) { |
|
| 1141 | + echo $result.')'; |
|
| 1142 | + } |
|
| 1090 | 1143 | } |
| 1091 | 1144 | return "success"; |
| 1092 | 1145 | |