@@ -14,6 +14,9 @@ discard block |
||
| 14 | 14 | public $dbs = array(); |
| 15 | 15 | public $latest_schema = 55; |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param string $dbname |
|
| 19 | + */ |
|
| 17 | 20 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
| 18 | 21 | global $globalNoDB; |
| 19 | 22 | if (!isset($globalNoDB) || $globalNoDB === FALSE) { |
@@ -146,6 +149,9 @@ discard block |
||
| 146 | 149 | return true; |
| 147 | 150 | } |
| 148 | 151 | |
| 152 | + /** |
|
| 153 | + * @param string $table |
|
| 154 | + */ |
|
| 149 | 155 | public function tableExists($table) |
| 150 | 156 | { |
| 151 | 157 | global $globalDBdriver; |
@@ -196,6 +202,11 @@ discard block |
||
| 196 | 202 | /* |
| 197 | 203 | * Check if index exist |
| 198 | 204 | */ |
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @param string $table |
|
| 208 | + * @param string $index |
|
| 209 | + */ |
|
| 199 | 210 | public function indexExists($table,$index) |
| 200 | 211 | { |
| 201 | 212 | global $globalDBdriver; |
@@ -238,6 +249,10 @@ discard block |
||
| 238 | 249 | return $columns; |
| 239 | 250 | } |
| 240 | 251 | |
| 252 | + /** |
|
| 253 | + * @param string $table |
|
| 254 | + * @param string $column |
|
| 255 | + */ |
|
| 241 | 256 | public function getColumnType($table,$column) { |
| 242 | 257 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 243 | 258 | $tomet = $select->getColumnMeta(0); |
@@ -248,6 +263,11 @@ discard block |
||
| 248 | 263 | * Check if a column name exist in a table |
| 249 | 264 | * @return Boolean column exist or not |
| 250 | 265 | */ |
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * @param string $table |
|
| 269 | + * @param string $name |
|
| 270 | + */ |
|
| 251 | 271 | public function checkColumnName($table,$name) |
| 252 | 272 | { |
| 253 | 273 | global $globalDBdriver, $globalDBname; |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | require_once(dirname(__FILE__).'/settings.php'); |
| 10 | 10 | |
| 11 | -class Connection{ |
|
| 11 | +class Connection { |
|
| 12 | 12 | /** @var $db PDO */ |
| 13 | 13 | public $db; |
| 14 | 14 | public $dbs = array(); |
| 15 | 15 | public $latest_schema = 55; |
| 16 | 16 | |
| 17 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
| 17 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
| 18 | 18 | global $globalNoDB; |
| 19 | 19 | if (!isset($globalNoDB) || $globalNoDB === FALSE) { |
| 20 | 20 | if ($dbc === null) { |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | if ($user === null && $pass === null) { |
| 23 | 23 | $this->createDBConnection(); |
| 24 | 24 | } else { |
| 25 | - $this->createDBConnection(null,$user,$pass); |
|
| 25 | + $this->createDBConnection(null, $user, $pass); |
|
| 26 | 26 | } |
| 27 | 27 | } else { |
| 28 | 28 | $this->createDBConnection($dbname); |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | while (true) { |
| 105 | 105 | try { |
| 106 | 106 | if ($globalDBSdriver == 'mysql') { |
| 107 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 107 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 108 | 108 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 109 | 109 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 110 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 111 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 112 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 113 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 114 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 110 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 111 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
| 112 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 113 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 114 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 115 | 115 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 116 | 116 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 117 | 117 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -121,19 +121,19 @@ discard block |
||
| 121 | 121 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
| 122 | 122 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
| 123 | 123 | } else { |
| 124 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 124 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 125 | 125 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 126 | 126 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 127 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 128 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 129 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 130 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 131 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 127 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 128 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
| 129 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 130 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 131 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 132 | 132 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 133 | 133 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
| 134 | 134 | } |
| 135 | 135 | break; |
| 136 | - } catch(PDOException $e) { |
|
| 136 | + } catch (PDOException $e) { |
|
| 137 | 137 | $i++; |
| 138 | 138 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
| 139 | 139 | //exit; |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | try { |
| 159 | 159 | //$Connection = new Connection(); |
| 160 | 160 | $results = $this->db->query($query); |
| 161 | - } catch(PDOException $e) { |
|
| 161 | + } catch (PDOException $e) { |
|
| 162 | 162 | return false; |
| 163 | 163 | } |
| 164 | - if($results->rowCount()>0) { |
|
| 164 | + if ($results->rowCount() > 0) { |
|
| 165 | 165 | return true; |
| 166 | 166 | } |
| 167 | 167 | else return false; |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | return false; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - } catch(PDOException $e) { |
|
| 187 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 186 | + } catch (PDOException $e) { |
|
| 187 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 188 | 188 | throw $e; |
| 189 | 189 | } |
| 190 | 190 | //echo 'error ! '.$e->getMessage(); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | /* |
| 197 | 197 | * Check if index exist |
| 198 | 198 | */ |
| 199 | - public function indexExists($table,$index) |
|
| 199 | + public function indexExists($table, $index) |
|
| 200 | 200 | { |
| 201 | 201 | global $globalDBdriver; |
| 202 | 202 | if ($globalDBdriver == 'mysql') { |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | try { |
| 208 | 208 | //$Connection = new Connection(); |
| 209 | 209 | $results = $this->db->query($query); |
| 210 | - } catch(PDOException $e) { |
|
| 210 | + } catch (PDOException $e) { |
|
| 211 | 211 | return false; |
| 212 | 212 | } |
| 213 | 213 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
| 214 | - if($nb[0]['nb'] > 0) { |
|
| 214 | + if ($nb[0]['nb'] > 0) { |
|
| 215 | 215 | return true; |
| 216 | 216 | } |
| 217 | 217 | else return false; |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 227 | 227 | try { |
| 228 | 228 | $results = $this->db->query($query); |
| 229 | - } catch(PDOException $e) { |
|
| 229 | + } catch (PDOException $e) { |
|
| 230 | 230 | return "error : ".$e->getMessage()."\n"; |
| 231 | 231 | } |
| 232 | 232 | $columns = array(); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | return $columns; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - public function getColumnType($table,$column) { |
|
| 241 | + public function getColumnType($table, $column) { |
|
| 242 | 242 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 243 | 243 | $tomet = $select->getColumnMeta(0); |
| 244 | 244 | return $tomet['native_type']; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * Check if a column name exist in a table |
| 249 | 249 | * @return Boolean column exist or not |
| 250 | 250 | */ |
| 251 | - public function checkColumnName($table,$name) |
|
| 251 | + public function checkColumnName($table, $name) |
|
| 252 | 252 | { |
| 253 | 253 | global $globalDBdriver, $globalDBname; |
| 254 | 254 | if ($globalDBdriver == 'mysql') { |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | try { |
| 260 | 260 | $sth = $this->db()->prepare($query); |
| 261 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
| 262 | - } catch(PDOException $e) { |
|
| 261 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
| 262 | + } catch (PDOException $e) { |
|
| 263 | 263 | echo "error : ".$e->getMessage()."\n"; |
| 264 | 264 | return false; |
| 265 | 265 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | try { |
| 300 | 300 | $sth = $this->db->prepare($query); |
| 301 | 301 | $sth->execute(); |
| 302 | - } catch(PDOException $e) { |
|
| 302 | + } catch (PDOException $e) { |
|
| 303 | 303 | return "error : ".$e->getMessage()."\n"; |
| 304 | 304 | } |
| 305 | 305 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -76,8 +76,11 @@ discard block |
||
| 76 | 76 | $globalDBSname = $globalDBname; |
| 77 | 77 | $globalDBSuser = $globalDBuser; |
| 78 | 78 | $globalDBSpass = $globalDBpass; |
| 79 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
| 80 | - else $globalDBSport = $globalDBport; |
|
| 79 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
| 80 | + $globalDBSport = 3306; |
|
| 81 | + } else { |
|
| 82 | + $globalDBSport = $globalDBport; |
|
| 83 | + } |
|
| 81 | 84 | } else { |
| 82 | 85 | $DBname = 'default'; |
| 83 | 86 | $globalDBSdriver = $globalDBdriver; |
@@ -85,8 +88,11 @@ discard block |
||
| 85 | 88 | $globalDBSname = $globalDBname; |
| 86 | 89 | $globalDBSuser = $user; |
| 87 | 90 | $globalDBSpass = $pass; |
| 88 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
| 89 | - else $globalDBSport = $globalDBport; |
|
| 91 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
| 92 | + $globalDBSport = 3306; |
|
| 93 | + } else { |
|
| 94 | + $globalDBSport = $globalDBport; |
|
| 95 | + } |
|
| 90 | 96 | } |
| 91 | 97 | } else { |
| 92 | 98 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -94,12 +100,19 @@ discard block |
||
| 94 | 100 | $globalDBSname = $globalDB[$DBname]['name']; |
| 95 | 101 | $globalDBSuser = $globalDB[$DBname]['user']; |
| 96 | 102 | $globalDBSpass = $globalDB[$DBname]['pass']; |
| 97 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
| 98 | - else $globalDBSport = 3306; |
|
| 103 | + if (isset($globalDB[$DBname]['port'])) { |
|
| 104 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
| 105 | + } else { |
|
| 106 | + $globalDBSport = 3306; |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + if ($globalDBSname == '' || $globalDBSuser == '') { |
|
| 110 | + return false; |
|
| 99 | 111 | } |
| 100 | - if ($globalDBSname == '' || $globalDBSuser == '') return false; |
|
| 101 | 112 | // Set number of try to connect to DB |
| 102 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
| 113 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
| 114 | + $globalDBretry = 5; |
|
| 115 | + } |
|
| 103 | 116 | $i = 0; |
| 104 | 117 | while (true) { |
| 105 | 118 | try { |
@@ -108,10 +121,16 @@ discard block |
||
| 108 | 121 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 109 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 110 | 123 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
| 111 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 112 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 113 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 114 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 124 | + if (!isset($globalDBTimeOut)) { |
|
| 125 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 126 | + } else { |
|
| 127 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 128 | + } |
|
| 129 | + if (!isset($globalDBPersistent)) { |
|
| 130 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 131 | + } else { |
|
| 132 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 133 | + } |
|
| 115 | 134 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 116 | 135 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 117 | 136 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -125,24 +144,36 @@ discard block |
||
| 125 | 144 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 126 | 145 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 127 | 146 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
| 128 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 129 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 130 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 131 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 147 | + if (!isset($globalDBTimeOut)) { |
|
| 148 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 149 | + } else { |
|
| 150 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 151 | + } |
|
| 152 | + if (!isset($globalDBPersistent)) { |
|
| 153 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 154 | + } else { |
|
| 155 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 156 | + } |
|
| 132 | 157 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 133 | 158 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
| 134 | 159 | } |
| 135 | 160 | break; |
| 136 | 161 | } catch(PDOException $e) { |
| 137 | 162 | $i++; |
| 138 | - if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
| 163 | + if (isset($globalDebug) && $globalDebug) { |
|
| 164 | + echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
| 165 | + } |
|
| 139 | 166 | //exit; |
| 140 | - if ($i > $globalDBretry) return false; |
|
| 167 | + if ($i > $globalDBretry) { |
|
| 168 | + return false; |
|
| 169 | + } |
|
| 141 | 170 | //return false; |
| 142 | 171 | } |
| 143 | 172 | sleep(2); |
| 144 | 173 | } |
| 145 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
| 174 | + if ($DBname === 'default') { |
|
| 175 | + $this->db = $this->dbs['default']; |
|
| 176 | + } |
|
| 146 | 177 | return true; |
| 147 | 178 | } |
| 148 | 179 | |
@@ -154,7 +185,9 @@ discard block |
||
| 154 | 185 | } else { |
| 155 | 186 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
| 156 | 187 | } |
| 157 | - if ($this->db == NULL) return false; |
|
| 188 | + if ($this->db == NULL) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 158 | 191 | try { |
| 159 | 192 | //$Connection = new Connection(); |
| 160 | 193 | $results = $this->db->query($query); |
@@ -163,22 +196,31 @@ discard block |
||
| 163 | 196 | } |
| 164 | 197 | if($results->rowCount()>0) { |
| 165 | 198 | return true; |
| 199 | + } else { |
|
| 200 | + return false; |
|
| 166 | 201 | } |
| 167 | - else return false; |
|
| 168 | 202 | } |
| 169 | 203 | |
| 170 | 204 | public function connectionExists() |
| 171 | 205 | { |
| 172 | 206 | global $globalDBCheckConnection, $globalNoDB; |
| 173 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
| 174 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 207 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
| 208 | + return true; |
|
| 209 | + } |
|
| 210 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
| 211 | + return true; |
|
| 212 | + } |
|
| 175 | 213 | $query = "SELECT 1 + 1"; |
| 176 | - if ($this->db === null) return false; |
|
| 214 | + if ($this->db === null) { |
|
| 215 | + return false; |
|
| 216 | + } |
|
| 177 | 217 | try { |
| 178 | 218 | $sum = @$this->db->query($query); |
| 179 | 219 | if ($sum instanceof \PDOStatement) { |
| 180 | 220 | $sum = $sum->fetchColumn(0); |
| 181 | - } else $sum = 0; |
|
| 221 | + } else { |
|
| 222 | + $sum = 0; |
|
| 223 | + } |
|
| 182 | 224 | if (intval($sum) !== 2) { |
| 183 | 225 | return false; |
| 184 | 226 | } |
@@ -213,8 +255,9 @@ discard block |
||
| 213 | 255 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
| 214 | 256 | if($nb[0]['nb'] > 0) { |
| 215 | 257 | return true; |
| 258 | + } else { |
|
| 259 | + return false; |
|
| 216 | 260 | } |
| 217 | - else return false; |
|
| 218 | 261 | } |
| 219 | 262 | |
| 220 | 263 | /* |
@@ -265,9 +308,12 @@ discard block |
||
| 265 | 308 | } |
| 266 | 309 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 267 | 310 | $sth->closeCursor(); |
| 268 | - if ($result['nb'] > 0) return true; |
|
| 269 | - else return false; |
|
| 270 | -/* } else { |
|
| 311 | + if ($result['nb'] > 0) { |
|
| 312 | + return true; |
|
| 313 | + } else { |
|
| 314 | + return false; |
|
| 315 | + } |
|
| 316 | + /* } else { |
|
| 271 | 317 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 272 | 318 | try { |
| 273 | 319 | $results = $this->db->query($query); |
@@ -306,7 +352,9 @@ discard block |
||
| 306 | 352 | $sth->closeCursor(); |
| 307 | 353 | return $result['value']; |
| 308 | 354 | } |
| 309 | - } else return $version; |
|
| 355 | + } else { |
|
| 356 | + return $version; |
|
| 357 | + } |
|
| 310 | 358 | } |
| 311 | 359 | |
| 312 | 360 | /* |
@@ -315,9 +363,14 @@ discard block |
||
| 315 | 363 | */ |
| 316 | 364 | public function latest() { |
| 317 | 365 | global $globalNoDB; |
| 318 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 319 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 320 | - else return false; |
|
| 366 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
| 367 | + return true; |
|
| 368 | + } |
|
| 369 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
| 370 | + return true; |
|
| 371 | + } else { |
|
| 372 | + return false; |
|
| 373 | + } |
|
| 321 | 374 | } |
| 322 | 375 | |
| 323 | 376 | } |
@@ -187,6 +187,9 @@ |
||
| 187 | 187 | return ''; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | + /** |
|
| 191 | + * @param string $type |
|
| 192 | + */ |
|
| 190 | 193 | public function deleteLocationByType($type) { |
| 191 | 194 | $query = "DELETE FROM source_location WHERE type = :type"; |
| 192 | 195 | $query_values = array(':type' => $type); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | try { |
| 28 | 28 | $sth = $this->db->prepare($query); |
| 29 | 29 | $sth->execute($query_values); |
| 30 | - } catch(PDOException $e) { |
|
| 30 | + } catch (PDOException $e) { |
|
| 31 | 31 | return "error : ".$e->getMessage(); |
| 32 | 32 | } |
| 33 | 33 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -40,20 +40,20 @@ discard block |
||
| 40 | 40 | try { |
| 41 | 41 | $sth = $this->db->prepare($query); |
| 42 | 42 | $sth->execute($query_values); |
| 43 | - } catch(PDOException $e) { |
|
| 43 | + } catch (PDOException $e) { |
|
| 44 | 44 | return "error : ".$e->getMessage(); |
| 45 | 45 | } |
| 46 | 46 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 47 | 47 | return $all; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function getLocationInfobyNameType($name,$type) { |
|
| 50 | + public function getLocationInfobyNameType($name, $type) { |
|
| 51 | 51 | $query = "SELECT * FROM source_location WHERE name = :name AND type = :type"; |
| 52 | - $query_values = array(':name' => $name,':type' => $type); |
|
| 52 | + $query_values = array(':name' => $name, ':type' => $type); |
|
| 53 | 53 | try { |
| 54 | 54 | $sth = $this->db->prepare($query); |
| 55 | 55 | $sth->execute($query_values); |
| 56 | - } catch(PDOException $e) { |
|
| 56 | + } catch (PDOException $e) { |
|
| 57 | 57 | return "error : ".$e->getMessage(); |
| 58 | 58 | } |
| 59 | 59 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | try { |
| 71 | 71 | $sth = $this->db->prepare($query); |
| 72 | 72 | $sth->execute($query_values); |
| 73 | - } catch(PDOException $e) { |
|
| 73 | + } catch (PDOException $e) { |
|
| 74 | 74 | echo "error : ".$e->getMessage(); |
| 75 | 75 | return array(); |
| 76 | 76 | } |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | public function getLocationInfoByType($type, $coord = array(), $limit = false) { |
| 82 | 82 | $query = "SELECT * FROM source_location WHERE type = :type"; |
| 83 | 83 | if (is_array($coord) && !empty($coord) && count($coord) == 4) { |
| 84 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 85 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 86 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 87 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 84 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 85 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 86 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 87 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 88 | 88 | $query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0"; |
| 89 | 89 | } |
| 90 | 90 | $query .= " ORDER BY last_seen DESC"; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | try { |
| 94 | 94 | $sth = $this->db->prepare($query); |
| 95 | 95 | $sth->execute($query_values); |
| 96 | - } catch(PDOException $e) { |
|
| 96 | + } catch (PDOException $e) { |
|
| 97 | 97 | return "error : ".$e->getMessage(); |
| 98 | 98 | } |
| 99 | 99 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | try { |
| 107 | 107 | $sth = $this->db->prepare($query); |
| 108 | 108 | $sth->execute($query_values); |
| 109 | - } catch(PDOException $e) { |
|
| 109 | + } catch (PDOException $e) { |
|
| 110 | 110 | return "error : ".$e->getMessage(); |
| 111 | 111 | } |
| 112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -119,58 +119,58 @@ discard block |
||
| 119 | 119 | try { |
| 120 | 120 | $sth = $this->db->prepare($query); |
| 121 | 121 | $sth->execute($query_values); |
| 122 | - } catch(PDOException $e) { |
|
| 122 | + } catch (PDOException $e) { |
|
| 123 | 123 | return "error : ".$e->getMessage(); |
| 124 | 124 | } |
| 125 | 125 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 126 | 126 | return $all; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
|
| 129 | + public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
| 130 | 130 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 131 | 131 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
| 132 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 132 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 133 | 133 | try { |
| 134 | 134 | $sth = $this->db->prepare($query); |
| 135 | 135 | $sth->execute($query_values); |
| 136 | - } catch(PDOException $e) { |
|
| 136 | + } catch (PDOException $e) { |
|
| 137 | 137 | echo "error : ".$e->getMessage(); |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
|
| 141 | + public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
| 142 | 142 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 143 | 143 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
| 144 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 144 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 145 | 145 | try { |
| 146 | 146 | $sth = $this->db->prepare($query); |
| 147 | 147 | $sth->execute($query_values); |
| 148 | - } catch(PDOException $e) { |
|
| 148 | + } catch (PDOException $e) { |
|
| 149 | 149 | return "error : ".$e->getMessage(); |
| 150 | 150 | } |
| 151 | 151 | return ''; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { |
|
| 154 | + public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') { |
|
| 155 | 155 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; |
| 156 | - $query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); |
|
| 156 | + $query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description); |
|
| 157 | 157 | try { |
| 158 | 158 | $sth = $this->db->prepare($query); |
| 159 | 159 | $sth->execute($query_values); |
| 160 | - } catch(PDOException $e) { |
|
| 160 | + } catch (PDOException $e) { |
|
| 161 | 161 | return "error : ".$e->getMessage(); |
| 162 | 162 | } |
| 163 | 163 | return ''; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
|
| 166 | + public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') { |
|
| 167 | 167 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 168 | 168 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
| 169 | - $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 169 | + $query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 170 | 170 | try { |
| 171 | 171 | $sth = $this->db->prepare($query); |
| 172 | 172 | $sth->execute($query_values); |
| 173 | - } catch(PDOException $e) { |
|
| 173 | + } catch (PDOException $e) { |
|
| 174 | 174 | echo "error : ".$e->getMessage(); |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | try { |
| 182 | 182 | $sth = $this->db->prepare($query); |
| 183 | 183 | $sth->execute($query_values); |
| 184 | - } catch(PDOException $e) { |
|
| 184 | + } catch (PDOException $e) { |
|
| 185 | 185 | return "error : ".$e->getMessage(); |
| 186 | 186 | } |
| 187 | 187 | return ''; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | try { |
| 194 | 194 | $sth = $this->db->prepare($query); |
| 195 | 195 | $sth->execute($query_values); |
| 196 | - } catch(PDOException $e) { |
|
| 196 | + } catch (PDOException $e) { |
|
| 197 | 197 | return "error : ".$e->getMessage(); |
| 198 | 198 | } |
| 199 | 199 | return ''; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | try { |
| 206 | 206 | $sth = $this->db->prepare($query); |
| 207 | 207 | $sth->execute($query_values); |
| 208 | - } catch(PDOException $e) { |
|
| 208 | + } catch (PDOException $e) { |
|
| 209 | 209 | return "error : ".$e->getMessage(); |
| 210 | 210 | } |
| 211 | 211 | return ''; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | try { |
| 217 | 217 | $sth = $this->db->prepare($query); |
| 218 | 218 | $sth->execute(); |
| 219 | - } catch(PDOException $e) { |
|
| 219 | + } catch (PDOException $e) { |
|
| 220 | 220 | return "error : ".$e->getMessage(); |
| 221 | 221 | } |
| 222 | 222 | return ''; |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | try { |
| 247 | 247 | $sth = $this->db->prepare($query); |
| 248 | 248 | $sth->execute(array(':type' => $type)); |
| 249 | - } catch(PDOException $e) { |
|
| 249 | + } catch (PDOException $e) { |
|
| 250 | 250 | return "error"; |
| 251 | 251 | } |
| 252 | 252 | return "success"; |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * @param $ident |
| 77 | - * @param $correct_ident |
|
| 78 | - * @param $source |
|
| 77 | + * @param string $correct_ident |
|
| 78 | + * @param string $source |
|
| 79 | 79 | * @return string |
| 80 | 80 | */ |
| 81 | 81 | public function addOperator($ident, $correct_ident, $source) { |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @param $ident |
| 94 | - * @param $correct_ident |
|
| 95 | - * @param $source |
|
| 94 | + * @param string $correct_ident |
|
| 95 | + * @param string $source |
|
| 96 | 96 | * @return string |
| 97 | 97 | */ |
| 98 | 98 | public function updateOperator($ident, $correct_ident, $source) { |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * Change IATA to ICAO value for ident |
|
| 29 | - * |
|
| 30 | - * @param string $ident ident |
|
| 31 | - * @return string the icao |
|
| 32 | - */ |
|
| 28 | + * Change IATA to ICAO value for ident |
|
| 29 | + * |
|
| 30 | + * @param string $ident ident |
|
| 31 | + * @return string the icao |
|
| 32 | + */ |
|
| 33 | 33 | public function ident2icao($ident) { |
| 34 | 34 | $Spotter = new Spotter(); |
| 35 | 35 | if (!is_numeric(substr($ident, 0, 3))) { |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | return $icao; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @param $ident |
|
| 57 | - * @return string |
|
| 58 | - */ |
|
| 59 | - public function getOperator($ident) { |
|
| 55 | + /** |
|
| 56 | + * @param $ident |
|
| 57 | + * @return string |
|
| 58 | + */ |
|
| 59 | + public function getOperator($ident) { |
|
| 60 | 60 | $query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1"; |
| 61 | 61 | $query_values = array(':ident' => $ident); |
| 62 | 62 | try { |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | } else return $ident; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @param $ident |
|
| 77 | - * @param $correct_ident |
|
| 78 | - * @param $source |
|
| 79 | - * @return string |
|
| 80 | - */ |
|
| 81 | - public function addOperator($ident, $correct_ident, $source) { |
|
| 75 | + /** |
|
| 76 | + * @param $ident |
|
| 77 | + * @param $correct_ident |
|
| 78 | + * @param $source |
|
| 79 | + * @return string |
|
| 80 | + */ |
|
| 81 | + public function addOperator($ident, $correct_ident, $source) { |
|
| 82 | 82 | $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)"; |
| 83 | 83 | $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
| 84 | 84 | try { |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * @param $ident |
|
| 94 | - * @param $correct_ident |
|
| 95 | - * @param $source |
|
| 96 | - * @return string |
|
| 97 | - */ |
|
| 98 | - public function updateOperator($ident, $correct_ident, $source) { |
|
| 92 | + /** |
|
| 93 | + * @param $ident |
|
| 94 | + * @param $correct_ident |
|
| 95 | + * @param $source |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 98 | + public function updateOperator($ident, $correct_ident, $source) { |
|
| 99 | 99 | $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident"; |
| 100 | 100 | $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
| 101 | 101 | try { |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @param $ident |
|
| 111 | - * @param bool $web |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public function checkTranslation($ident, $web = false) { |
|
| 109 | + /** |
|
| 110 | + * @param $ident |
|
| 111 | + * @param bool $web |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public function checkTranslation($ident, $web = false) { |
|
| 115 | 115 | global $globalTranslationSources, $globalTranslationFetch; |
| 116 | 116 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
| 117 | 117 | $globalTranslationSources = array(); |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | } else return $ident; |
| 42 | 42 | } else return $ident; |
| 43 | 43 | if ($airline_icao == 'AF') { |
| 44 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 45 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 44 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 45 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
| 46 | 46 | } else { |
| 47 | 47 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
| 48 | 48 | if (isset($identicao[0])) { |
| 49 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
| 49 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
| 50 | 50 | } else $icao = $ident; |
| 51 | 51 | } |
| 52 | 52 | return $icao; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | try { |
| 63 | 63 | $sth = $this->db->prepare($query); |
| 64 | 64 | $sth->execute($query_values); |
| 65 | - } catch(PDOException $e) { |
|
| 65 | + } catch (PDOException $e) { |
|
| 66 | 66 | return "error : ".$e->getMessage(); |
| 67 | 67 | } |
| 68 | 68 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function addOperator($ident, $correct_ident, $source) { |
| 82 | 82 | $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)"; |
| 83 | - $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
|
| 83 | + $query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source); |
|
| 84 | 84 | try { |
| 85 | 85 | $sth = $this->db->prepare($query); |
| 86 | 86 | $sth->execute($query_values); |
| 87 | - } catch(PDOException $e) { |
|
| 87 | + } catch (PDOException $e) { |
|
| 88 | 88 | return "error : ".$e->getMessage(); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function updateOperator($ident, $correct_ident, $source) { |
| 99 | 99 | $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident"; |
| 100 | - $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
|
| 100 | + $query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source); |
|
| 101 | 101 | try { |
| 102 | 102 | $sth = $this->db->prepare($query); |
| 103 | 103 | $sth->execute($query_values); |
| 104 | - } catch(PDOException $e) { |
|
| 104 | + } catch (PDOException $e) { |
|
| 105 | 105 | return "error : ".$e->getMessage(); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -38,16 +38,25 @@ discard block |
||
| 38 | 38 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
| 39 | 39 | //$airline_icao = substr($ident, 0, 3); |
| 40 | 40 | return $ident; |
| 41 | - } else return $ident; |
|
| 42 | - } else return $ident; |
|
| 41 | + } else { |
|
| 42 | + return $ident; |
|
| 43 | + } |
|
| 44 | + } else { |
|
| 45 | + return $ident; |
|
| 46 | + } |
|
| 43 | 47 | if ($airline_icao == 'AF') { |
| 44 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 45 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 48 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 49 | + $icao = $ident; |
|
| 50 | + } else { |
|
| 51 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 52 | + } |
|
| 46 | 53 | } else { |
| 47 | 54 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
| 48 | 55 | if (isset($identicao[0])) { |
| 49 | 56 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 50 | - } else $icao = $ident; |
|
| 57 | + } else { |
|
| 58 | + $icao = $ident; |
|
| 59 | + } |
|
| 51 | 60 | } |
| 52 | 61 | return $icao; |
| 53 | 62 | } |
@@ -69,7 +78,9 @@ discard block |
||
| 69 | 78 | $sth->closeCursor(); |
| 70 | 79 | if (isset($row['operator_correct'])) { |
| 71 | 80 | return $row['operator_correct']; |
| 72 | - } else return $ident; |
|
| 81 | + } else { |
|
| 82 | + return $ident; |
|
| 83 | + } |
|
| 73 | 84 | } |
| 74 | 85 | |
| 75 | 86 | /** |
@@ -115,7 +126,9 @@ discard block |
||
| 115 | 126 | global $globalTranslationSources, $globalTranslationFetch; |
| 116 | 127 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
| 117 | 128 | $globalTranslationSources = array(); |
| 118 | - if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
| 129 | + if (!isset($globalTranslationFetch)) { |
|
| 130 | + $globalTranslationFetch = TRUE; |
|
| 131 | + } |
|
| 119 | 132 | //echo "Check Translation for ".$ident."..."; |
| 120 | 133 | $correct = $this->getOperator($ident); |
| 121 | 134 | if ($correct != '' && $correct != $ident) { |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | if ($this->db === null) die('Error: No DB connection. (Stats)'); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function addLastStatsUpdate($type,$stats_date) { |
|
| 31 | + public function addLastStatsUpdate($type, $stats_date) { |
|
| 32 | 32 | $query = "DELETE FROM config WHERE name = :type; |
| 33 | 33 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
| 34 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
| 34 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
| 35 | 35 | try { |
| 36 | 36 | $sth = $this->db->prepare($query); |
| 37 | 37 | $sth->execute($query_values); |
| 38 | - } catch(PDOException $e) { |
|
| 38 | + } catch (PDOException $e) { |
|
| 39 | 39 | return "error : ".$e->getMessage(); |
| 40 | 40 | } |
| 41 | 41 | return ''; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | try { |
| 47 | 47 | $sth = $this->db->prepare($query); |
| 48 | 48 | $sth->execute(array(':type' => $type)); |
| 49 | - } catch(PDOException $e) { |
|
| 49 | + } catch (PDOException $e) { |
|
| 50 | 50 | echo "error : ".$e->getMessage(); |
| 51 | 51 | return array(); |
| 52 | 52 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | try { |
| 69 | 69 | $sth = $this->db->prepare($query); |
| 70 | 70 | $sth->execute(array(':filter_name' => $filter_name)); |
| 71 | - } catch(PDOException $e) { |
|
| 71 | + } catch (PDOException $e) { |
|
| 72 | 72 | return "error : ".$e->getMessage(); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | try { |
| 82 | 82 | $sth = $this->db->prepare($query); |
| 83 | 83 | $sth->execute(); |
| 84 | - } catch(PDOException $e) { |
|
| 84 | + } catch (PDOException $e) { |
|
| 85 | 85 | return "error : ".$e->getMessage(); |
| 86 | 86 | } |
| 87 | 87 | $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
| 88 | 88 | try { |
| 89 | 89 | $sth = $this->db->prepare($query); |
| 90 | 90 | $sth->execute(array(':filter_name' => $filter_name)); |
| 91 | - } catch(PDOException $e) { |
|
| 91 | + } catch (PDOException $e) { |
|
| 92 | 92 | return "error : ".$e->getMessage(); |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -100,77 +100,77 @@ discard block |
||
| 100 | 100 | try { |
| 101 | 101 | $sth = $this->db->prepare($query); |
| 102 | 102 | $sth->execute(array(':filter_name' => $filter_name)); |
| 103 | - } catch(PDOException $e) { |
|
| 103 | + } catch (PDOException $e) { |
|
| 104 | 104 | echo "error : ".$e->getMessage(); |
| 105 | 105 | } |
| 106 | 106 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 107 | 107 | if (empty($all)) { |
| 108 | 108 | $filters = array(); |
| 109 | 109 | if ($filter_name != '') { |
| 110 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 110 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 111 | 111 | } |
| 112 | 112 | $Spotter = new Spotter($this->db); |
| 113 | - $all = $Spotter->getAllAirlineNames('',NULL,$filters); |
|
| 113 | + $all = $Spotter->getAllAirlineNames('', NULL, $filters); |
|
| 114 | 114 | } |
| 115 | 115 | return $all; |
| 116 | 116 | } |
| 117 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
| 117 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
| 118 | 118 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 119 | 119 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 120 | 120 | try { |
| 121 | 121 | $sth = $this->db->prepare($query); |
| 122 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 123 | - } catch(PDOException $e) { |
|
| 122 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 123 | + } catch (PDOException $e) { |
|
| 124 | 124 | echo "error : ".$e->getMessage(); |
| 125 | 125 | } |
| 126 | 126 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 127 | 127 | return $all; |
| 128 | 128 | } |
| 129 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
| 129 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
| 130 | 130 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 131 | 131 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
| 132 | 132 | try { |
| 133 | 133 | $sth = $this->db->prepare($query); |
| 134 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 135 | - } catch(PDOException $e) { |
|
| 134 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 135 | + } catch (PDOException $e) { |
|
| 136 | 136 | echo "error : ".$e->getMessage(); |
| 137 | 137 | } |
| 138 | 138 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 139 | 139 | return $all; |
| 140 | 140 | } |
| 141 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
| 141 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
| 142 | 142 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 143 | 143 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
| 144 | 144 | try { |
| 145 | 145 | $sth = $this->db->prepare($query); |
| 146 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 147 | - } catch(PDOException $e) { |
|
| 146 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 147 | + } catch (PDOException $e) { |
|
| 148 | 148 | echo "error : ".$e->getMessage(); |
| 149 | 149 | } |
| 150 | 150 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 151 | 151 | return $all; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
| 154 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
| 155 | 155 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 156 | 156 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 157 | 157 | try { |
| 158 | 158 | $sth = $this->db->prepare($query); |
| 159 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 160 | - } catch(PDOException $e) { |
|
| 159 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 160 | + } catch (PDOException $e) { |
|
| 161 | 161 | echo "error : ".$e->getMessage(); |
| 162 | 162 | } |
| 163 | 163 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 164 | 164 | return $all; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
| 167 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
| 168 | 168 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 169 | 169 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 170 | 170 | try { |
| 171 | 171 | $sth = $this->db->prepare($query); |
| 172 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 173 | - } catch(PDOException $e) { |
|
| 172 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 173 | + } catch (PDOException $e) { |
|
| 174 | 174 | echo "error : ".$e->getMessage(); |
| 175 | 175 | } |
| 176 | 176 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -178,23 +178,23 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
| 181 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 181 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 182 | 182 | global $globalStatsFilters; |
| 183 | 183 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 184 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 184 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 185 | 185 | $Spotter = new Spotter($this->db); |
| 186 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 186 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 187 | 187 | $alliance_airlines = array(); |
| 188 | 188 | foreach ($airlines as $airline) { |
| 189 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 189 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 190 | 190 | } |
| 191 | 191 | if ($year == '' && $month == '') { |
| 192 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 193 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 192 | + if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 193 | + else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 194 | 194 | try { |
| 195 | 195 | $sth = $this->db->prepare($query); |
| 196 | 196 | $sth->execute(array(':filter_name' => $filter_name)); |
| 197 | - } catch(PDOException $e) { |
|
| 197 | + } catch (PDOException $e) { |
|
| 198 | 198 | echo "error : ".$e->getMessage(); |
| 199 | 199 | } |
| 200 | 200 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -205,29 +205,29 @@ discard block |
||
| 205 | 205 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
| 206 | 206 | try { |
| 207 | 207 | $sth = $this->db->prepare($query); |
| 208 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 209 | - } catch(PDOException $e) { |
|
| 208 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 209 | + } catch (PDOException $e) { |
|
| 210 | 210 | echo "error : ".$e->getMessage(); |
| 211 | 211 | } |
| 212 | 212 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 213 | 213 | } else $all = array(); |
| 214 | 214 | } |
| 215 | 215 | if (empty($all)) { |
| 216 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 217 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 216 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 217 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 218 | 218 | } else { |
| 219 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 219 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 220 | 220 | } |
| 221 | 221 | if ($filter_name != '') { |
| 222 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 222 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 223 | 223 | } |
| 224 | 224 | $Spotter = new Spotter($this->db); |
| 225 | 225 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
| 226 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
| 226 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
| 227 | 227 | } |
| 228 | 228 | return $all; |
| 229 | 229 | } |
| 230 | - public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') { |
|
| 230 | + public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 231 | 231 | global $globalStatsFilters, $globalVM; |
| 232 | 232 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 233 | 233 | if ($year == '' && $month == '' && (!isset($globalVM) || $globalVM === FALSE)) { |
@@ -236,23 +236,23 @@ discard block |
||
| 236 | 236 | try { |
| 237 | 237 | $sth = $this->db->prepare($query); |
| 238 | 238 | $sth->execute(array(':filter_name' => $filter_name)); |
| 239 | - } catch(PDOException $e) { |
|
| 239 | + } catch (PDOException $e) { |
|
| 240 | 240 | echo "error : ".$e->getMessage(); |
| 241 | 241 | } |
| 242 | 242 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 243 | 243 | } else $all = array(); |
| 244 | 244 | if (empty($all)) { |
| 245 | - $filters = array('year' => $year,'month' => $month); |
|
| 245 | + $filters = array('year' => $year, 'month' => $month); |
|
| 246 | 246 | if ($filter_name != '') { |
| 247 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 247 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 248 | 248 | } |
| 249 | 249 | $Marine = new Marine($this->db); |
| 250 | 250 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
| 251 | - $all = $Marine->countAllMarineTypes($limit,0,'',$filters); |
|
| 251 | + $all = $Marine->countAllMarineTypes($limit, 0, '', $filters); |
|
| 252 | 252 | } |
| 253 | 253 | return $all; |
| 254 | 254 | } |
| 255 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 255 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 256 | 256 | global $globalStatsFilters; |
| 257 | 257 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 258 | 258 | if ($year == '' && $month == '') { |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | try { |
| 262 | 262 | $sth = $this->db->prepare($query); |
| 263 | 263 | $sth->execute(array(':filter_name' => $filter_name)); |
| 264 | - } catch(PDOException $e) { |
|
| 264 | + } catch (PDOException $e) { |
|
| 265 | 265 | echo "error : ".$e->getMessage(); |
| 266 | 266 | } |
| 267 | 267 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -269,32 +269,32 @@ discard block |
||
| 269 | 269 | if (empty($all)) { |
| 270 | 270 | $Spotter = new Spotter($this->db); |
| 271 | 271 | $filters = array(); |
| 272 | - $filters = array('year' => $year,'month' => $month); |
|
| 272 | + $filters = array('year' => $year, 'month' => $month); |
|
| 273 | 273 | if ($filter_name != '') { |
| 274 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 274 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 275 | 275 | } |
| 276 | 276 | //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
| 277 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
| 277 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
| 278 | 278 | } |
| 279 | 279 | return $all; |
| 280 | 280 | } |
| 281 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 281 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 282 | 282 | global $globalStatsFilters; |
| 283 | 283 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 284 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 284 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 285 | 285 | $Spotter = new Spotter($this->db); |
| 286 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 286 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 287 | 287 | $alliance_airlines = array(); |
| 288 | 288 | foreach ($airlines as $airline) { |
| 289 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 289 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 290 | 290 | } |
| 291 | 291 | if ($year == '' && $month == '') { |
| 292 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 293 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 292 | + if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 293 | + else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 294 | 294 | try { |
| 295 | 295 | $sth = $this->db->prepare($query); |
| 296 | 296 | $sth->execute(array(':filter_name' => $filter_name)); |
| 297 | - } catch(PDOException $e) { |
|
| 297 | + } catch (PDOException $e) { |
|
| 298 | 298 | echo "error : ".$e->getMessage(); |
| 299 | 299 | } |
| 300 | 300 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -305,21 +305,21 @@ discard block |
||
| 305 | 305 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
| 306 | 306 | try { |
| 307 | 307 | $sth = $this->db->prepare($query); |
| 308 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 309 | - } catch(PDOException $e) { |
|
| 308 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 309 | + } catch (PDOException $e) { |
|
| 310 | 310 | echo "error : ".$e->getMessage(); |
| 311 | 311 | } |
| 312 | 312 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 313 | 313 | } else $all = array(); |
| 314 | 314 | } |
| 315 | 315 | if (empty($all)) { |
| 316 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 317 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 316 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 317 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 318 | 318 | } else { |
| 319 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 319 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 320 | 320 | } |
| 321 | 321 | if ($filter_name != '') { |
| 322 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 322 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 323 | 323 | } |
| 324 | 324 | $Spotter = new Spotter($this->db); |
| 325 | 325 | //$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
@@ -328,23 +328,23 @@ discard block |
||
| 328 | 328 | return $all; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 331 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 332 | 332 | global $globalStatsFilters; |
| 333 | 333 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 334 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 334 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 335 | 335 | $Spotter = new Spotter($this->db); |
| 336 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 336 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 337 | 337 | $alliance_airlines = array(); |
| 338 | 338 | foreach ($airlines as $airline) { |
| 339 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 339 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 340 | 340 | } |
| 341 | 341 | if ($year == '' && $month == '') { |
| 342 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 343 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 342 | + if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 343 | + else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 344 | 344 | try { |
| 345 | 345 | $sth = $this->db->prepare($query); |
| 346 | 346 | $sth->execute(array(':filter_name' => $filter_name)); |
| 347 | - } catch(PDOException $e) { |
|
| 347 | + } catch (PDOException $e) { |
|
| 348 | 348 | echo "error : ".$e->getMessage(); |
| 349 | 349 | } |
| 350 | 350 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -355,61 +355,61 @@ discard block |
||
| 355 | 355 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
| 356 | 356 | try { |
| 357 | 357 | $sth = $this->db->prepare($query); |
| 358 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 359 | - } catch(PDOException $e) { |
|
| 358 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 359 | + } catch (PDOException $e) { |
|
| 360 | 360 | echo "error : ".$e->getMessage(); |
| 361 | 361 | } |
| 362 | 362 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 363 | 363 | } else $all = array(); |
| 364 | 364 | } |
| 365 | 365 | if (empty($all)) { |
| 366 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 367 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 366 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 367 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 368 | 368 | } else { |
| 369 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 369 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 370 | 370 | } |
| 371 | 371 | if ($filter_name != '') { |
| 372 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 372 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 373 | 373 | } |
| 374 | 374 | $Spotter = new Spotter($this->db); |
| 375 | 375 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
| 376 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
| 376 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
| 377 | 377 | } |
| 378 | 378 | return $all; |
| 379 | 379 | } |
| 380 | 380 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 381 | 381 | global $globalStatsFilters; |
| 382 | 382 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 383 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 383 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 384 | 384 | $Spotter = new Spotter($this->db); |
| 385 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 385 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 386 | 386 | $alliance_airlines = array(); |
| 387 | 387 | foreach ($airlines as $airline) { |
| 388 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 388 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 389 | 389 | } |
| 390 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 391 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 390 | + if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 391 | + else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 392 | 392 | $query_values = array(':filter_name' => $filter_name); |
| 393 | 393 | } else { |
| 394 | 394 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
| 395 | 395 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
| 396 | - $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 396 | + $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 397 | 397 | } |
| 398 | 398 | try { |
| 399 | 399 | $sth = $this->db->prepare($query); |
| 400 | 400 | $sth->execute($query_values); |
| 401 | - } catch(PDOException $e) { |
|
| 401 | + } catch (PDOException $e) { |
|
| 402 | 402 | echo "error : ".$e->getMessage(); |
| 403 | 403 | } |
| 404 | 404 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 405 | 405 | if (empty($all)) { |
| 406 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 407 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 406 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 407 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 408 | 408 | } else { |
| 409 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 409 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 410 | 410 | } |
| 411 | 411 | if ($filter_name != '') { |
| 412 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 412 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 413 | 413 | } |
| 414 | 414 | $Spotter = new Spotter($this->db); |
| 415 | 415 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | return $all; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 421 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 422 | 422 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 423 | 423 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 424 | 424 | if ($year == '' && $month == '') { |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | if (isset($forsource)) { |
| 428 | 428 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
| 429 | 429 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
| 430 | - $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
|
| 430 | + $query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource); |
|
| 431 | 431 | } else { |
| 432 | 432 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
| 433 | 433 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | try { |
| 437 | 437 | $sth = $this->db->prepare($query); |
| 438 | 438 | $sth->execute($query_values); |
| 439 | - } catch(PDOException $e) { |
|
| 439 | + } catch (PDOException $e) { |
|
| 440 | 440 | echo "error : ".$e->getMessage(); |
| 441 | 441 | } |
| 442 | 442 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -444,32 +444,32 @@ discard block |
||
| 444 | 444 | if (empty($all)) { |
| 445 | 445 | $Spotter = new Spotter($this->db); |
| 446 | 446 | $filters = array(); |
| 447 | - $filters = array('year' => $year,'month' => $month); |
|
| 447 | + $filters = array('year' => $year, 'month' => $month); |
|
| 448 | 448 | if ($filter_name != '') { |
| 449 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 449 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 450 | 450 | } |
| 451 | 451 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
| 452 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 452 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
| 453 | 453 | } |
| 454 | 454 | return $all; |
| 455 | 455 | } |
| 456 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 456 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 457 | 457 | global $globalStatsFilters; |
| 458 | 458 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 459 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 459 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 460 | 460 | $Spotter = new Spotter($this->db); |
| 461 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 461 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 462 | 462 | $alliance_airlines = array(); |
| 463 | 463 | foreach ($airlines as $airline) { |
| 464 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 464 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 465 | 465 | } |
| 466 | 466 | if ($year == '' && $month == '') { |
| 467 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 468 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 467 | + if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 468 | + else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 469 | 469 | try { |
| 470 | 470 | $sth = $this->db->prepare($query); |
| 471 | 471 | $sth->execute(array(':filter_name' => $filter_name)); |
| 472 | - } catch(PDOException $e) { |
|
| 472 | + } catch (PDOException $e) { |
|
| 473 | 473 | echo "error : ".$e->getMessage(); |
| 474 | 474 | } |
| 475 | 475 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -480,45 +480,45 @@ discard block |
||
| 480 | 480 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
| 481 | 481 | try { |
| 482 | 482 | $sth = $this->db->prepare($query); |
| 483 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 484 | - } catch(PDOException $e) { |
|
| 483 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 484 | + } catch (PDOException $e) { |
|
| 485 | 485 | echo "error : ".$e->getMessage(); |
| 486 | 486 | } |
| 487 | 487 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 488 | 488 | } else $all = array(); |
| 489 | 489 | } |
| 490 | 490 | if (empty($all)) { |
| 491 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 492 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 491 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 492 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 493 | 493 | } else { |
| 494 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 494 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 495 | 495 | } |
| 496 | 496 | if ($filter_name != '') { |
| 497 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 497 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 498 | 498 | } |
| 499 | 499 | $Spotter = new Spotter($this->db); |
| 500 | 500 | //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
| 501 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
| 501 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
| 502 | 502 | } |
| 503 | 503 | return $all; |
| 504 | 504 | } |
| 505 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 505 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 506 | 506 | global $globalStatsFilters; |
| 507 | 507 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 508 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 508 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 509 | 509 | $Spotter = new Spotter($this->db); |
| 510 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 510 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 511 | 511 | $alliance_airlines = array(); |
| 512 | 512 | foreach ($airlines as $airline) { |
| 513 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 513 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 514 | 514 | } |
| 515 | 515 | if ($year == '' && $month == '') { |
| 516 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 517 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 516 | + if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 517 | + else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 518 | 518 | try { |
| 519 | 519 | $sth = $this->db->prepare($query); |
| 520 | 520 | $sth->execute(array(':filter_name' => $filter_name)); |
| 521 | - } catch(PDOException $e) { |
|
| 521 | + } catch (PDOException $e) { |
|
| 522 | 522 | echo "error : ".$e->getMessage(); |
| 523 | 523 | } |
| 524 | 524 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -529,46 +529,46 @@ discard block |
||
| 529 | 529 | else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
| 530 | 530 | try { |
| 531 | 531 | $sth = $this->db->prepare($query); |
| 532 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 533 | - } catch(PDOException $e) { |
|
| 532 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 533 | + } catch (PDOException $e) { |
|
| 534 | 534 | echo "error : ".$e->getMessage(); |
| 535 | 535 | } |
| 536 | 536 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 537 | 537 | } else $all = array(); |
| 538 | 538 | } |
| 539 | 539 | if (empty($all)) { |
| 540 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 541 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 540 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 541 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 542 | 542 | } else { |
| 543 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 543 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 544 | 544 | } |
| 545 | 545 | if ($filter_name != '') { |
| 546 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 546 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 547 | 547 | } |
| 548 | 548 | $Spotter = new Spotter($this->db); |
| 549 | 549 | //$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
| 550 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
| 550 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
| 551 | 551 | } |
| 552 | 552 | return $all; |
| 553 | 553 | } |
| 554 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 554 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 555 | 555 | $Connection = new Connection($this->db); |
| 556 | 556 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 557 | 557 | if ($Connection->tableExists('countries')) { |
| 558 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 558 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 559 | 559 | $Spotter = new Spotter($this->db); |
| 560 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 560 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 561 | 561 | if ($year == '' && $month == '') { |
| 562 | 562 | $alliance_airlines = array(); |
| 563 | 563 | foreach ($airlines as $airline) { |
| 564 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 564 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 565 | 565 | } |
| 566 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 567 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 566 | + if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 567 | + else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 568 | 568 | try { |
| 569 | 569 | $sth = $this->db->prepare($query); |
| 570 | 570 | $sth->execute(array(':filter_name' => $filter_name)); |
| 571 | - } catch(PDOException $e) { |
|
| 571 | + } catch (PDOException $e) { |
|
| 572 | 572 | echo "error : ".$e->getMessage(); |
| 573 | 573 | } |
| 574 | 574 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -580,8 +580,8 @@ discard block |
||
| 580 | 580 | else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
| 581 | 581 | try { |
| 582 | 582 | $sth = $this->db->prepare($query); |
| 583 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 584 | - } catch(PDOException $e) { |
|
| 583 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 584 | + } catch (PDOException $e) { |
|
| 585 | 585 | echo "error : ".$e->getMessage(); |
| 586 | 586 | } |
| 587 | 587 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | return $Spotter->countAllFlightOverCountries($limit); |
| 593 | 593 | } else return array(); |
| 594 | 594 | } |
| 595 | - public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
|
| 595 | + public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 596 | 596 | $Connection = new Connection($this->db); |
| 597 | 597 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 598 | 598 | if ($Connection->tableExists('countries')) { |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | try { |
| 604 | 604 | $sth = $this->db->prepare($query); |
| 605 | 605 | $sth->execute(array(':filter_name' => $filter_name)); |
| 606 | - } catch(PDOException $e) { |
|
| 606 | + } catch (PDOException $e) { |
|
| 607 | 607 | echo "error : ".$e->getMessage(); |
| 608 | 608 | } |
| 609 | 609 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -611,15 +611,15 @@ discard block |
||
| 611 | 611 | if (empty($all)) { |
| 612 | 612 | $filters = array(); |
| 613 | 613 | if ($filter_name != '') { |
| 614 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 614 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 615 | 615 | } |
| 616 | 616 | $Marine = new Marine($this->db); |
| 617 | - $all = $Marine->countAllMarineOverCountries($limit,0,'',$filters); |
|
| 617 | + $all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters); |
|
| 618 | 618 | } |
| 619 | 619 | return $all; |
| 620 | 620 | } else return array(); |
| 621 | 621 | } |
| 622 | - public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
|
| 622 | + public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 623 | 623 | global $globalStatsFilters; |
| 624 | 624 | $Connection = new Connection($this->db); |
| 625 | 625 | if ($filter_name == '') $filter_name = $this->filter_name; |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | try { |
| 632 | 632 | $sth = $this->db->prepare($query); |
| 633 | 633 | $sth->execute(array(':filter_name' => $filter_name)); |
| 634 | - } catch(PDOException $e) { |
|
| 634 | + } catch (PDOException $e) { |
|
| 635 | 635 | echo "error : ".$e->getMessage(); |
| 636 | 636 | } |
| 637 | 637 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -640,15 +640,15 @@ discard block |
||
| 640 | 640 | if (empty($all)) { |
| 641 | 641 | $filters = array(); |
| 642 | 642 | if ($filter_name != '') { |
| 643 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 643 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 644 | 644 | } |
| 645 | 645 | $Tracker = new Tracker($this->db); |
| 646 | - $all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters); |
|
| 646 | + $all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters); |
|
| 647 | 647 | } |
| 648 | 648 | return $all; |
| 649 | 649 | } else return array(); |
| 650 | 650 | } |
| 651 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
| 651 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 652 | 652 | global $globalStatsFilters; |
| 653 | 653 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 654 | 654 | if ($year == '' && $month == '') { |
@@ -656,41 +656,41 @@ discard block |
||
| 656 | 656 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
| 657 | 657 | try { |
| 658 | 658 | $sth = $this->db->prepare($query); |
| 659 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 660 | - } catch(PDOException $e) { |
|
| 659 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 660 | + } catch (PDOException $e) { |
|
| 661 | 661 | echo "error : ".$e->getMessage(); |
| 662 | 662 | } |
| 663 | 663 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 664 | 664 | } else $all = array(); |
| 665 | 665 | if (empty($all)) { |
| 666 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 666 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 667 | 667 | if ($filter_name != '') { |
| 668 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 668 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 669 | 669 | } |
| 670 | 670 | $Spotter = new Spotter($this->db); |
| 671 | 671 | //$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
| 672 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
| 672 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
| 673 | 673 | } |
| 674 | 674 | return $all; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 677 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 678 | 678 | global $globalStatsFilters; |
| 679 | 679 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 680 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 680 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 681 | 681 | $Spotter = new Spotter($this->db); |
| 682 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 682 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 683 | 683 | if ($year == '' && $month == '') { |
| 684 | 684 | $alliance_airlines = array(); |
| 685 | 685 | foreach ($airlines as $airline) { |
| 686 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 686 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 687 | 687 | } |
| 688 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 689 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 688 | + if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 689 | + else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 690 | 690 | try { |
| 691 | 691 | $sth = $this->db->prepare($query); |
| 692 | 692 | $sth->execute(array(':filter_name' => $filter_name)); |
| 693 | - } catch(PDOException $e) { |
|
| 693 | + } catch (PDOException $e) { |
|
| 694 | 694 | echo "error : ".$e->getMessage(); |
| 695 | 695 | } |
| 696 | 696 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -701,45 +701,45 @@ discard block |
||
| 701 | 701 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
| 702 | 702 | try { |
| 703 | 703 | $sth = $this->db->prepare($query); |
| 704 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 705 | - } catch(PDOException $e) { |
|
| 704 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 705 | + } catch (PDOException $e) { |
|
| 706 | 706 | echo "error : ".$e->getMessage(); |
| 707 | 707 | } |
| 708 | 708 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 709 | 709 | } else $all = array(); |
| 710 | 710 | } |
| 711 | 711 | if (empty($all)) { |
| 712 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 713 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 712 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 713 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 714 | 714 | } else { |
| 715 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 715 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 716 | 716 | } |
| 717 | 717 | if ($filter_name != '') { |
| 718 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 718 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 719 | 719 | } |
| 720 | 720 | $Spotter = new Spotter($this->db); |
| 721 | 721 | //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
| 722 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
| 722 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
| 723 | 723 | } |
| 724 | 724 | return $all; |
| 725 | 725 | } |
| 726 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 726 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 727 | 727 | global $globalStatsFilters; |
| 728 | 728 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 729 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 729 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 730 | 730 | $Spotter = new Spotter($this->db); |
| 731 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 731 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 732 | 732 | if ($year == '' && $month == '') { |
| 733 | 733 | $alliance_airlines = array(); |
| 734 | 734 | foreach ($airlines as $airline) { |
| 735 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 735 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 736 | 736 | } |
| 737 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 738 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 737 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 738 | + else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 739 | 739 | try { |
| 740 | 740 | $sth = $this->db->prepare($query); |
| 741 | 741 | $sth->execute(array(':filter_name' => $filter_name)); |
| 742 | - } catch(PDOException $e) { |
|
| 742 | + } catch (PDOException $e) { |
|
| 743 | 743 | echo "error : ".$e->getMessage(); |
| 744 | 744 | } |
| 745 | 745 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -750,27 +750,27 @@ discard block |
||
| 750 | 750 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
| 751 | 751 | try { |
| 752 | 752 | $sth = $this->db->prepare($query); |
| 753 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 754 | - } catch(PDOException $e) { |
|
| 753 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 754 | + } catch (PDOException $e) { |
|
| 755 | 755 | echo "error : ".$e->getMessage(); |
| 756 | 756 | } |
| 757 | 757 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 758 | 758 | } else $all = array(); |
| 759 | 759 | } |
| 760 | 760 | if (empty($all)) { |
| 761 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 762 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 761 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 762 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 763 | 763 | } else { |
| 764 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 764 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 765 | 765 | } |
| 766 | 766 | if ($filter_name != '') { |
| 767 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 767 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 768 | 768 | } |
| 769 | 769 | $Spotter = new Spotter($this->db); |
| 770 | 770 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
| 771 | 771 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
| 772 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
| 773 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
| 772 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
| 773 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
| 774 | 774 | $all = array(); |
| 775 | 775 | foreach ($pall as $value) { |
| 776 | 776 | $icao = $value['airport_departure_icao']; |
@@ -786,27 +786,27 @@ discard block |
||
| 786 | 786 | foreach ($all as $key => $row) { |
| 787 | 787 | $count[$key] = $row['airport_departure_icao_count']; |
| 788 | 788 | } |
| 789 | - array_multisort($count,SORT_DESC,$all); |
|
| 789 | + array_multisort($count, SORT_DESC, $all); |
|
| 790 | 790 | } |
| 791 | 791 | return $all; |
| 792 | 792 | } |
| 793 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 793 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 794 | 794 | global $globalStatsFilters; |
| 795 | 795 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 796 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 796 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 797 | 797 | $Spotter = new Spotter($this->db); |
| 798 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 798 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 799 | 799 | if ($year == '' && $month == '') { |
| 800 | 800 | $alliance_airlines = array(); |
| 801 | 801 | foreach ($airlines as $airline) { |
| 802 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 802 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 803 | 803 | } |
| 804 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 805 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 804 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 805 | + else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 806 | 806 | try { |
| 807 | 807 | $sth = $this->db->prepare($query); |
| 808 | 808 | $sth->execute(array(':filter_name' => $filter_name)); |
| 809 | - } catch(PDOException $e) { |
|
| 809 | + } catch (PDOException $e) { |
|
| 810 | 810 | echo "error : ".$e->getMessage(); |
| 811 | 811 | } |
| 812 | 812 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -817,27 +817,27 @@ discard block |
||
| 817 | 817 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
| 818 | 818 | try { |
| 819 | 819 | $sth = $this->db->prepare($query); |
| 820 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 821 | - } catch(PDOException $e) { |
|
| 820 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 821 | + } catch (PDOException $e) { |
|
| 822 | 822 | echo "error : ".$e->getMessage(); |
| 823 | 823 | } |
| 824 | 824 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 825 | 825 | } else $all = array(); |
| 826 | 826 | } |
| 827 | 827 | if (empty($all)) { |
| 828 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 829 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 828 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 829 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 830 | 830 | } else { |
| 831 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 831 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 832 | 832 | } |
| 833 | 833 | if ($filter_name != '') { |
| 834 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 834 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 835 | 835 | } |
| 836 | 836 | $Spotter = new Spotter($this->db); |
| 837 | 837 | // $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 838 | 838 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 839 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
| 840 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
| 839 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
| 840 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
| 841 | 841 | $all = array(); |
| 842 | 842 | foreach ($pall as $value) { |
| 843 | 843 | $icao = $value['airport_arrival_icao']; |
@@ -853,26 +853,26 @@ discard block |
||
| 853 | 853 | foreach ($all as $key => $row) { |
| 854 | 854 | $count[$key] = $row['airport_arrival_icao_count']; |
| 855 | 855 | } |
| 856 | - array_multisort($count,SORT_DESC,$all); |
|
| 856 | + array_multisort($count, SORT_DESC, $all); |
|
| 857 | 857 | } |
| 858 | 858 | return $all; |
| 859 | 859 | } |
| 860 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
| 860 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
| 861 | 861 | global $globalDBdriver, $globalStatsFilters; |
| 862 | 862 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 863 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 863 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 864 | 864 | $Spotter = new Spotter($this->db); |
| 865 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 865 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 866 | 866 | $alliance_airlines = array(); |
| 867 | 867 | foreach ($airlines as $airline) { |
| 868 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 868 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 869 | 869 | } |
| 870 | 870 | if ($globalDBdriver == 'mysql') { |
| 871 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 872 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 871 | + if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 872 | + else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 873 | 873 | } else { |
| 874 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 875 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 874 | + if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 875 | + else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 876 | 876 | } |
| 877 | 877 | $query_data = array(':filter_name' => $filter_name); |
| 878 | 878 | } else { |
@@ -883,23 +883,23 @@ discard block |
||
| 883 | 883 | if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 884 | 884 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 885 | 885 | } |
| 886 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 886 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 887 | 887 | } |
| 888 | 888 | try { |
| 889 | 889 | $sth = $this->db->prepare($query); |
| 890 | 890 | $sth->execute($query_data); |
| 891 | - } catch(PDOException $e) { |
|
| 891 | + } catch (PDOException $e) { |
|
| 892 | 892 | echo "error : ".$e->getMessage(); |
| 893 | 893 | } |
| 894 | 894 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 895 | 895 | if (empty($all)) { |
| 896 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 897 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 896 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 897 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 898 | 898 | } else { |
| 899 | 899 | $filters = array('airlines' => array($stats_airline)); |
| 900 | 900 | } |
| 901 | 901 | if ($filter_name != '') { |
| 902 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 902 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 903 | 903 | } |
| 904 | 904 | $Spotter = new Spotter($this->db); |
| 905 | 905 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | return $all; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') { |
|
| 910 | + public function countAllMarineMonthsLastYear($limit = true, $filter_name = '') { |
|
| 911 | 911 | global $globalDBdriver, $globalStatsFilters; |
| 912 | 912 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 913 | 913 | if ($globalDBdriver == 'mysql') { |
@@ -921,14 +921,14 @@ discard block |
||
| 921 | 921 | try { |
| 922 | 922 | $sth = $this->db->prepare($query); |
| 923 | 923 | $sth->execute($query_data); |
| 924 | - } catch(PDOException $e) { |
|
| 924 | + } catch (PDOException $e) { |
|
| 925 | 925 | echo "error : ".$e->getMessage(); |
| 926 | 926 | } |
| 927 | 927 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 928 | 928 | if (empty($all)) { |
| 929 | 929 | $filters = array(); |
| 930 | 930 | if ($filter_name != '') { |
| 931 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 931 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 932 | 932 | } |
| 933 | 933 | $Marine = new Marine($this->db); |
| 934 | 934 | $all = $Marine->countAllMonthsLastYear($filters); |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | return $all; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') { |
|
| 939 | + public function countAllTrackerMonthsLastYear($limit = true, $filter_name = '') { |
|
| 940 | 940 | global $globalDBdriver, $globalStatsFilters; |
| 941 | 941 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 942 | 942 | if ($globalDBdriver == 'mysql') { |
@@ -950,14 +950,14 @@ discard block |
||
| 950 | 950 | try { |
| 951 | 951 | $sth = $this->db->prepare($query); |
| 952 | 952 | $sth->execute($query_data); |
| 953 | - } catch(PDOException $e) { |
|
| 953 | + } catch (PDOException $e) { |
|
| 954 | 954 | echo "error : ".$e->getMessage(); |
| 955 | 955 | } |
| 956 | 956 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 957 | 957 | if (empty($all)) { |
| 958 | 958 | $filters = array(); |
| 959 | 959 | if ($filter_name != '') { |
| 960 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 960 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 961 | 961 | } |
| 962 | 962 | $Tracker = new Tracker($this->db); |
| 963 | 963 | $all = $Tracker->countAllMonthsLastYear($filters); |
@@ -965,37 +965,37 @@ discard block |
||
| 965 | 965 | return $all; |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
| 968 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
| 969 | 969 | global $globalStatsFilters; |
| 970 | 970 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 971 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 971 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 972 | 972 | $Spotter = new Spotter($this->db); |
| 973 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 973 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 974 | 974 | $alliance_airlines = array(); |
| 975 | 975 | foreach ($airlines as $airline) { |
| 976 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 976 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 977 | 977 | } |
| 978 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 978 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 979 | 979 | $query_data = array(':filter_name' => $filter_name); |
| 980 | 980 | } else { |
| 981 | 981 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 982 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 982 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 983 | 983 | } |
| 984 | 984 | try { |
| 985 | 985 | $sth = $this->db->prepare($query); |
| 986 | 986 | $sth->execute($query_data); |
| 987 | - } catch(PDOException $e) { |
|
| 987 | + } catch (PDOException $e) { |
|
| 988 | 988 | echo "error : ".$e->getMessage(); |
| 989 | 989 | } |
| 990 | 990 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 991 | 991 | if (empty($all)) { |
| 992 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 993 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 992 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 993 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 994 | 994 | } else { |
| 995 | 995 | $filters = array('airlines' => array($stats_airline)); |
| 996 | 996 | } |
| 997 | 997 | if ($filter_name != '') { |
| 998 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 998 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 999 | 999 | } |
| 1000 | 1000 | $Spotter = new Spotter($this->db); |
| 1001 | 1001 | $all = $Spotter->countAllDatesLastMonth($filters); |
@@ -1010,14 +1010,14 @@ discard block |
||
| 1010 | 1010 | try { |
| 1011 | 1011 | $sth = $this->db->prepare($query); |
| 1012 | 1012 | $sth->execute($query_data); |
| 1013 | - } catch(PDOException $e) { |
|
| 1013 | + } catch (PDOException $e) { |
|
| 1014 | 1014 | echo "error : ".$e->getMessage(); |
| 1015 | 1015 | } |
| 1016 | 1016 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1017 | 1017 | if (empty($all)) { |
| 1018 | 1018 | $filters = array(); |
| 1019 | 1019 | if ($filter_name != '') { |
| 1020 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1020 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1021 | 1021 | } |
| 1022 | 1022 | $Marine = new Marine($this->db); |
| 1023 | 1023 | $all = $Marine->countAllDatesLastMonth($filters); |
@@ -1032,34 +1032,34 @@ discard block |
||
| 1032 | 1032 | try { |
| 1033 | 1033 | $sth = $this->db->prepare($query); |
| 1034 | 1034 | $sth->execute($query_data); |
| 1035 | - } catch(PDOException $e) { |
|
| 1035 | + } catch (PDOException $e) { |
|
| 1036 | 1036 | echo "error : ".$e->getMessage(); |
| 1037 | 1037 | } |
| 1038 | 1038 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1039 | 1039 | if (empty($all)) { |
| 1040 | 1040 | $filters = array(); |
| 1041 | 1041 | if ($filter_name != '') { |
| 1042 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1042 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | $Tracker = new Tracker($this->db); |
| 1045 | 1045 | $all = $Tracker->countAllDatesLastMonth($filters); |
| 1046 | 1046 | } |
| 1047 | 1047 | return $all; |
| 1048 | 1048 | } |
| 1049 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
| 1049 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
| 1050 | 1050 | global $globalDBdriver, $globalStatsFilters; |
| 1051 | 1051 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1052 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1052 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1053 | 1053 | $Spotter = new Spotter($this->db); |
| 1054 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1054 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1055 | 1055 | $alliance_airlines = array(); |
| 1056 | 1056 | foreach ($airlines as $airline) { |
| 1057 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1057 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1058 | 1058 | } |
| 1059 | 1059 | if ($globalDBdriver == 'mysql') { |
| 1060 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1060 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1061 | 1061 | } else { |
| 1062 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1062 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1063 | 1063 | } |
| 1064 | 1064 | $query_data = array(':filter_name' => $filter_name); |
| 1065 | 1065 | } else { |
@@ -1068,23 +1068,23 @@ discard block |
||
| 1068 | 1068 | } else { |
| 1069 | 1069 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1070 | 1070 | } |
| 1071 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1071 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | try { |
| 1074 | 1074 | $sth = $this->db->prepare($query); |
| 1075 | 1075 | $sth->execute($query_data); |
| 1076 | - } catch(PDOException $e) { |
|
| 1076 | + } catch (PDOException $e) { |
|
| 1077 | 1077 | echo "error : ".$e->getMessage(); |
| 1078 | 1078 | } |
| 1079 | 1079 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1080 | 1080 | if (empty($all)) { |
| 1081 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1082 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1081 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1082 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1083 | 1083 | } else { |
| 1084 | 1084 | $filters = array('airlines' => array($stats_airline)); |
| 1085 | 1085 | } |
| 1086 | 1086 | if ($filter_name != '') { |
| 1087 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1087 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | $Spotter = new Spotter($this->db); |
| 1090 | 1090 | $all = $Spotter->countAllDatesLast7Days($filters); |
@@ -1103,14 +1103,14 @@ discard block |
||
| 1103 | 1103 | try { |
| 1104 | 1104 | $sth = $this->db->prepare($query); |
| 1105 | 1105 | $sth->execute($query_data); |
| 1106 | - } catch(PDOException $e) { |
|
| 1106 | + } catch (PDOException $e) { |
|
| 1107 | 1107 | echo "error : ".$e->getMessage(); |
| 1108 | 1108 | } |
| 1109 | 1109 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1110 | 1110 | if (empty($all)) { |
| 1111 | 1111 | $filters = array(); |
| 1112 | 1112 | if ($filter_name != '') { |
| 1113 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1113 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | $Marine = new Marine($this->db); |
| 1116 | 1116 | $all = $Marine->countAllDatesLast7Days($filters); |
@@ -1129,51 +1129,51 @@ discard block |
||
| 1129 | 1129 | try { |
| 1130 | 1130 | $sth = $this->db->prepare($query); |
| 1131 | 1131 | $sth->execute($query_data); |
| 1132 | - } catch(PDOException $e) { |
|
| 1132 | + } catch (PDOException $e) { |
|
| 1133 | 1133 | echo "error : ".$e->getMessage(); |
| 1134 | 1134 | } |
| 1135 | 1135 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1136 | 1136 | if (empty($all)) { |
| 1137 | 1137 | $filters = array(); |
| 1138 | 1138 | if ($filter_name != '') { |
| 1139 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1139 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | $Tracker = new Tracker($this->db); |
| 1142 | 1142 | $all = $Tracker->countAllDatesLast7Days($filters); |
| 1143 | 1143 | } |
| 1144 | 1144 | return $all; |
| 1145 | 1145 | } |
| 1146 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
| 1146 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
| 1147 | 1147 | global $globalStatsFilters; |
| 1148 | 1148 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1149 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1149 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1150 | 1150 | $Spotter = new Spotter($this->db); |
| 1151 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1151 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1152 | 1152 | $alliance_airlines = array(); |
| 1153 | 1153 | foreach ($airlines as $airline) { |
| 1154 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1154 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1155 | 1155 | } |
| 1156 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
| 1156 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
| 1157 | 1157 | $query_data = array(':filter_name' => $filter_name); |
| 1158 | 1158 | } else { |
| 1159 | 1159 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
| 1160 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1160 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | try { |
| 1163 | 1163 | $sth = $this->db->prepare($query); |
| 1164 | 1164 | $sth->execute($query_data); |
| 1165 | - } catch(PDOException $e) { |
|
| 1165 | + } catch (PDOException $e) { |
|
| 1166 | 1166 | echo "error : ".$e->getMessage(); |
| 1167 | 1167 | } |
| 1168 | 1168 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1169 | 1169 | if (empty($all)) { |
| 1170 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1171 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1170 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1171 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1172 | 1172 | } else { |
| 1173 | 1173 | $filters = array('airlines' => array($stats_airline)); |
| 1174 | 1174 | } |
| 1175 | 1175 | if ($filter_name != '') { |
| 1176 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1176 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1177 | 1177 | } |
| 1178 | 1178 | $Spotter = new Spotter($this->db); |
| 1179 | 1179 | $all = $Spotter->countAllDates($filters); |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | try { |
| 1189 | 1189 | $sth = $this->db->prepare($query); |
| 1190 | 1190 | $sth->execute($query_data); |
| 1191 | - } catch(PDOException $e) { |
|
| 1191 | + } catch (PDOException $e) { |
|
| 1192 | 1192 | echo "error : ".$e->getMessage(); |
| 1193 | 1193 | } |
| 1194 | 1194 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1210,7 +1210,7 @@ discard block |
||
| 1210 | 1210 | try { |
| 1211 | 1211 | $sth = $this->db->prepare($query); |
| 1212 | 1212 | $sth->execute($query_data); |
| 1213 | - } catch(PDOException $e) { |
|
| 1213 | + } catch (PDOException $e) { |
|
| 1214 | 1214 | echo "error : ".$e->getMessage(); |
| 1215 | 1215 | } |
| 1216 | 1216 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1232,34 +1232,34 @@ discard block |
||
| 1232 | 1232 | try { |
| 1233 | 1233 | $sth = $this->db->prepare($query); |
| 1234 | 1234 | $sth->execute($query_data); |
| 1235 | - } catch(PDOException $e) { |
|
| 1235 | + } catch (PDOException $e) { |
|
| 1236 | 1236 | echo "error : ".$e->getMessage(); |
| 1237 | 1237 | } |
| 1238 | 1238 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1239 | 1239 | if (empty($all)) { |
| 1240 | 1240 | $filters = array(); |
| 1241 | 1241 | if ($filter_name != '') { |
| 1242 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1242 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | $Spotter = new Spotter($this->db); |
| 1245 | 1245 | $all = $Spotter->countAllDatesByAirlines($filters); |
| 1246 | 1246 | } |
| 1247 | 1247 | return $all; |
| 1248 | 1248 | } |
| 1249 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
| 1249 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
| 1250 | 1250 | global $globalStatsFilters, $globalDBdriver; |
| 1251 | 1251 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1252 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1252 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1253 | 1253 | $Spotter = new Spotter($this->db); |
| 1254 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1254 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1255 | 1255 | $alliance_airlines = array(); |
| 1256 | 1256 | foreach ($airlines as $airline) { |
| 1257 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1257 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1258 | 1258 | } |
| 1259 | 1259 | if ($globalDBdriver == 'mysql') { |
| 1260 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 1260 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 1261 | 1261 | } else { |
| 1262 | - $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 1262 | + $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | $query_data = array(':filter_name' => $filter_name); |
| 1265 | 1265 | } else { |
@@ -1273,18 +1273,18 @@ discard block |
||
| 1273 | 1273 | try { |
| 1274 | 1274 | $sth = $this->db->prepare($query); |
| 1275 | 1275 | $sth->execute($query_data); |
| 1276 | - } catch(PDOException $e) { |
|
| 1276 | + } catch (PDOException $e) { |
|
| 1277 | 1277 | echo "error : ".$e->getMessage(); |
| 1278 | 1278 | } |
| 1279 | 1279 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1280 | 1280 | if (empty($all)) { |
| 1281 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1282 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1281 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1282 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1283 | 1283 | } else { |
| 1284 | 1284 | $filters = array('airlines' => array($stats_airline)); |
| 1285 | 1285 | } |
| 1286 | 1286 | if ($filter_name != '') { |
| 1287 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1287 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | $Spotter = new Spotter($this->db); |
| 1290 | 1290 | $all = $Spotter->countAllMonths($filters); |
@@ -1301,7 +1301,7 @@ discard block |
||
| 1301 | 1301 | try { |
| 1302 | 1302 | $sth = $this->db->prepare($query); |
| 1303 | 1303 | $sth->execute(); |
| 1304 | - } catch(PDOException $e) { |
|
| 1304 | + } catch (PDOException $e) { |
|
| 1305 | 1305 | echo "error : ".$e->getMessage(); |
| 1306 | 1306 | } |
| 1307 | 1307 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | try { |
| 1322 | 1322 | $sth = $this->db->prepare($query); |
| 1323 | 1323 | $sth->execute(); |
| 1324 | - } catch(PDOException $e) { |
|
| 1324 | + } catch (PDOException $e) { |
|
| 1325 | 1325 | echo "error : ".$e->getMessage(); |
| 1326 | 1326 | } |
| 1327 | 1327 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1338,32 +1338,32 @@ discard block |
||
| 1338 | 1338 | try { |
| 1339 | 1339 | $sth = $this->db->prepare($query); |
| 1340 | 1340 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1341 | - } catch(PDOException $e) { |
|
| 1341 | + } catch (PDOException $e) { |
|
| 1342 | 1342 | echo "error : ".$e->getMessage(); |
| 1343 | 1343 | } |
| 1344 | 1344 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1345 | 1345 | if (empty($all)) { |
| 1346 | 1346 | $filters = array(); |
| 1347 | 1347 | if ($filter_name != '') { |
| 1348 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1348 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | $Spotter = new Spotter($this->db); |
| 1351 | 1351 | $all = $Spotter->countAllMilitaryMonths($filters); |
| 1352 | 1352 | } |
| 1353 | 1353 | return $all; |
| 1354 | 1354 | } |
| 1355 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
| 1355 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
| 1356 | 1356 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1357 | 1357 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1358 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1358 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1359 | 1359 | $Spotter = new Spotter($this->db); |
| 1360 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1360 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1361 | 1361 | $alliance_airlines = array(); |
| 1362 | 1362 | foreach ($airlines as $airline) { |
| 1363 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1363 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1364 | 1364 | } |
| 1365 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1366 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1365 | + if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1366 | + else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1367 | 1367 | $query_data = array(':filter_name' => $filter_name); |
| 1368 | 1368 | } else { |
| 1369 | 1369 | if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1381,25 +1381,25 @@ discard block |
||
| 1381 | 1381 | try { |
| 1382 | 1382 | $sth = $this->db->prepare($query); |
| 1383 | 1383 | $sth->execute($query_data); |
| 1384 | - } catch(PDOException $e) { |
|
| 1384 | + } catch (PDOException $e) { |
|
| 1385 | 1385 | echo "error : ".$e->getMessage(); |
| 1386 | 1386 | } |
| 1387 | 1387 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1388 | 1388 | if (empty($all)) { |
| 1389 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1390 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1389 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1390 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1391 | 1391 | } else { |
| 1392 | 1392 | $filters = array('airlines' => array($stats_airline)); |
| 1393 | 1393 | } |
| 1394 | 1394 | if ($filter_name != '') { |
| 1395 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1395 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | $Spotter = new Spotter($this->db); |
| 1398 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
| 1398 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
| 1399 | 1399 | } |
| 1400 | 1400 | return $all; |
| 1401 | 1401 | } |
| 1402 | - public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') { |
|
| 1402 | + public function countAllMarineHours($orderby = 'hour', $limit = true, $filter_name = '') { |
|
| 1403 | 1403 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1404 | 1404 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1405 | 1405 | if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
@@ -1416,21 +1416,21 @@ discard block |
||
| 1416 | 1416 | try { |
| 1417 | 1417 | $sth = $this->db->prepare($query); |
| 1418 | 1418 | $sth->execute($query_data); |
| 1419 | - } catch(PDOException $e) { |
|
| 1419 | + } catch (PDOException $e) { |
|
| 1420 | 1420 | echo "error : ".$e->getMessage(); |
| 1421 | 1421 | } |
| 1422 | 1422 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1423 | 1423 | if (empty($all)) { |
| 1424 | 1424 | $filters = array(); |
| 1425 | 1425 | if ($filter_name != '') { |
| 1426 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1426 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1427 | 1427 | } |
| 1428 | 1428 | $Marine = new Marine($this->db); |
| 1429 | - $all = $Marine->countAllHours($orderby,$filters); |
|
| 1429 | + $all = $Marine->countAllHours($orderby, $filters); |
|
| 1430 | 1430 | } |
| 1431 | 1431 | return $all; |
| 1432 | 1432 | } |
| 1433 | - public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') { |
|
| 1433 | + public function countAllTrackerHours($orderby = 'hour', $limit = true, $filter_name = '') { |
|
| 1434 | 1434 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1435 | 1435 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1436 | 1436 | if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
@@ -1447,33 +1447,33 @@ discard block |
||
| 1447 | 1447 | try { |
| 1448 | 1448 | $sth = $this->db->prepare($query); |
| 1449 | 1449 | $sth->execute($query_data); |
| 1450 | - } catch(PDOException $e) { |
|
| 1450 | + } catch (PDOException $e) { |
|
| 1451 | 1451 | echo "error : ".$e->getMessage(); |
| 1452 | 1452 | } |
| 1453 | 1453 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1454 | 1454 | if (empty($all)) { |
| 1455 | 1455 | $filters = array(); |
| 1456 | 1456 | if ($filter_name != '') { |
| 1457 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1457 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | $Tracker = new Tracker($this->db); |
| 1460 | - $all = $Tracker->countAllHours($orderby,$filters); |
|
| 1460 | + $all = $Tracker->countAllHours($orderby, $filters); |
|
| 1461 | 1461 | } |
| 1462 | 1462 | return $all; |
| 1463 | 1463 | } |
| 1464 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 1464 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1465 | 1465 | global $globalStatsFilters; |
| 1466 | 1466 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1467 | 1467 | if ($year == '') $year = date('Y'); |
| 1468 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1468 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1469 | 1469 | if (empty($all)) { |
| 1470 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1471 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1470 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1471 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1472 | 1472 | } else { |
| 1473 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1473 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1474 | 1474 | } |
| 1475 | 1475 | if ($filter_name != '') { |
| 1476 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1476 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1477 | 1477 | } |
| 1478 | 1478 | $Spotter = new Spotter($this->db); |
| 1479 | 1479 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1481,15 +1481,15 @@ discard block |
||
| 1481 | 1481 | } |
| 1482 | 1482 | return $all; |
| 1483 | 1483 | } |
| 1484 | - public function countOverallMarine($filter_name = '',$year = '',$month = '') { |
|
| 1484 | + public function countOverallMarine($filter_name = '', $year = '', $month = '') { |
|
| 1485 | 1485 | global $globalStatsFilters; |
| 1486 | 1486 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1487 | 1487 | if ($year == '') $year = date('Y'); |
| 1488 | - $all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month); |
|
| 1488 | + $all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month); |
|
| 1489 | 1489 | if (empty($all)) { |
| 1490 | - $filters = array('year' => $year,'month' => $month); |
|
| 1490 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1491 | 1491 | if ($filter_name != '') { |
| 1492 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1492 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1493 | 1493 | } |
| 1494 | 1494 | $Marine = new Marine($this->db); |
| 1495 | 1495 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1497,15 +1497,15 @@ discard block |
||
| 1497 | 1497 | } |
| 1498 | 1498 | return $all; |
| 1499 | 1499 | } |
| 1500 | - public function countOverallTracker($filter_name = '',$year = '',$month = '') { |
|
| 1500 | + public function countOverallTracker($filter_name = '', $year = '', $month = '') { |
|
| 1501 | 1501 | global $globalStatsFilters; |
| 1502 | 1502 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1503 | 1503 | if ($year == '') $year = date('Y'); |
| 1504 | - $all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month); |
|
| 1504 | + $all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month); |
|
| 1505 | 1505 | if (empty($all)) { |
| 1506 | - $filters = array('year' => $year,'month' => $month); |
|
| 1506 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1507 | 1507 | if ($filter_name != '') { |
| 1508 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1508 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1509 | 1509 | } |
| 1510 | 1510 | $Tracker = new Tracker($this->db); |
| 1511 | 1511 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1513,16 +1513,16 @@ discard block |
||
| 1513 | 1513 | } |
| 1514 | 1514 | return $all; |
| 1515 | 1515 | } |
| 1516 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
| 1516 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
| 1517 | 1517 | global $globalStatsFilters; |
| 1518 | 1518 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1519 | 1519 | if ($year == '') $year = date('Y'); |
| 1520 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
| 1520 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
| 1521 | 1521 | if (empty($all)) { |
| 1522 | 1522 | $filters = array(); |
| 1523 | - $filters = array('year' => $year,'month' => $month); |
|
| 1523 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1524 | 1524 | if ($filter_name != '') { |
| 1525 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1525 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1526 | 1526 | } |
| 1527 | 1527 | $Spotter = new Spotter($this->db); |
| 1528 | 1528 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -1530,19 +1530,19 @@ discard block |
||
| 1530 | 1530 | } |
| 1531 | 1531 | return $all; |
| 1532 | 1532 | } |
| 1533 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
| 1533 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1534 | 1534 | global $globalStatsFilters; |
| 1535 | 1535 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1536 | 1536 | if ($year == '') $year = date('Y'); |
| 1537 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1537 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1538 | 1538 | if (empty($all)) { |
| 1539 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1540 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1539 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1540 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1541 | 1541 | } else { |
| 1542 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1542 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1543 | 1543 | } |
| 1544 | 1544 | if ($filter_name != '') { |
| 1545 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1545 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1546 | 1546 | } |
| 1547 | 1547 | $Spotter = new Spotter($this->db); |
| 1548 | 1548 | //$all = $Spotter->countOverallArrival($filters,$year,$month); |
@@ -1550,48 +1550,48 @@ discard block |
||
| 1550 | 1550 | } |
| 1551 | 1551 | return $all; |
| 1552 | 1552 | } |
| 1553 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 1553 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1554 | 1554 | global $globalStatsFilters; |
| 1555 | 1555 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1556 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1556 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1557 | 1557 | $Spotter = new Spotter($this->db); |
| 1558 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1558 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1559 | 1559 | if ($year == '' && $month == '') { |
| 1560 | 1560 | $alliance_airlines = array(); |
| 1561 | 1561 | foreach ($airlines as $airline) { |
| 1562 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1562 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1563 | 1563 | } |
| 1564 | - $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1564 | + $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1565 | 1565 | try { |
| 1566 | 1566 | $sth = $this->db->prepare($query); |
| 1567 | 1567 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1568 | - } catch(PDOException $e) { |
|
| 1568 | + } catch (PDOException $e) { |
|
| 1569 | 1569 | echo "error : ".$e->getMessage(); |
| 1570 | 1570 | } |
| 1571 | 1571 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1572 | 1572 | $all = $result[0]['nb']; |
| 1573 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1573 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1574 | 1574 | } else { |
| 1575 | 1575 | if ($year == '' && $month == '') { |
| 1576 | 1576 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1577 | 1577 | try { |
| 1578 | 1578 | $sth = $this->db->prepare($query); |
| 1579 | - $sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline)); |
|
| 1580 | - } catch(PDOException $e) { |
|
| 1579 | + $sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline)); |
|
| 1580 | + } catch (PDOException $e) { |
|
| 1581 | 1581 | echo "error : ".$e->getMessage(); |
| 1582 | 1582 | } |
| 1583 | 1583 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1584 | 1584 | $all = $result[0]['nb']; |
| 1585 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1585 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1586 | 1586 | } |
| 1587 | 1587 | if (empty($all)) { |
| 1588 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1589 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1588 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1589 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1590 | 1590 | } else { |
| 1591 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1591 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1592 | 1592 | } |
| 1593 | 1593 | if ($filter_name != '') { |
| 1594 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1594 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | $Spotter = new Spotter($this->db); |
| 1597 | 1597 | //$all = $Spotter->countOverallAircrafts($filters,$year,$month); |
@@ -1599,7 +1599,7 @@ discard block |
||
| 1599 | 1599 | } |
| 1600 | 1600 | return $all; |
| 1601 | 1601 | } |
| 1602 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
| 1602 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
| 1603 | 1603 | global $globalStatsFilters; |
| 1604 | 1604 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1605 | 1605 | if ($year == '' && $month == '') { |
@@ -1607,17 +1607,17 @@ discard block |
||
| 1607 | 1607 | try { |
| 1608 | 1608 | $sth = $this->db->prepare($query); |
| 1609 | 1609 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1610 | - } catch(PDOException $e) { |
|
| 1610 | + } catch (PDOException $e) { |
|
| 1611 | 1611 | echo "error : ".$e->getMessage(); |
| 1612 | 1612 | } |
| 1613 | 1613 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1614 | 1614 | $all = $result[0]['nb_airline']; |
| 1615 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1615 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
| 1616 | 1616 | if (empty($all)) { |
| 1617 | 1617 | $filters = array(); |
| 1618 | - $filters = array('year' => $year,'month' => $month); |
|
| 1618 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1619 | 1619 | if ($filter_name != '') { |
| 1620 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1620 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1621 | 1621 | } |
| 1622 | 1622 | $Spotter = new Spotter($this->db); |
| 1623 | 1623 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -1625,7 +1625,7 @@ discard block |
||
| 1625 | 1625 | } |
| 1626 | 1626 | return $all; |
| 1627 | 1627 | } |
| 1628 | - public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') { |
|
| 1628 | + public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') { |
|
| 1629 | 1629 | global $globalStatsFilters; |
| 1630 | 1630 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1631 | 1631 | $all = array(); |
@@ -1634,7 +1634,7 @@ discard block |
||
| 1634 | 1634 | try { |
| 1635 | 1635 | $sth = $this->db->prepare($query); |
| 1636 | 1636 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1637 | - } catch(PDOException $e) { |
|
| 1637 | + } catch (PDOException $e) { |
|
| 1638 | 1638 | echo "error : ".$e->getMessage(); |
| 1639 | 1639 | } |
| 1640 | 1640 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1642,9 +1642,9 @@ discard block |
||
| 1642 | 1642 | } |
| 1643 | 1643 | if (empty($all)) { |
| 1644 | 1644 | $filters = array(); |
| 1645 | - $filters = array('year' => $year,'month' => $month); |
|
| 1645 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1646 | 1646 | if ($filter_name != '') { |
| 1647 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1647 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1648 | 1648 | } |
| 1649 | 1649 | $Marine = new Marine($this->db); |
| 1650 | 1650 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -1652,29 +1652,29 @@ discard block |
||
| 1652 | 1652 | } |
| 1653 | 1653 | return $all; |
| 1654 | 1654 | } |
| 1655 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 1655 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1656 | 1656 | global $globalStatsFilters; |
| 1657 | 1657 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1658 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1658 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1659 | 1659 | $Spotter = new Spotter($this->db); |
| 1660 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1660 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1661 | 1661 | if ($year == '' && $month == '') { |
| 1662 | 1662 | $alliance_airlines = array(); |
| 1663 | 1663 | foreach ($airlines as $airline) { |
| 1664 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1664 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1665 | 1665 | } |
| 1666 | - $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1666 | + $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1667 | 1667 | $query_values = array(':filter_name' => $filter_name); |
| 1668 | 1668 | try { |
| 1669 | 1669 | $sth = $this->db->prepare($query); |
| 1670 | 1670 | $sth->execute($query_values); |
| 1671 | - } catch(PDOException $e) { |
|
| 1671 | + } catch (PDOException $e) { |
|
| 1672 | 1672 | echo "error : ".$e->getMessage(); |
| 1673 | 1673 | } |
| 1674 | 1674 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1675 | 1675 | $all = $result[0]['nb']; |
| 1676 | 1676 | } else { |
| 1677 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1677 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1678 | 1678 | } |
| 1679 | 1679 | } else { |
| 1680 | 1680 | if ($year == '' && $month == '') { |
@@ -1683,23 +1683,23 @@ discard block |
||
| 1683 | 1683 | try { |
| 1684 | 1684 | $sth = $this->db->prepare($query); |
| 1685 | 1685 | $sth->execute($query_values); |
| 1686 | - } catch(PDOException $e) { |
|
| 1686 | + } catch (PDOException $e) { |
|
| 1687 | 1687 | echo "error : ".$e->getMessage(); |
| 1688 | 1688 | } |
| 1689 | 1689 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1690 | 1690 | $all = $result[0]['nb']; |
| 1691 | 1691 | } else { |
| 1692 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1692 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1693 | 1693 | } |
| 1694 | 1694 | } |
| 1695 | 1695 | if (empty($all)) { |
| 1696 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1697 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1696 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1697 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1698 | 1698 | } else { |
| 1699 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1699 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | if ($filter_name != '') { |
| 1702 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1702 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1703 | 1703 | } |
| 1704 | 1704 | $Spotter = new Spotter($this->db); |
| 1705 | 1705 | //$all = $Spotter->countOverallOwners($filters,$year,$month); |
@@ -1707,7 +1707,7 @@ discard block |
||
| 1707 | 1707 | } |
| 1708 | 1708 | return $all; |
| 1709 | 1709 | } |
| 1710 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 1710 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1711 | 1711 | global $globalStatsFilters; |
| 1712 | 1712 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1713 | 1713 | //if ($year == '') $year = date('Y'); |
@@ -1717,18 +1717,18 @@ discard block |
||
| 1717 | 1717 | try { |
| 1718 | 1718 | $sth = $this->db->prepare($query); |
| 1719 | 1719 | $sth->execute($query_values); |
| 1720 | - } catch(PDOException $e) { |
|
| 1720 | + } catch (PDOException $e) { |
|
| 1721 | 1721 | echo "error : ".$e->getMessage(); |
| 1722 | 1722 | } |
| 1723 | 1723 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1724 | 1724 | $all = $result[0]['nb']; |
| 1725 | 1725 | } else { |
| 1726 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1726 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1727 | 1727 | } |
| 1728 | 1728 | if (empty($all)) { |
| 1729 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1729 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1730 | 1730 | if ($filter_name != '') { |
| 1731 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1731 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1732 | 1732 | } |
| 1733 | 1733 | $Spotter = new Spotter($this->db); |
| 1734 | 1734 | //$all = $Spotter->countOverallPilots($filters,$year,$month); |
@@ -1737,104 +1737,104 @@ discard block |
||
| 1737 | 1737 | return $all; |
| 1738 | 1738 | } |
| 1739 | 1739 | |
| 1740 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
| 1740 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
| 1741 | 1741 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1742 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1742 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1743 | 1743 | $Spotter = new Spotter($this->db); |
| 1744 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1744 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1745 | 1745 | $alliance_airlines = array(); |
| 1746 | 1746 | foreach ($airlines as $airline) { |
| 1747 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1747 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1748 | 1748 | } |
| 1749 | - $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
| 1750 | - $query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name); |
|
| 1749 | + $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
| 1750 | + $query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name); |
|
| 1751 | 1751 | } else { |
| 1752 | 1752 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
| 1753 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1753 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1754 | 1754 | } |
| 1755 | 1755 | try { |
| 1756 | 1756 | $sth = $this->db->prepare($query); |
| 1757 | 1757 | $sth->execute($query_values); |
| 1758 | - } catch(PDOException $e) { |
|
| 1758 | + } catch (PDOException $e) { |
|
| 1759 | 1759 | echo "error : ".$e->getMessage(); |
| 1760 | 1760 | } |
| 1761 | 1761 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1762 | 1762 | return $all; |
| 1763 | 1763 | } |
| 1764 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
| 1764 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
| 1765 | 1765 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1766 | 1766 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1767 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1767 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1768 | 1768 | try { |
| 1769 | 1769 | $sth = $this->db->prepare($query); |
| 1770 | 1770 | $sth->execute($query_values); |
| 1771 | - } catch(PDOException $e) { |
|
| 1771 | + } catch (PDOException $e) { |
|
| 1772 | 1772 | echo "error : ".$e->getMessage(); |
| 1773 | 1773 | } |
| 1774 | 1774 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1775 | 1775 | return $all; |
| 1776 | 1776 | } |
| 1777 | - public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
|
| 1777 | + public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') { |
|
| 1778 | 1778 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1779 | 1779 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1780 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1780 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1781 | 1781 | try { |
| 1782 | 1782 | $sth = $this->db->prepare($query); |
| 1783 | 1783 | $sth->execute($query_values); |
| 1784 | - } catch(PDOException $e) { |
|
| 1784 | + } catch (PDOException $e) { |
|
| 1785 | 1785 | echo "error : ".$e->getMessage(); |
| 1786 | 1786 | } |
| 1787 | 1787 | } |
| 1788 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
| 1788 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
| 1789 | 1789 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1790 | 1790 | global $globalArchiveMonths, $globalDBdriver; |
| 1791 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1791 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1792 | 1792 | $Spotter = new Spotter($this->db); |
| 1793 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1793 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1794 | 1794 | $alliance_airlines = array(); |
| 1795 | 1795 | foreach ($airlines as $airline) { |
| 1796 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1796 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1797 | 1797 | } |
| 1798 | 1798 | if ($globalDBdriver == 'mysql') { |
| 1799 | 1799 | if ($month == '') { |
| 1800 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1800 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1801 | 1801 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
| 1802 | 1802 | } else { |
| 1803 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1804 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
| 1803 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1804 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1805 | 1805 | } |
| 1806 | 1806 | } else { |
| 1807 | 1807 | if ($month == '') { |
| 1808 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1808 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1809 | 1809 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
| 1810 | 1810 | } else { |
| 1811 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1812 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
| 1811 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1812 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1813 | 1813 | } |
| 1814 | 1814 | } |
| 1815 | 1815 | } else { |
| 1816 | 1816 | if ($globalDBdriver == 'mysql') { |
| 1817 | 1817 | if ($month == '') { |
| 1818 | 1818 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1819 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1819 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1820 | 1820 | } else { |
| 1821 | 1821 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1822 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 1822 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1823 | 1823 | } |
| 1824 | 1824 | } else { |
| 1825 | 1825 | if ($month == '') { |
| 1826 | 1826 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1827 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1827 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1828 | 1828 | } else { |
| 1829 | 1829 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1830 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 1830 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1831 | 1831 | } |
| 1832 | 1832 | } |
| 1833 | 1833 | } |
| 1834 | 1834 | try { |
| 1835 | 1835 | $sth = $this->db->prepare($query); |
| 1836 | 1836 | $sth->execute($query_values); |
| 1837 | - } catch(PDOException $e) { |
|
| 1837 | + } catch (PDOException $e) { |
|
| 1838 | 1838 | echo "error : ".$e->getMessage(); |
| 1839 | 1839 | } |
| 1840 | 1840 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1843,17 +1843,17 @@ discard block |
||
| 1843 | 1843 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1844 | 1844 | global $globalArchiveMonths, $globalDBdriver; |
| 1845 | 1845 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1846 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1846 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1847 | 1847 | $Spotter = new Spotter($this->db); |
| 1848 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1848 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1849 | 1849 | $alliance_airlines = array(); |
| 1850 | 1850 | foreach ($airlines as $airline) { |
| 1851 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1851 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1852 | 1852 | } |
| 1853 | 1853 | if ($globalDBdriver == 'mysql') { |
| 1854 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1854 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1855 | 1855 | } else { |
| 1856 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1856 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1857 | 1857 | } |
| 1858 | 1858 | $query_values = array(':type' => $type, ':filter_name' => $filter_name); |
| 1859 | 1859 | } else { |
@@ -1867,7 +1867,7 @@ discard block |
||
| 1867 | 1867 | try { |
| 1868 | 1868 | $sth = $this->db->prepare($query); |
| 1869 | 1869 | $sth->execute($query_values); |
| 1870 | - } catch(PDOException $e) { |
|
| 1870 | + } catch (PDOException $e) { |
|
| 1871 | 1871 | echo "error : ".$e->getMessage(); |
| 1872 | 1872 | } |
| 1873 | 1873 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1876,17 +1876,17 @@ discard block |
||
| 1876 | 1876 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1877 | 1877 | global $globalArchiveMonths, $globalDBdriver; |
| 1878 | 1878 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1879 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1879 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1880 | 1880 | $Spotter = new Spotter($this->db); |
| 1881 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1881 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1882 | 1882 | $alliance_airlines = array(); |
| 1883 | 1883 | foreach ($airlines as $airline) { |
| 1884 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1884 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1885 | 1885 | } |
| 1886 | 1886 | if ($globalDBdriver == 'mysql') { |
| 1887 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1887 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1888 | 1888 | } else { |
| 1889 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1889 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1890 | 1890 | } |
| 1891 | 1891 | } else { |
| 1892 | 1892 | if ($globalDBdriver == 'mysql') { |
@@ -1898,7 +1898,7 @@ discard block |
||
| 1898 | 1898 | try { |
| 1899 | 1899 | $sth = $this->db->prepare($query); |
| 1900 | 1900 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
| 1901 | - } catch(PDOException $e) { |
|
| 1901 | + } catch (PDOException $e) { |
|
| 1902 | 1902 | echo "error : ".$e->getMessage(); |
| 1903 | 1903 | } |
| 1904 | 1904 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1915,7 +1915,7 @@ discard block |
||
| 1915 | 1915 | try { |
| 1916 | 1916 | $sth = $this->db->prepare($query); |
| 1917 | 1917 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1918 | - } catch(PDOException $e) { |
|
| 1918 | + } catch (PDOException $e) { |
|
| 1919 | 1919 | echo "error : ".$e->getMessage(); |
| 1920 | 1920 | } |
| 1921 | 1921 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1932,20 +1932,20 @@ discard block |
||
| 1932 | 1932 | try { |
| 1933 | 1933 | $sth = $this->db->prepare($query); |
| 1934 | 1934 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1935 | - } catch(PDOException $e) { |
|
| 1935 | + } catch (PDOException $e) { |
|
| 1936 | 1936 | echo "error : ".$e->getMessage(); |
| 1937 | 1937 | } |
| 1938 | 1938 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1939 | 1939 | return $all[0]['total']; |
| 1940 | 1940 | } |
| 1941 | - public function getStatsOwner($owner_name,$filter_name = '') { |
|
| 1941 | + public function getStatsOwner($owner_name, $filter_name = '') { |
|
| 1942 | 1942 | global $globalArchiveMonths, $globalDBdriver; |
| 1943 | 1943 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1944 | 1944 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1945 | 1945 | try { |
| 1946 | 1946 | $sth = $this->db->prepare($query); |
| 1947 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
| 1948 | - } catch(PDOException $e) { |
|
| 1947 | + $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name)); |
|
| 1948 | + } catch (PDOException $e) { |
|
| 1949 | 1949 | echo "error : ".$e->getMessage(); |
| 1950 | 1950 | } |
| 1951 | 1951 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1963,20 +1963,20 @@ discard block |
||
| 1963 | 1963 | try { |
| 1964 | 1964 | $sth = $this->db->prepare($query); |
| 1965 | 1965 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1966 | - } catch(PDOException $e) { |
|
| 1966 | + } catch (PDOException $e) { |
|
| 1967 | 1967 | echo "error : ".$e->getMessage(); |
| 1968 | 1968 | } |
| 1969 | 1969 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1970 | 1970 | return $all[0]['total']; |
| 1971 | 1971 | } |
| 1972 | - public function getStatsPilot($pilot,$filter_name = '') { |
|
| 1972 | + public function getStatsPilot($pilot, $filter_name = '') { |
|
| 1973 | 1973 | global $globalArchiveMonths, $globalDBdriver; |
| 1974 | 1974 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1975 | 1975 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1976 | 1976 | try { |
| 1977 | 1977 | $sth = $this->db->prepare($query); |
| 1978 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
| 1979 | - } catch(PDOException $e) { |
|
| 1978 | + $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot)); |
|
| 1979 | + } catch (PDOException $e) { |
|
| 1980 | 1980 | echo "error : ".$e->getMessage(); |
| 1981 | 1981 | } |
| 1982 | 1982 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | else return 0; |
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 1987 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 1988 | 1988 | global $globalDBdriver; |
| 1989 | 1989 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1990 | 1990 | if ($globalDBdriver == 'mysql') { |
@@ -1992,15 +1992,15 @@ discard block |
||
| 1992 | 1992 | } else { |
| 1993 | 1993 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1994 | 1994 | } |
| 1995 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1995 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1996 | 1996 | try { |
| 1997 | 1997 | $sth = $this->db->prepare($query); |
| 1998 | 1998 | $sth->execute($query_values); |
| 1999 | - } catch(PDOException $e) { |
|
| 1999 | + } catch (PDOException $e) { |
|
| 2000 | 2000 | return "error : ".$e->getMessage(); |
| 2001 | 2001 | } |
| 2002 | 2002 | } |
| 2003 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 2003 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 2004 | 2004 | global $globalDBdriver; |
| 2005 | 2005 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 2006 | 2006 | if ($globalDBdriver == 'mysql') { |
@@ -2009,11 +2009,11 @@ discard block |
||
| 2009 | 2009 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 2010 | 2010 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 2011 | 2011 | } |
| 2012 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 2012 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 2013 | 2013 | try { |
| 2014 | 2014 | $sth = $this->db->prepare($query); |
| 2015 | 2015 | $sth->execute($query_values); |
| 2016 | - } catch(PDOException $e) { |
|
| 2016 | + } catch (PDOException $e) { |
|
| 2017 | 2017 | return "error : ".$e->getMessage(); |
| 2018 | 2018 | } |
| 2019 | 2019 | } |
@@ -2037,95 +2037,95 @@ discard block |
||
| 2037 | 2037 | } |
| 2038 | 2038 | */ |
| 2039 | 2039 | |
| 2040 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
| 2040 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
| 2041 | 2041 | global $globalDBdriver; |
| 2042 | 2042 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
| 2043 | 2043 | $query_values = array(); |
| 2044 | 2044 | if ($globalDBdriver == 'mysql') { |
| 2045 | 2045 | if ($year != '') { |
| 2046 | 2046 | $query .= ' AND YEAR(stats_date) = :year'; |
| 2047 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2047 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2048 | 2048 | } |
| 2049 | 2049 | if ($month != '') { |
| 2050 | 2050 | $query .= ' AND MONTH(stats_date) = :month'; |
| 2051 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2051 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2052 | 2052 | } |
| 2053 | 2053 | if ($day != '') { |
| 2054 | 2054 | $query .= ' AND DAY(stats_date) = :day'; |
| 2055 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2055 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2056 | 2056 | } |
| 2057 | 2057 | } else { |
| 2058 | 2058 | if ($year != '') { |
| 2059 | 2059 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
| 2060 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2060 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2061 | 2061 | } |
| 2062 | 2062 | if ($month != '') { |
| 2063 | 2063 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
| 2064 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2064 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2065 | 2065 | } |
| 2066 | 2066 | if ($day != '') { |
| 2067 | 2067 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
| 2068 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2068 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2069 | 2069 | } |
| 2070 | 2070 | } |
| 2071 | 2071 | $query .= " ORDER BY source_name"; |
| 2072 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
| 2072 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
| 2073 | 2073 | try { |
| 2074 | 2074 | $sth = $this->db->prepare($query); |
| 2075 | 2075 | $sth->execute($query_values); |
| 2076 | - } catch(PDOException $e) { |
|
| 2076 | + } catch (PDOException $e) { |
|
| 2077 | 2077 | echo "error : ".$e->getMessage(); |
| 2078 | 2078 | } |
| 2079 | 2079 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2080 | 2080 | return $all; |
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
| 2083 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
| 2084 | 2084 | global $globalDBdriver; |
| 2085 | 2085 | if ($globalDBdriver == 'mysql') { |
| 2086 | 2086 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
| 2087 | 2087 | } else { |
| 2088 | 2088 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
| 2089 | 2089 | } |
| 2090 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
| 2090 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
| 2091 | 2091 | try { |
| 2092 | 2092 | $sth = $this->db->prepare($query); |
| 2093 | 2093 | $sth->execute($query_values); |
| 2094 | - } catch(PDOException $e) { |
|
| 2094 | + } catch (PDOException $e) { |
|
| 2095 | 2095 | return "error : ".$e->getMessage(); |
| 2096 | 2096 | } |
| 2097 | 2097 | } |
| 2098 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
| 2098 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
| 2099 | 2099 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
| 2100 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 2100 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 2101 | 2101 | try { |
| 2102 | 2102 | $sth = $this->db->prepare($query); |
| 2103 | 2103 | $sth->execute($query_values); |
| 2104 | - } catch(PDOException $e) { |
|
| 2104 | + } catch (PDOException $e) { |
|
| 2105 | 2105 | return "error : ".$e->getMessage(); |
| 2106 | 2106 | } |
| 2107 | 2107 | } |
| 2108 | - public function addStatMarine($type,$date_name,$cnt,$filter_name = '') { |
|
| 2108 | + public function addStatMarine($type, $date_name, $cnt, $filter_name = '') { |
|
| 2109 | 2109 | $query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)"; |
| 2110 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2110 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2111 | 2111 | try { |
| 2112 | 2112 | $sth = $this->db->prepare($query); |
| 2113 | 2113 | $sth->execute($query_values); |
| 2114 | - } catch(PDOException $e) { |
|
| 2114 | + } catch (PDOException $e) { |
|
| 2115 | 2115 | return "error : ".$e->getMessage(); |
| 2116 | 2116 | } |
| 2117 | 2117 | } |
| 2118 | - public function addStatTracker($type,$date_name,$cnt,$filter_name = '') { |
|
| 2118 | + public function addStatTracker($type, $date_name, $cnt, $filter_name = '') { |
|
| 2119 | 2119 | $query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)"; |
| 2120 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2120 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2121 | 2121 | try { |
| 2122 | 2122 | $sth = $this->db->prepare($query); |
| 2123 | 2123 | $sth->execute($query_values); |
| 2124 | - } catch(PDOException $e) { |
|
| 2124 | + } catch (PDOException $e) { |
|
| 2125 | 2125 | return "error : ".$e->getMessage(); |
| 2126 | 2126 | } |
| 2127 | 2127 | } |
| 2128 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 2128 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2129 | 2129 | global $globalDBdriver; |
| 2130 | 2130 | if ($globalDBdriver == 'mysql') { |
| 2131 | 2131 | if ($reset) { |
@@ -2140,15 +2140,15 @@ discard block |
||
| 2140 | 2140 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 2141 | 2141 | } |
| 2142 | 2142 | } |
| 2143 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2143 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2144 | 2144 | try { |
| 2145 | 2145 | $sth = $this->db->prepare($query); |
| 2146 | 2146 | $sth->execute($query_values); |
| 2147 | - } catch(PDOException $e) { |
|
| 2147 | + } catch (PDOException $e) { |
|
| 2148 | 2148 | return "error : ".$e->getMessage(); |
| 2149 | 2149 | } |
| 2150 | 2150 | } |
| 2151 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2151 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2152 | 2152 | global $globalDBdriver; |
| 2153 | 2153 | if ($globalDBdriver == 'mysql') { |
| 2154 | 2154 | if ($reset) { |
@@ -2163,15 +2163,15 @@ discard block |
||
| 2163 | 2163 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
| 2164 | 2164 | } |
| 2165 | 2165 | } |
| 2166 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2166 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2167 | 2167 | try { |
| 2168 | 2168 | $sth = $this->db->prepare($query); |
| 2169 | 2169 | $sth->execute($query_values); |
| 2170 | - } catch(PDOException $e) { |
|
| 2170 | + } catch (PDOException $e) { |
|
| 2171 | 2171 | return "error : ".$e->getMessage(); |
| 2172 | 2172 | } |
| 2173 | 2173 | } |
| 2174 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 2174 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2175 | 2175 | global $globalDBdriver; |
| 2176 | 2176 | if ($globalDBdriver == 'mysql') { |
| 2177 | 2177 | if ($reset) { |
@@ -2186,15 +2186,15 @@ discard block |
||
| 2186 | 2186 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
| 2187 | 2187 | } |
| 2188 | 2188 | } |
| 2189 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
| 2189 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
| 2190 | 2190 | try { |
| 2191 | 2191 | $sth = $this->db->prepare($query); |
| 2192 | 2192 | $sth->execute($query_values); |
| 2193 | - } catch(PDOException $e) { |
|
| 2193 | + } catch (PDOException $e) { |
|
| 2194 | 2194 | return "error : ".$e->getMessage(); |
| 2195 | 2195 | } |
| 2196 | 2196 | } |
| 2197 | - public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) { |
|
| 2197 | + public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) { |
|
| 2198 | 2198 | global $globalDBdriver; |
| 2199 | 2199 | if ($globalDBdriver == 'mysql') { |
| 2200 | 2200 | if ($reset) { |
@@ -2209,15 +2209,15 @@ discard block |
||
| 2209 | 2209 | $query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
| 2210 | 2210 | } |
| 2211 | 2211 | } |
| 2212 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2212 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2213 | 2213 | try { |
| 2214 | 2214 | $sth = $this->db->prepare($query); |
| 2215 | 2215 | $sth->execute($query_values); |
| 2216 | - } catch(PDOException $e) { |
|
| 2216 | + } catch (PDOException $e) { |
|
| 2217 | 2217 | return "error : ".$e->getMessage(); |
| 2218 | 2218 | } |
| 2219 | 2219 | } |
| 2220 | - public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) { |
|
| 2220 | + public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) { |
|
| 2221 | 2221 | global $globalDBdriver; |
| 2222 | 2222 | if ($globalDBdriver == 'mysql') { |
| 2223 | 2223 | if ($reset) { |
@@ -2232,15 +2232,15 @@ discard block |
||
| 2232 | 2232 | $query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
| 2233 | 2233 | } |
| 2234 | 2234 | } |
| 2235 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2235 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2236 | 2236 | try { |
| 2237 | 2237 | $sth = $this->db->prepare($query); |
| 2238 | 2238 | $sth->execute($query_values); |
| 2239 | - } catch(PDOException $e) { |
|
| 2239 | + } catch (PDOException $e) { |
|
| 2240 | 2240 | return "error : ".$e->getMessage(); |
| 2241 | 2241 | } |
| 2242 | 2242 | } |
| 2243 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2243 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2244 | 2244 | global $globalDBdriver; |
| 2245 | 2245 | if ($globalDBdriver == 'mysql') { |
| 2246 | 2246 | if ($reset) { |
@@ -2255,15 +2255,15 @@ discard block |
||
| 2255 | 2255 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 2256 | 2256 | } |
| 2257 | 2257 | } |
| 2258 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2258 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2259 | 2259 | try { |
| 2260 | 2260 | $sth = $this->db->prepare($query); |
| 2261 | 2261 | $sth->execute($query_values); |
| 2262 | - } catch(PDOException $e) { |
|
| 2262 | + } catch (PDOException $e) { |
|
| 2263 | 2263 | return "error : ".$e->getMessage(); |
| 2264 | 2264 | } |
| 2265 | 2265 | } |
| 2266 | - public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) { |
|
| 2266 | + public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) { |
|
| 2267 | 2267 | global $globalDBdriver; |
| 2268 | 2268 | if ($globalDBdriver == 'mysql') { |
| 2269 | 2269 | if ($reset) { |
@@ -2278,15 +2278,15 @@ discard block |
||
| 2278 | 2278 | $query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type = :type AND filter_name = :filter_name);"; |
| 2279 | 2279 | } |
| 2280 | 2280 | } |
| 2281 | - $query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2281 | + $query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2282 | 2282 | try { |
| 2283 | 2283 | $sth = $this->db->prepare($query); |
| 2284 | 2284 | $sth->execute($query_values); |
| 2285 | - } catch(PDOException $e) { |
|
| 2285 | + } catch (PDOException $e) { |
|
| 2286 | 2286 | return "error : ".$e->getMessage(); |
| 2287 | 2287 | } |
| 2288 | 2288 | } |
| 2289 | - public function addStatTrackerType($type,$cnt, $filter_name = '', $reset = false) { |
|
| 2289 | + public function addStatTrackerType($type, $cnt, $filter_name = '', $reset = false) { |
|
| 2290 | 2290 | global $globalDBdriver; |
| 2291 | 2291 | if ($globalDBdriver == 'mysql') { |
| 2292 | 2292 | if ($reset) { |
@@ -2301,15 +2301,15 @@ discard block |
||
| 2301 | 2301 | $query = "UPDATE stats_tracker_type SET cnt = cnt+:cnt WHERE type = :type AND filter_name = :filter_name; INSERT INTO stats_tracker_type (type,cnt,filter_name) SELECT :type,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_type WHERE type = :type AND filter_name = :filter_name);"; |
| 2302 | 2302 | } |
| 2303 | 2303 | } |
| 2304 | - $query_values = array(':type' => $type,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2304 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2305 | 2305 | try { |
| 2306 | 2306 | $sth = $this->db->prepare($query); |
| 2307 | 2307 | $sth->execute($query_values); |
| 2308 | - } catch(PDOException $e) { |
|
| 2308 | + } catch (PDOException $e) { |
|
| 2309 | 2309 | return "error : ".$e->getMessage(); |
| 2310 | 2310 | } |
| 2311 | 2311 | } |
| 2312 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
| 2312 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
| 2313 | 2313 | global $globalDBdriver; |
| 2314 | 2314 | if ($globalDBdriver == 'mysql') { |
| 2315 | 2315 | if ($reset) { |
@@ -2324,15 +2324,15 @@ discard block |
||
| 2324 | 2324 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
| 2325 | 2325 | } |
| 2326 | 2326 | } |
| 2327 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2327 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2328 | 2328 | try { |
| 2329 | 2329 | $sth = $this->db->prepare($query); |
| 2330 | 2330 | $sth->execute($query_values); |
| 2331 | - } catch(PDOException $e) { |
|
| 2331 | + } catch (PDOException $e) { |
|
| 2332 | 2332 | return "error : ".$e->getMessage(); |
| 2333 | 2333 | } |
| 2334 | 2334 | } |
| 2335 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
| 2335 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
| 2336 | 2336 | global $globalDBdriver; |
| 2337 | 2337 | if ($globalDBdriver == 'mysql') { |
| 2338 | 2338 | if ($reset) { |
@@ -2347,15 +2347,15 @@ discard block |
||
| 2347 | 2347 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 2348 | 2348 | } |
| 2349 | 2349 | } |
| 2350 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 2350 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 2351 | 2351 | try { |
| 2352 | 2352 | $sth = $this->db->prepare($query); |
| 2353 | 2353 | $sth->execute($query_values); |
| 2354 | - } catch(PDOException $e) { |
|
| 2354 | + } catch (PDOException $e) { |
|
| 2355 | 2355 | return "error : ".$e->getMessage(); |
| 2356 | 2356 | } |
| 2357 | 2357 | } |
| 2358 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
| 2358 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
| 2359 | 2359 | global $globalDBdriver; |
| 2360 | 2360 | if ($globalDBdriver == 'mysql') { |
| 2361 | 2361 | if ($reset) { |
@@ -2370,15 +2370,15 @@ discard block |
||
| 2370 | 2370 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
| 2371 | 2371 | } |
| 2372 | 2372 | } |
| 2373 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
| 2373 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
| 2374 | 2374 | try { |
| 2375 | 2375 | $sth = $this->db->prepare($query); |
| 2376 | 2376 | $sth->execute($query_values); |
| 2377 | - } catch(PDOException $e) { |
|
| 2377 | + } catch (PDOException $e) { |
|
| 2378 | 2378 | return "error : ".$e->getMessage(); |
| 2379 | 2379 | } |
| 2380 | 2380 | } |
| 2381 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 2381 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2382 | 2382 | global $globalDBdriver; |
| 2383 | 2383 | if ($airport_icao != '') { |
| 2384 | 2384 | if ($globalDBdriver == 'mysql') { |
@@ -2394,16 +2394,16 @@ discard block |
||
| 2394 | 2394 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
| 2395 | 2395 | } |
| 2396 | 2396 | } |
| 2397 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 2397 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2398 | 2398 | try { |
| 2399 | 2399 | $sth = $this->db->prepare($query); |
| 2400 | 2400 | $sth->execute($query_values); |
| 2401 | - } catch(PDOException $e) { |
|
| 2401 | + } catch (PDOException $e) { |
|
| 2402 | 2402 | return "error : ".$e->getMessage(); |
| 2403 | 2403 | } |
| 2404 | 2404 | } |
| 2405 | 2405 | } |
| 2406 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
| 2406 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
| 2407 | 2407 | global $globalDBdriver; |
| 2408 | 2408 | if ($airport_icao != '') { |
| 2409 | 2409 | if ($globalDBdriver == 'mysql') { |
@@ -2411,16 +2411,16 @@ discard block |
||
| 2411 | 2411 | } else { |
| 2412 | 2412 | $query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 2413 | 2413 | } |
| 2414 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 2414 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2415 | 2415 | try { |
| 2416 | 2416 | $sth = $this->db->prepare($query); |
| 2417 | 2417 | $sth->execute($query_values); |
| 2418 | - } catch(PDOException $e) { |
|
| 2418 | + } catch (PDOException $e) { |
|
| 2419 | 2419 | return "error : ".$e->getMessage(); |
| 2420 | 2420 | } |
| 2421 | 2421 | } |
| 2422 | 2422 | } |
| 2423 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 2423 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2424 | 2424 | global $globalDBdriver; |
| 2425 | 2425 | if ($airport_icao != '') { |
| 2426 | 2426 | if ($globalDBdriver == 'mysql') { |
@@ -2436,16 +2436,16 @@ discard block |
||
| 2436 | 2436 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
| 2437 | 2437 | } |
| 2438 | 2438 | } |
| 2439 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 2439 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2440 | 2440 | try { |
| 2441 | 2441 | $sth = $this->db->prepare($query); |
| 2442 | 2442 | $sth->execute($query_values); |
| 2443 | - } catch(PDOException $e) { |
|
| 2443 | + } catch (PDOException $e) { |
|
| 2444 | 2444 | return "error : ".$e->getMessage(); |
| 2445 | 2445 | } |
| 2446 | 2446 | } |
| 2447 | 2447 | } |
| 2448 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
| 2448 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
| 2449 | 2449 | global $globalDBdriver; |
| 2450 | 2450 | if ($airport_icao != '') { |
| 2451 | 2451 | if ($globalDBdriver == 'mysql') { |
@@ -2453,11 +2453,11 @@ discard block |
||
| 2453 | 2453 | } else { |
| 2454 | 2454 | $query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 2455 | 2455 | } |
| 2456 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 2456 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2457 | 2457 | try { |
| 2458 | 2458 | $sth = $this->db->prepare($query); |
| 2459 | 2459 | $sth->execute($query_values); |
| 2460 | - } catch(PDOException $e) { |
|
| 2460 | + } catch (PDOException $e) { |
|
| 2461 | 2461 | return "error : ".$e->getMessage(); |
| 2462 | 2462 | } |
| 2463 | 2463 | } |
@@ -2469,7 +2469,7 @@ discard block |
||
| 2469 | 2469 | try { |
| 2470 | 2470 | $sth = $this->db->prepare($query); |
| 2471 | 2471 | $sth->execute($query_values); |
| 2472 | - } catch(PDOException $e) { |
|
| 2472 | + } catch (PDOException $e) { |
|
| 2473 | 2473 | return "error : ".$e->getMessage(); |
| 2474 | 2474 | } |
| 2475 | 2475 | } |
@@ -2479,7 +2479,7 @@ discard block |
||
| 2479 | 2479 | try { |
| 2480 | 2480 | $sth = $this->db->prepare($query); |
| 2481 | 2481 | $sth->execute($query_values); |
| 2482 | - } catch(PDOException $e) { |
|
| 2482 | + } catch (PDOException $e) { |
|
| 2483 | 2483 | return "error : ".$e->getMessage(); |
| 2484 | 2484 | } |
| 2485 | 2485 | } |
@@ -2489,7 +2489,7 @@ discard block |
||
| 2489 | 2489 | try { |
| 2490 | 2490 | $sth = $this->db->prepare($query); |
| 2491 | 2491 | $sth->execute($query_values); |
| 2492 | - } catch(PDOException $e) { |
|
| 2492 | + } catch (PDOException $e) { |
|
| 2493 | 2493 | return "error : ".$e->getMessage(); |
| 2494 | 2494 | } |
| 2495 | 2495 | } |
@@ -2499,7 +2499,7 @@ discard block |
||
| 2499 | 2499 | try { |
| 2500 | 2500 | $sth = $this->db->prepare($query); |
| 2501 | 2501 | $sth->execute($query_values); |
| 2502 | - } catch(PDOException $e) { |
|
| 2502 | + } catch (PDOException $e) { |
|
| 2503 | 2503 | return "error : ".$e->getMessage(); |
| 2504 | 2504 | } |
| 2505 | 2505 | } |
@@ -2509,13 +2509,13 @@ discard block |
||
| 2509 | 2509 | try { |
| 2510 | 2510 | $sth = $this->db->prepare($query); |
| 2511 | 2511 | $sth->execute($query_values); |
| 2512 | - } catch(PDOException $e) { |
|
| 2512 | + } catch (PDOException $e) { |
|
| 2513 | 2513 | return "error : ".$e->getMessage(); |
| 2514 | 2514 | } |
| 2515 | 2515 | } |
| 2516 | 2516 | |
| 2517 | 2517 | public function addOldStats() { |
| 2518 | - global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
| 2518 | + global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents; |
|
| 2519 | 2519 | $Common = new Common(); |
| 2520 | 2520 | $Connection = new Connection($this->db); |
| 2521 | 2521 | date_default_timezone_set('UTC'); |
@@ -2530,9 +2530,9 @@ discard block |
||
| 2530 | 2530 | $filtername = 'marine'; |
| 2531 | 2531 | if ($Connection->tableExists('countries')) { |
| 2532 | 2532 | if ($globalDebug) echo 'Count all vessels by countries...'."\n"; |
| 2533 | - $alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day); |
|
| 2533 | + $alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day); |
|
| 2534 | 2534 | foreach ($alldata as $number) { |
| 2535 | - echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset); |
|
| 2535 | + echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset); |
|
| 2536 | 2536 | } |
| 2537 | 2537 | } |
| 2538 | 2538 | if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
@@ -2542,44 +2542,44 @@ discard block |
||
| 2542 | 2542 | $lastyear = false; |
| 2543 | 2543 | foreach ($alldata as $number) { |
| 2544 | 2544 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2545 | - $this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2545 | + $this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2546 | 2546 | } |
| 2547 | 2547 | echo 'Marine data...'."\n"; |
| 2548 | 2548 | $this->deleteStatMarine('month'); |
| 2549 | 2549 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2550 | 2550 | $alldata = $Marine->countAllDatesLastMonth($filter_last_month); |
| 2551 | 2551 | foreach ($alldata as $number) { |
| 2552 | - $this->addStatMarine('month',$number['date_name'],$number['date_count']); |
|
| 2552 | + $this->addStatMarine('month', $number['date_name'], $number['date_count']); |
|
| 2553 | 2553 | } |
| 2554 | 2554 | echo '-> countAllDates...'."\n"; |
| 2555 | 2555 | $previousdata = $this->countAllDatesMarine(); |
| 2556 | 2556 | $this->deleteStatMarine('date'); |
| 2557 | - $alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month)); |
|
| 2557 | + $alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month)); |
|
| 2558 | 2558 | $values = array(); |
| 2559 | 2559 | foreach ($alldata as $cnt) { |
| 2560 | 2560 | $values[] = $cnt['date_count']; |
| 2561 | 2561 | } |
| 2562 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2563 | - array_splice($alldata,11); |
|
| 2562 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2563 | + array_splice($alldata, 11); |
|
| 2564 | 2564 | foreach ($alldata as $number) { |
| 2565 | - $this->addStatMarine('date',$number['date_name'],$number['date_count']); |
|
| 2565 | + $this->addStatMarine('date', $number['date_name'], $number['date_count']); |
|
| 2566 | 2566 | } |
| 2567 | 2567 | |
| 2568 | 2568 | $this->deleteStatMarine('hour'); |
| 2569 | 2569 | echo '-> countAllHours...'."\n"; |
| 2570 | - $alldata = $Marine->countAllHours('hour',$filter_last_month); |
|
| 2570 | + $alldata = $Marine->countAllHours('hour', $filter_last_month); |
|
| 2571 | 2571 | foreach ($alldata as $number) { |
| 2572 | - $this->addStatMarine('hour',$number['hour_name'],$number['hour_count']); |
|
| 2572 | + $this->addStatMarine('hour', $number['hour_name'], $number['hour_count']); |
|
| 2573 | 2573 | } |
| 2574 | 2574 | if ($globalDebug) echo 'Count all types...'."\n"; |
| 2575 | - $alldata = $Marine->countAllMarineTypes(false,0,$last_update_day); |
|
| 2575 | + $alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day); |
|
| 2576 | 2576 | foreach ($alldata as $number) { |
| 2577 | - $this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset); |
|
| 2577 | + $this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset); |
|
| 2578 | 2578 | } |
| 2579 | 2579 | |
| 2580 | 2580 | echo 'Insert last stats update date...'."\n"; |
| 2581 | 2581 | date_default_timezone_set('UTC'); |
| 2582 | - $this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s')); |
|
| 2582 | + $this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s')); |
|
| 2583 | 2583 | } |
| 2584 | 2584 | if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) { |
| 2585 | 2585 | $last_update = $this->getLastStatsUpdate('last_update_stats_tracker'); |
@@ -2591,9 +2591,9 @@ discard block |
||
| 2591 | 2591 | $Tracker = new Tracker($this->db); |
| 2592 | 2592 | if ($Connection->tableExists('countries')) { |
| 2593 | 2593 | if ($globalDebug) echo 'Count all trackers by countries...'."\n"; |
| 2594 | - $alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day); |
|
| 2594 | + $alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day); |
|
| 2595 | 2595 | foreach ($alldata as $number) { |
| 2596 | - $this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset); |
|
| 2596 | + $this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset); |
|
| 2597 | 2597 | } |
| 2598 | 2598 | } |
| 2599 | 2599 | if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
@@ -2603,43 +2603,43 @@ discard block |
||
| 2603 | 2603 | $lastyear = false; |
| 2604 | 2604 | foreach ($alldata as $number) { |
| 2605 | 2605 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2606 | - $this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2606 | + $this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2607 | 2607 | } |
| 2608 | 2608 | echo 'Tracker data...'."\n"; |
| 2609 | 2609 | $this->deleteStatTracker('month'); |
| 2610 | 2610 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2611 | 2611 | $alldata = $Tracker->countAllDatesLastMonth($filter_last_month); |
| 2612 | 2612 | foreach ($alldata as $number) { |
| 2613 | - $this->addStatTracker('month',$number['date_name'],$number['date_count']); |
|
| 2613 | + $this->addStatTracker('month', $number['date_name'], $number['date_count']); |
|
| 2614 | 2614 | } |
| 2615 | 2615 | echo '-> countAllDates...'."\n"; |
| 2616 | 2616 | $previousdata = $this->countAllDatesTracker(); |
| 2617 | 2617 | $this->deleteStatTracker('date'); |
| 2618 | - $alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month)); |
|
| 2618 | + $alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month)); |
|
| 2619 | 2619 | $values = array(); |
| 2620 | 2620 | foreach ($alldata as $cnt) { |
| 2621 | 2621 | $values[] = $cnt['date_count']; |
| 2622 | 2622 | } |
| 2623 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2624 | - array_splice($alldata,11); |
|
| 2623 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2624 | + array_splice($alldata, 11); |
|
| 2625 | 2625 | foreach ($alldata as $number) { |
| 2626 | - $this->addStatTracker('date',$number['date_name'],$number['date_count']); |
|
| 2626 | + $this->addStatTracker('date', $number['date_name'], $number['date_count']); |
|
| 2627 | 2627 | } |
| 2628 | 2628 | |
| 2629 | 2629 | $this->deleteStatTracker('hour'); |
| 2630 | 2630 | echo '-> countAllHours...'."\n"; |
| 2631 | - $alldata = $Tracker->countAllHours('hour',$filter_last_month); |
|
| 2631 | + $alldata = $Tracker->countAllHours('hour', $filter_last_month); |
|
| 2632 | 2632 | foreach ($alldata as $number) { |
| 2633 | - $this->addStatTracker('hour',$number['hour_name'],$number['hour_count']); |
|
| 2633 | + $this->addStatTracker('hour', $number['hour_name'], $number['hour_count']); |
|
| 2634 | 2634 | } |
| 2635 | 2635 | if ($globalDebug) echo 'Count all types...'."\n"; |
| 2636 | - $alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day); |
|
| 2636 | + $alldata = $Tracker->countAllTrackerTypes(false, 0, $last_update_day); |
|
| 2637 | 2637 | foreach ($alldata as $number) { |
| 2638 | - $this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset); |
|
| 2638 | + $this->addStatTrackerType($number['tracker_type'], $number['tracker_type_count'], '', $reset); |
|
| 2639 | 2639 | } |
| 2640 | 2640 | echo 'Insert last stats update date...'."\n"; |
| 2641 | 2641 | date_default_timezone_set('UTC'); |
| 2642 | - $this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s')); |
|
| 2642 | + $this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s')); |
|
| 2643 | 2643 | } |
| 2644 | 2644 | |
| 2645 | 2645 | if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) { |
@@ -2657,41 +2657,41 @@ discard block |
||
| 2657 | 2657 | $Spotter = new Spotter($this->db); |
| 2658 | 2658 | |
| 2659 | 2659 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
| 2660 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
| 2660 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
| 2661 | 2661 | foreach ($alldata as $number) { |
| 2662 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
| 2662 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
| 2665 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
| 2665 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
| 2666 | 2666 | foreach ($alldata as $number) { |
| 2667 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
| 2667 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
| 2668 | 2668 | } |
| 2669 | 2669 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
| 2670 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
| 2670 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
| 2671 | 2671 | foreach ($alldata as $number) { |
| 2672 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
| 2672 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
| 2675 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
| 2675 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
| 2676 | 2676 | foreach ($alldata as $number) { |
| 2677 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2677 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2678 | 2678 | } |
| 2679 | 2679 | if ($globalDebug) echo 'Count all owners...'."\n"; |
| 2680 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
| 2680 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
| 2681 | 2681 | foreach ($alldata as $number) { |
| 2682 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
| 2682 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
| 2685 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
| 2685 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
| 2686 | 2686 | foreach ($alldata as $number) { |
| 2687 | 2687 | if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
| 2688 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
| 2688 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
| 2692 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
| 2692 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
| 2693 | 2693 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
| 2694 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
| 2694 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
| 2695 | 2695 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
| 2696 | 2696 | $alldata = array(); |
| 2697 | 2697 | foreach ($pall as $value) { |
@@ -2708,14 +2708,14 @@ discard block |
||
| 2708 | 2708 | foreach ($alldata as $key => $row) { |
| 2709 | 2709 | $count[$key] = $row['airport_departure_icao_count']; |
| 2710 | 2710 | } |
| 2711 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2711 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2712 | 2712 | foreach ($alldata as $number) { |
| 2713 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
|
| 2713 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset); |
|
| 2714 | 2714 | } |
| 2715 | 2715 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 2716 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
| 2716 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
| 2717 | 2717 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
| 2718 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
| 2718 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
| 2719 | 2719 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
| 2720 | 2720 | $alldata = array(); |
| 2721 | 2721 | foreach ($pall as $value) { |
@@ -2732,18 +2732,18 @@ discard block |
||
| 2732 | 2732 | foreach ($alldata as $key => $row) { |
| 2733 | 2733 | $count[$key] = $row['airport_arrival_icao_count']; |
| 2734 | 2734 | } |
| 2735 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2735 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2736 | 2736 | foreach ($alldata as $number) { |
| 2737 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
|
| 2737 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset); |
|
| 2738 | 2738 | } |
| 2739 | 2739 | if ($Connection->tableExists('countries')) { |
| 2740 | 2740 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
| 2741 | 2741 | //$SpotterArchive = new SpotterArchive(); |
| 2742 | 2742 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2743 | 2743 | $Spotter = new Spotter($this->db); |
| 2744 | - $alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day); |
|
| 2744 | + $alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day); |
|
| 2745 | 2745 | foreach ($alldata as $number) { |
| 2746 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
| 2746 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
| 2747 | 2747 | } |
| 2748 | 2748 | } |
| 2749 | 2749 | |
@@ -2753,12 +2753,12 @@ discard block |
||
| 2753 | 2753 | $this->deleteStatsByType('fatalities_byyear'); |
| 2754 | 2754 | $alldata = $Accident->countFatalitiesByYear(); |
| 2755 | 2755 | foreach ($alldata as $number) { |
| 2756 | - $this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year']))); |
|
| 2756 | + $this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year']))); |
|
| 2757 | 2757 | } |
| 2758 | 2758 | $this->deleteStatsByType('fatalities_bymonth'); |
| 2759 | 2759 | $alldata = $Accident->countFatalitiesLast12Months(); |
| 2760 | 2760 | foreach ($alldata as $number) { |
| 2761 | - $this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year']))); |
|
| 2761 | + $this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year']))); |
|
| 2762 | 2762 | } |
| 2763 | 2763 | } |
| 2764 | 2764 | |
@@ -2772,37 +2772,37 @@ discard block |
||
| 2772 | 2772 | $lastyear = false; |
| 2773 | 2773 | foreach ($alldata as $number) { |
| 2774 | 2774 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2775 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2775 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2776 | 2776 | } |
| 2777 | 2777 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
| 2778 | 2778 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2779 | 2779 | foreach ($alldata as $number) { |
| 2780 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2780 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2781 | 2781 | } |
| 2782 | 2782 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
| 2783 | 2783 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2784 | 2784 | foreach ($alldata as $number) { |
| 2785 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2785 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2786 | 2786 | } |
| 2787 | 2787 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
| 2788 | 2788 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2789 | 2789 | foreach ($alldata as $number) { |
| 2790 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2790 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2791 | 2791 | } |
| 2792 | 2792 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
| 2793 | 2793 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2794 | 2794 | foreach ($alldata as $number) { |
| 2795 | - $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2795 | + $this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2796 | 2796 | } |
| 2797 | 2797 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 2798 | 2798 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2799 | 2799 | foreach ($alldata as $number) { |
| 2800 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2800 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2801 | 2801 | } |
| 2802 | 2802 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 2803 | 2803 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2804 | 2804 | foreach ($alldata as $number) { |
| 2805 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2805 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2806 | 2806 | } |
| 2807 | 2807 | if ($globalDebug) echo 'Airports data...'."\n"; |
| 2808 | 2808 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -2847,7 +2847,7 @@ discard block |
||
| 2847 | 2847 | } |
| 2848 | 2848 | $alldata = $pall; |
| 2849 | 2849 | foreach ($alldata as $number) { |
| 2850 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
| 2850 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
| 2851 | 2851 | } |
| 2852 | 2852 | echo '...Arrival'."\n"; |
| 2853 | 2853 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -2888,7 +2888,7 @@ discard block |
||
| 2888 | 2888 | } |
| 2889 | 2889 | $alldata = $pall; |
| 2890 | 2890 | foreach ($alldata as $number) { |
| 2891 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
| 2891 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
| 2892 | 2892 | } |
| 2893 | 2893 | |
| 2894 | 2894 | echo 'Flights data...'."\n"; |
@@ -2896,28 +2896,28 @@ discard block |
||
| 2896 | 2896 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2897 | 2897 | $alldata = $Spotter->countAllDatesLastMonth($filter_last_month); |
| 2898 | 2898 | foreach ($alldata as $number) { |
| 2899 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
| 2899 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
| 2900 | 2900 | } |
| 2901 | 2901 | echo '-> countAllDates...'."\n"; |
| 2902 | 2902 | $previousdata = $this->countAllDates(); |
| 2903 | 2903 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
| 2904 | 2904 | $this->deleteStatFlight('date'); |
| 2905 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month)); |
|
| 2905 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month)); |
|
| 2906 | 2906 | $values = array(); |
| 2907 | 2907 | foreach ($alldata as $cnt) { |
| 2908 | 2908 | $values[] = $cnt['date_count']; |
| 2909 | 2909 | } |
| 2910 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2911 | - array_splice($alldata,11); |
|
| 2910 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2911 | + array_splice($alldata, 11); |
|
| 2912 | 2912 | foreach ($alldata as $number) { |
| 2913 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
| 2913 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
| 2914 | 2914 | } |
| 2915 | 2915 | |
| 2916 | 2916 | $this->deleteStatFlight('hour'); |
| 2917 | 2917 | echo '-> countAllHours...'."\n"; |
| 2918 | - $alldata = $Spotter->countAllHours('hour',$filter_last_month); |
|
| 2918 | + $alldata = $Spotter->countAllHours('hour', $filter_last_month); |
|
| 2919 | 2919 | foreach ($alldata as $number) { |
| 2920 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
| 2920 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
| 2921 | 2921 | } |
| 2922 | 2922 | |
| 2923 | 2923 | // Count by airlines |
@@ -2926,42 +2926,42 @@ discard block |
||
| 2926 | 2926 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
| 2927 | 2927 | $SpotterArchive = new SpotterArchive($this->db); |
| 2928 | 2928 | //$Spotter = new Spotter($this->db); |
| 2929 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
| 2929 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
| 2930 | 2930 | //$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
| 2931 | 2931 | foreach ($alldata as $number) { |
| 2932 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
| 2932 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
| 2933 | 2933 | } |
| 2934 | 2934 | } |
| 2935 | 2935 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
| 2936 | 2936 | $Spotter = new Spotter($this->db); |
| 2937 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
| 2937 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
| 2938 | 2938 | foreach ($alldata as $number) { |
| 2939 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
| 2939 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
| 2940 | 2940 | } |
| 2941 | 2941 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
| 2942 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
| 2942 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
| 2943 | 2943 | foreach ($alldata as $number) { |
| 2944 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
| 2944 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
| 2945 | 2945 | } |
| 2946 | 2946 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
| 2947 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
| 2947 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
| 2948 | 2948 | foreach ($alldata as $number) { |
| 2949 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2949 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2950 | 2950 | } |
| 2951 | 2951 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
| 2952 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
| 2952 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
| 2953 | 2953 | foreach ($alldata as $number) { |
| 2954 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
| 2954 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
| 2955 | 2955 | } |
| 2956 | 2956 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
| 2957 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
| 2957 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
| 2958 | 2958 | foreach ($alldata as $number) { |
| 2959 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
| 2959 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
| 2960 | 2960 | } |
| 2961 | 2961 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
| 2962 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 2962 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 2963 | 2963 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
| 2964 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 2964 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 2965 | 2965 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
| 2966 | 2966 | //$alldata = array(); |
| 2967 | 2967 | foreach ($dall as $value) { |
@@ -2981,12 +2981,12 @@ discard block |
||
| 2981 | 2981 | } |
| 2982 | 2982 | $alldata = $pall; |
| 2983 | 2983 | foreach ($alldata as $number) { |
| 2984 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2984 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2985 | 2985 | } |
| 2986 | 2986 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
| 2987 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 2987 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 2988 | 2988 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
| 2989 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 2989 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 2990 | 2990 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
| 2991 | 2991 | //$alldata = array(); |
| 2992 | 2992 | foreach ($dall as $value) { |
@@ -3006,7 +3006,7 @@ discard block |
||
| 3006 | 3006 | } |
| 3007 | 3007 | $alldata = $pall; |
| 3008 | 3008 | foreach ($alldata as $number) { |
| 3009 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 3009 | + if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset); |
|
| 3010 | 3010 | } |
| 3011 | 3011 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
| 3012 | 3012 | $Spotter = new Spotter($this->db); |
@@ -3014,27 +3014,27 @@ discard block |
||
| 3014 | 3014 | $lastyear = false; |
| 3015 | 3015 | foreach ($alldata as $number) { |
| 3016 | 3016 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 3017 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 3017 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 3018 | 3018 | } |
| 3019 | 3019 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
| 3020 | 3020 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 3021 | 3021 | foreach ($alldata as $number) { |
| 3022 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 3022 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 3023 | 3023 | } |
| 3024 | 3024 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
| 3025 | 3025 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 3026 | 3026 | foreach ($alldata as $number) { |
| 3027 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 3027 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 3028 | 3028 | } |
| 3029 | 3029 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
| 3030 | 3030 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 3031 | 3031 | foreach ($alldata as $number) { |
| 3032 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 3032 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 3033 | 3033 | } |
| 3034 | 3034 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
| 3035 | 3035 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 3036 | 3036 | foreach ($alldata as $number) { |
| 3037 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 3037 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 3038 | 3038 | } |
| 3039 | 3039 | if ($globalDebug) echo '...Departure'."\n"; |
| 3040 | 3040 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -3057,7 +3057,7 @@ discard block |
||
| 3057 | 3057 | } |
| 3058 | 3058 | $alldata = $pall; |
| 3059 | 3059 | foreach ($alldata as $number) { |
| 3060 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
|
| 3060 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']); |
|
| 3061 | 3061 | } |
| 3062 | 3062 | if ($globalDebug) echo '...Arrival'."\n"; |
| 3063 | 3063 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -3080,32 +3080,32 @@ discard block |
||
| 3080 | 3080 | } |
| 3081 | 3081 | $alldata = $pall; |
| 3082 | 3082 | foreach ($alldata as $number) { |
| 3083 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
|
| 3083 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']); |
|
| 3084 | 3084 | } |
| 3085 | 3085 | |
| 3086 | 3086 | if ($globalDebug) echo 'Flights data...'."\n"; |
| 3087 | 3087 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
| 3088 | 3088 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 3089 | 3089 | foreach ($alldata as $number) { |
| 3090 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
| 3090 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 3091 | 3091 | } |
| 3092 | 3092 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
| 3093 | 3093 | //$previousdata = $this->countAllDatesByAirlines(); |
| 3094 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
|
| 3094 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month)); |
|
| 3095 | 3095 | $values = array(); |
| 3096 | 3096 | foreach ($alldata as $cnt) { |
| 3097 | 3097 | $values[] = $cnt['date_count']; |
| 3098 | 3098 | } |
| 3099 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 3100 | - array_splice($alldata,11); |
|
| 3099 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 3100 | + array_splice($alldata, 11); |
|
| 3101 | 3101 | foreach ($alldata as $number) { |
| 3102 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
| 3102 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 3103 | 3103 | } |
| 3104 | 3104 | |
| 3105 | 3105 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
| 3106 | - $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
|
| 3106 | + $alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month); |
|
| 3107 | 3107 | foreach ($alldata as $number) { |
| 3108 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
| 3108 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
| 3109 | 3109 | } |
| 3110 | 3110 | |
| 3111 | 3111 | // Stats by filters |
@@ -3129,7 +3129,7 @@ discard block |
||
| 3129 | 3129 | $last_update_day = date('Y').'-01-01 00:00:00'; |
| 3130 | 3130 | } |
| 3131 | 3131 | } |
| 3132 | - if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 3132 | + if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 3133 | 3133 | $last_update_day = date('Y').'-01-01 00:00:00'; |
| 3134 | 3134 | $reset = true; |
| 3135 | 3135 | } |
@@ -3137,38 +3137,38 @@ discard block |
||
| 3137 | 3137 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
| 3138 | 3138 | $Spotter = new Spotter($this->db); |
| 3139 | 3139 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
| 3140 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
| 3140 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
| 3141 | 3141 | foreach ($alldata as $number) { |
| 3142 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
| 3142 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
| 3143 | 3143 | } |
| 3144 | 3144 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
| 3145 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
| 3145 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
| 3146 | 3146 | foreach ($alldata as $number) { |
| 3147 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
| 3147 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
| 3148 | 3148 | } |
| 3149 | 3149 | if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
| 3150 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
| 3150 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
| 3151 | 3151 | foreach ($alldata as $number) { |
| 3152 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
| 3152 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
| 3153 | 3153 | } |
| 3154 | 3154 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
| 3155 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
| 3155 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
| 3156 | 3156 | foreach ($alldata as $number) { |
| 3157 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
| 3157 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
| 3158 | 3158 | } |
| 3159 | 3159 | if ($globalDebug) echo 'Count all owners...'."\n"; |
| 3160 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
| 3160 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
| 3161 | 3161 | foreach ($alldata as $number) { |
| 3162 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
| 3162 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
| 3163 | 3163 | } |
| 3164 | 3164 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
| 3165 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
| 3165 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
| 3166 | 3166 | foreach ($alldata as $number) { |
| 3167 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
| 3167 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
| 3168 | 3168 | } |
| 3169 | 3169 | if ($globalDebug) echo 'Count departure airports...'."\n"; |
| 3170 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
| 3171 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
| 3170 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 3171 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 3172 | 3172 | $alldata = array(); |
| 3173 | 3173 | foreach ($pall as $value) { |
| 3174 | 3174 | $icao = $value['airport_departure_icao']; |
@@ -3184,13 +3184,13 @@ discard block |
||
| 3184 | 3184 | foreach ($alldata as $key => $row) { |
| 3185 | 3185 | $count[$key] = $row['airport_departure_icao_count']; |
| 3186 | 3186 | } |
| 3187 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 3187 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 3188 | 3188 | foreach ($alldata as $number) { |
| 3189 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
| 3189 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset); |
|
| 3190 | 3190 | } |
| 3191 | 3191 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 3192 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 3193 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 3192 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 3193 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 3194 | 3194 | $alldata = array(); |
| 3195 | 3195 | foreach ($pall as $value) { |
| 3196 | 3196 | $icao = $value['airport_arrival_icao']; |
@@ -3206,9 +3206,9 @@ discard block |
||
| 3206 | 3206 | foreach ($alldata as $key => $row) { |
| 3207 | 3207 | $count[$key] = $row['airport_arrival_icao_count']; |
| 3208 | 3208 | } |
| 3209 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 3209 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 3210 | 3210 | foreach ($alldata as $number) { |
| 3211 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
|
| 3211 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset); |
|
| 3212 | 3212 | } |
| 3213 | 3213 | if ($globalDebug) echo 'Count all months...'."\n"; |
| 3214 | 3214 | $Spotter = new Spotter($this->db); |
@@ -3216,36 +3216,36 @@ discard block |
||
| 3216 | 3216 | $lastyear = false; |
| 3217 | 3217 | foreach ($alldata as $number) { |
| 3218 | 3218 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 3219 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 3219 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 3220 | 3220 | } |
| 3221 | 3221 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
| 3222 | 3222 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 3223 | 3223 | foreach ($alldata as $number) { |
| 3224 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 3224 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 3225 | 3225 | } |
| 3226 | 3226 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
| 3227 | 3227 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 3228 | 3228 | foreach ($alldata as $number) { |
| 3229 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 3229 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 3230 | 3230 | } |
| 3231 | 3231 | if ($globalDebug) echo 'Count all military by months...'."\n"; |
| 3232 | 3232 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 3233 | 3233 | foreach ($alldata as $number) { |
| 3234 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 3234 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 3235 | 3235 | } |
| 3236 | 3236 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 3237 | 3237 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 3238 | 3238 | foreach ($alldata as $number) { |
| 3239 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 3239 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 3240 | 3240 | } |
| 3241 | 3241 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 3242 | 3242 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 3243 | 3243 | foreach ($alldata as $number) { |
| 3244 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 3244 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 3245 | 3245 | } |
| 3246 | 3246 | echo '...Departure'."\n"; |
| 3247 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
| 3248 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
| 3247 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
| 3248 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
| 3249 | 3249 | foreach ($dall as $value) { |
| 3250 | 3250 | $icao = $value['departure_airport_icao']; |
| 3251 | 3251 | $ddate = $value['date']; |
@@ -3263,11 +3263,11 @@ discard block |
||
| 3263 | 3263 | } |
| 3264 | 3264 | $alldata = $pall; |
| 3265 | 3265 | foreach ($alldata as $number) { |
| 3266 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
| 3266 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
| 3267 | 3267 | } |
| 3268 | 3268 | echo '...Arrival'."\n"; |
| 3269 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
| 3270 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
| 3269 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
| 3270 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
| 3271 | 3271 | foreach ($dall as $value) { |
| 3272 | 3272 | $icao = $value['arrival_airport_icao']; |
| 3273 | 3273 | $ddate = $value['date']; |
@@ -3285,39 +3285,39 @@ discard block |
||
| 3285 | 3285 | } |
| 3286 | 3286 | $alldata = $pall; |
| 3287 | 3287 | foreach ($alldata as $number) { |
| 3288 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
| 3288 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
| 3289 | 3289 | } |
| 3290 | 3290 | echo 'Flights data...'."\n"; |
| 3291 | 3291 | echo '-> countAllDatesLastMonth...'."\n"; |
| 3292 | 3292 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
| 3293 | 3293 | foreach ($alldata as $number) { |
| 3294 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
| 3294 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 3295 | 3295 | } |
| 3296 | 3296 | echo '-> countAllDates...'."\n"; |
| 3297 | - $previousdata = $this->countAllDates('',$filter_name); |
|
| 3298 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
| 3297 | + $previousdata = $this->countAllDates('', $filter_name); |
|
| 3298 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
| 3299 | 3299 | $values = array(); |
| 3300 | 3300 | foreach ($alldata as $cnt) { |
| 3301 | 3301 | $values[] = $cnt['date_count']; |
| 3302 | 3302 | } |
| 3303 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 3304 | - array_splice($alldata,11); |
|
| 3303 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 3304 | + array_splice($alldata, 11); |
|
| 3305 | 3305 | foreach ($alldata as $number) { |
| 3306 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
| 3306 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 3307 | 3307 | } |
| 3308 | 3308 | |
| 3309 | 3309 | echo '-> countAllHours...'."\n"; |
| 3310 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
| 3310 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
| 3311 | 3311 | foreach ($alldata as $number) { |
| 3312 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
| 3312 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
| 3313 | 3313 | } |
| 3314 | 3314 | echo 'Insert last stats update date...'."\n"; |
| 3315 | 3315 | date_default_timezone_set('UTC'); |
| 3316 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
| 3316 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
| 3317 | 3317 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
| 3318 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 3318 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 3319 | 3319 | $this->deleteOldStats($filter_name); |
| 3320 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
| 3320 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
| 3321 | 3321 | } |
| 3322 | 3322 | } |
| 3323 | 3323 | } |
@@ -3330,16 +3330,16 @@ discard block |
||
| 3330 | 3330 | // SUM all previous month to put as year |
| 3331 | 3331 | $previous_year = date('Y'); |
| 3332 | 3332 | $previous_year--; |
| 3333 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 3334 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 3335 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 3336 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 3333 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 3334 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 3335 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 3336 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 3337 | 3337 | $allairlines = $this->getAllAirlineNames(); |
| 3338 | 3338 | foreach ($allairlines as $data) { |
| 3339 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 3340 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 3341 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 3342 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 3339 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 3340 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 3341 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 3342 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 3343 | 3343 | } |
| 3344 | 3344 | |
| 3345 | 3345 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -3348,21 +3348,21 @@ discard block |
||
| 3348 | 3348 | try { |
| 3349 | 3349 | $sth = $this->db->prepare($query); |
| 3350 | 3350 | $sth->execute(); |
| 3351 | - } catch(PDOException $e) { |
|
| 3351 | + } catch (PDOException $e) { |
|
| 3352 | 3352 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3353 | 3353 | } |
| 3354 | 3354 | $query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'"; |
| 3355 | 3355 | try { |
| 3356 | 3356 | $sth = $this->db->prepare($query); |
| 3357 | 3357 | $sth->execute(); |
| 3358 | - } catch(PDOException $e) { |
|
| 3358 | + } catch (PDOException $e) { |
|
| 3359 | 3359 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3360 | 3360 | } |
| 3361 | 3361 | $query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'"; |
| 3362 | 3362 | try { |
| 3363 | 3363 | $sth = $this->db->prepare($query); |
| 3364 | 3364 | $sth->execute(); |
| 3365 | - } catch(PDOException $e) { |
|
| 3365 | + } catch (PDOException $e) { |
|
| 3366 | 3366 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3367 | 3367 | } |
| 3368 | 3368 | } |
@@ -3375,7 +3375,7 @@ discard block |
||
| 3375 | 3375 | try { |
| 3376 | 3376 | $sth = $this->db->prepare($query); |
| 3377 | 3377 | $sth->execute(); |
| 3378 | - } catch(PDOException $e) { |
|
| 3378 | + } catch (PDOException $e) { |
|
| 3379 | 3379 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3380 | 3380 | } |
| 3381 | 3381 | if ($globalDBdriver == 'mysql') { |
@@ -3386,7 +3386,7 @@ discard block |
||
| 3386 | 3386 | try { |
| 3387 | 3387 | $sth = $this->db->prepare($query); |
| 3388 | 3388 | $sth->execute(); |
| 3389 | - } catch(PDOException $e) { |
|
| 3389 | + } catch (PDOException $e) { |
|
| 3390 | 3390 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3391 | 3391 | } |
| 3392 | 3392 | if ($globalDBdriver == 'mysql') { |
@@ -3397,15 +3397,15 @@ discard block |
||
| 3397 | 3397 | try { |
| 3398 | 3398 | $sth = $this->db->prepare($query); |
| 3399 | 3399 | $sth->execute(); |
| 3400 | - } catch(PDOException $e) { |
|
| 3400 | + } catch (PDOException $e) { |
|
| 3401 | 3401 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3402 | 3402 | } |
| 3403 | 3403 | } |
| 3404 | 3404 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
| 3405 | 3405 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 3406 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 3406 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 3407 | 3407 | $this->deleteOldStats(); |
| 3408 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
| 3408 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
| 3409 | 3409 | $lastyearupdate = true; |
| 3410 | 3410 | } |
| 3411 | 3411 | } |
@@ -3427,7 +3427,7 @@ discard block |
||
| 3427 | 3427 | try { |
| 3428 | 3428 | $sth = $this->db->prepare($query); |
| 3429 | 3429 | $sth->execute(); |
| 3430 | - } catch(PDOException $e) { |
|
| 3430 | + } catch (PDOException $e) { |
|
| 3431 | 3431 | return "error : ".$e->getMessage(); |
| 3432 | 3432 | } |
| 3433 | 3433 | echo 'Archive old tracker data...'."\n"; |
@@ -3443,7 +3443,7 @@ discard block |
||
| 3443 | 3443 | try { |
| 3444 | 3444 | $sth = $this->db->prepare($query); |
| 3445 | 3445 | $sth->execute(); |
| 3446 | - } catch(PDOException $e) { |
|
| 3446 | + } catch (PDOException $e) { |
|
| 3447 | 3447 | return "error : ".$e->getMessage(); |
| 3448 | 3448 | } |
| 3449 | 3449 | echo 'Archive old marine data...'."\n"; |
@@ -3459,7 +3459,7 @@ discard block |
||
| 3459 | 3459 | try { |
| 3460 | 3460 | $sth = $this->db->prepare($query); |
| 3461 | 3461 | $sth->execute(); |
| 3462 | - } catch(PDOException $e) { |
|
| 3462 | + } catch (PDOException $e) { |
|
| 3463 | 3463 | return "error : ".$e->getMessage(); |
| 3464 | 3464 | } |
| 3465 | 3465 | } |
@@ -3472,7 +3472,7 @@ discard block |
||
| 3472 | 3472 | try { |
| 3473 | 3473 | $sth = $this->db->prepare($query); |
| 3474 | 3474 | $sth->execute(); |
| 3475 | - } catch(PDOException $e) { |
|
| 3475 | + } catch (PDOException $e) { |
|
| 3476 | 3476 | return "error : ".$e->getMessage(); |
| 3477 | 3477 | } |
| 3478 | 3478 | echo 'Deleting old tracker data...'."\n"; |
@@ -3484,7 +3484,7 @@ discard block |
||
| 3484 | 3484 | try { |
| 3485 | 3485 | $sth = $this->db->prepare($query); |
| 3486 | 3486 | $sth->execute(); |
| 3487 | - } catch(PDOException $e) { |
|
| 3487 | + } catch (PDOException $e) { |
|
| 3488 | 3488 | return "error : ".$e->getMessage(); |
| 3489 | 3489 | } |
| 3490 | 3490 | echo 'Deleting old marine data...'."\n"; |
@@ -3496,14 +3496,14 @@ discard block |
||
| 3496 | 3496 | try { |
| 3497 | 3497 | $sth = $this->db->prepare($query); |
| 3498 | 3498 | $sth->execute(); |
| 3499 | - } catch(PDOException $e) { |
|
| 3499 | + } catch (PDOException $e) { |
|
| 3500 | 3500 | return "error : ".$e->getMessage(); |
| 3501 | 3501 | } |
| 3502 | 3502 | } |
| 3503 | 3503 | if (!isset($lastyearupdate)) { |
| 3504 | 3504 | echo 'Insert last stats update date...'."\n"; |
| 3505 | 3505 | date_default_timezone_set('UTC'); |
| 3506 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
| 3506 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
| 3507 | 3507 | } |
| 3508 | 3508 | if ($globalStatsResetYear) { |
| 3509 | 3509 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Get SQL query part for filter used |
|
| 24 | - * @param array $filter the filter |
|
| 25 | - * @param bool $where |
|
| 26 | - * @param bool $and |
|
| 27 | - * @return string the SQL part |
|
| 28 | - */ |
|
| 22 | + /** |
|
| 23 | + * Get SQL query part for filter used |
|
| 24 | + * @param array $filter the filter |
|
| 25 | + * @param bool $where |
|
| 26 | + * @param bool $and |
|
| 27 | + * @return string the SQL part |
|
| 28 | + */ |
|
| 29 | 29 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 30 | 30 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 31 | 31 | $filters = array(); |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | return $filter_query; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Gets all the spotter information based on the latest data entry |
|
| 103 | - * |
|
| 104 | - * @param string $limit |
|
| 105 | - * @param string $sort |
|
| 106 | - * @param array $filter |
|
| 107 | - * @return array the spotter information |
|
| 108 | - */ |
|
| 101 | + /** |
|
| 102 | + * Gets all the spotter information based on the latest data entry |
|
| 103 | + * |
|
| 104 | + * @param string $limit |
|
| 105 | + * @param string $sort |
|
| 106 | + * @param array $filter |
|
| 107 | + * @return array the spotter information |
|
| 108 | + */ |
|
| 109 | 109 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
| 110 | 110 | { |
| 111 | 111 | global $globalDBdriver, $globalLiveInterval; |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | return $spotter_array; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Gets Minimal Live Spotter data |
|
| 151 | - * |
|
| 152 | - * @param array $filter |
|
| 153 | - * @return array the spotter information |
|
| 154 | - */ |
|
| 149 | + /** |
|
| 150 | + * Gets Minimal Live Spotter data |
|
| 151 | + * |
|
| 152 | + * @param array $filter |
|
| 153 | + * @return array the spotter information |
|
| 154 | + */ |
|
| 155 | 155 | public function getMinLiveTrackerData($filter = array()) |
| 156 | 156 | { |
| 157 | 157 | global $globalDBdriver, $globalLiveInterval; |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | return $spotter_array; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 189 | - * |
|
| 190 | - * @param $coord |
|
| 191 | - * @param array $filter |
|
| 192 | - * @param bool $limit |
|
| 193 | - * @return array the spotter information |
|
| 194 | - */ |
|
| 187 | + /** |
|
| 188 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 189 | + * |
|
| 190 | + * @param $coord |
|
| 191 | + * @param array $filter |
|
| 192 | + * @param bool $limit |
|
| 193 | + * @return array the spotter information |
|
| 194 | + */ |
|
| 195 | 195 | public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
| 196 | 196 | { |
| 197 | 197 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | return $spotter_array; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - /** |
|
| 268 | - * Gets number of latest data entry |
|
| 269 | - * |
|
| 270 | - * @param array $filter |
|
| 271 | - * @return String number of entry |
|
| 272 | - */ |
|
| 267 | + /** |
|
| 268 | + * Gets number of latest data entry |
|
| 269 | + * |
|
| 270 | + * @param array $filter |
|
| 271 | + * @return String number of entry |
|
| 272 | + */ |
|
| 273 | 273 | public function getLiveTrackerCount($filter = array()) |
| 274 | 274 | { |
| 275 | 275 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,13 +293,13 @@ discard block |
||
| 293 | 293 | return $result['nb']; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - /** |
|
| 297 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 298 | - * |
|
| 299 | - * @param $coord |
|
| 300 | - * @param array $filter |
|
| 301 | - * @return array the spotter information |
|
| 302 | - */ |
|
| 296 | + /** |
|
| 297 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 298 | + * |
|
| 299 | + * @param $coord |
|
| 300 | + * @param array $filter |
|
| 301 | + * @return array the spotter information |
|
| 302 | + */ |
|
| 303 | 303 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
| 304 | 304 | { |
| 305 | 305 | global $globalDBdriver, $globalLiveInterval; |
@@ -322,13 +322,13 @@ discard block |
||
| 322 | 322 | return $spotter_array; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 327 | - * |
|
| 328 | - * @param $coord |
|
| 329 | - * @param array $filter |
|
| 330 | - * @return array the spotter information |
|
| 331 | - */ |
|
| 325 | + /** |
|
| 326 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 327 | + * |
|
| 328 | + * @param $coord |
|
| 329 | + * @param array $filter |
|
| 330 | + * @return array the spotter information |
|
| 331 | + */ |
|
| 332 | 332 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
| 333 | 333 | { |
| 334 | 334 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -395,15 +395,15 @@ discard block |
||
| 395 | 395 | return $spotter_array; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - /** |
|
| 399 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 400 | - * |
|
| 401 | - * @param $lat |
|
| 402 | - * @param $lng |
|
| 403 | - * @param $radius |
|
| 404 | - * @param $interval |
|
| 405 | - * @return array the spotter information |
|
| 406 | - */ |
|
| 398 | + /** |
|
| 399 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 400 | + * |
|
| 401 | + * @param $lat |
|
| 402 | + * @param $lng |
|
| 403 | + * @param $radius |
|
| 404 | + * @param $interval |
|
| 405 | + * @return array the spotter information |
|
| 406 | + */ |
|
| 407 | 407 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
| 408 | 408 | { |
| 409 | 409 | $Tracker = new Tracker($this->db); |
@@ -460,100 +460,100 @@ discard block |
||
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | |
| 463 | - /** |
|
| 464 | - * Gets all the spotter information based on a particular callsign |
|
| 465 | - * |
|
| 466 | - * @param $ident |
|
| 467 | - * @return array the spotter information |
|
| 468 | - */ |
|
| 463 | + /** |
|
| 464 | + * Gets all the spotter information based on a particular callsign |
|
| 465 | + * |
|
| 466 | + * @param $ident |
|
| 467 | + * @return array the spotter information |
|
| 468 | + */ |
|
| 469 | 469 | public function getLastLiveTrackerDataByIdent($ident) |
| 470 | 470 | { |
| 471 | 471 | $Tracker = new Tracker($this->db); |
| 472 | 472 | date_default_timezone_set('UTC'); |
| 473 | 473 | |
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 475 | - $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'; |
|
| 475 | + $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'; |
|
| 476 | 476 | |
| 477 | 477 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 478 | 478 | |
| 479 | 479 | return $spotter_array; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - /** |
|
| 483 | - * Gets all the spotter information based on a particular callsign |
|
| 484 | - * |
|
| 485 | - * @param $ident |
|
| 486 | - * @param $date |
|
| 487 | - * @return array the spotter information |
|
| 488 | - */ |
|
| 482 | + /** |
|
| 483 | + * Gets all the spotter information based on a particular callsign |
|
| 484 | + * |
|
| 485 | + * @param $ident |
|
| 486 | + * @param $date |
|
| 487 | + * @return array the spotter information |
|
| 488 | + */ |
|
| 489 | 489 | public function getDateLiveTrackerDataByIdent($ident,$date) |
| 490 | 490 | { |
| 491 | 491 | $Tracker = new Tracker($this->db); |
| 492 | 492 | date_default_timezone_set('UTC'); |
| 493 | 493 | |
| 494 | 494 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 495 | - $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'; |
|
| 495 | + $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'; |
|
| 496 | 496 | |
| 497 | - $date = date('c',$date); |
|
| 497 | + $date = date('c',$date); |
|
| 498 | 498 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 499 | 499 | |
| 500 | 500 | return $spotter_array; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * Gets last spotter information based on a particular callsign |
|
| 505 | - * |
|
| 506 | - * @param $id |
|
| 507 | - * @return array the spotter information |
|
| 508 | - */ |
|
| 503 | + /** |
|
| 504 | + * Gets last spotter information based on a particular callsign |
|
| 505 | + * |
|
| 506 | + * @param $id |
|
| 507 | + * @return array the spotter information |
|
| 508 | + */ |
|
| 509 | 509 | public function getLastLiveTrackerDataById($id) |
| 510 | 510 | { |
| 511 | 511 | $Tracker = new Tracker($this->db); |
| 512 | 512 | date_default_timezone_set('UTC'); |
| 513 | 513 | |
| 514 | 514 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 515 | - $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'; |
|
| 515 | + $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'; |
|
| 516 | 516 | |
| 517 | 517 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
| 518 | 518 | |
| 519 | 519 | return $spotter_array; |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - /** |
|
| 523 | - * Gets last spotter information based on a particular callsign |
|
| 524 | - * |
|
| 525 | - * @param $id |
|
| 526 | - * @param $date |
|
| 527 | - * @return array the spotter information |
|
| 528 | - */ |
|
| 522 | + /** |
|
| 523 | + * Gets last spotter information based on a particular callsign |
|
| 524 | + * |
|
| 525 | + * @param $id |
|
| 526 | + * @param $date |
|
| 527 | + * @return array the spotter information |
|
| 528 | + */ |
|
| 529 | 529 | public function getDateLiveTrackerDataById($id,$date) |
| 530 | 530 | { |
| 531 | 531 | $Tracker = new Tracker($this->db); |
| 532 | 532 | date_default_timezone_set('UTC'); |
| 533 | 533 | |
| 534 | 534 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 535 | - $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'; |
|
| 536 | - $date = date('c',$date); |
|
| 535 | + $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'; |
|
| 536 | + $date = date('c',$date); |
|
| 537 | 537 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 538 | 538 | |
| 539 | 539 | return $spotter_array; |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - /** |
|
| 543 | - * Gets altitude information based on a particular callsign |
|
| 544 | - * |
|
| 545 | - * @param $ident |
|
| 546 | - * @return array the spotter information |
|
| 547 | - */ |
|
| 542 | + /** |
|
| 543 | + * Gets altitude information based on a particular callsign |
|
| 544 | + * |
|
| 545 | + * @param $ident |
|
| 546 | + * @return array the spotter information |
|
| 547 | + */ |
|
| 548 | 548 | public function getAltitudeLiveTrackerDataByIdent($ident) |
| 549 | 549 | { |
| 550 | 550 | |
| 551 | 551 | date_default_timezone_set('UTC'); |
| 552 | 552 | |
| 553 | 553 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 554 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 554 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 555 | 555 | |
| 556 | - try { |
|
| 556 | + try { |
|
| 557 | 557 | |
| 558 | 558 | $sth = $this->db->prepare($query); |
| 559 | 559 | $sth->execute(array(':ident' => $ident)); |
@@ -566,13 +566,13 @@ discard block |
||
| 566 | 566 | return $spotter_array; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - /** |
|
| 570 | - * Gets all the spotter information based on a particular id |
|
| 571 | - * |
|
| 572 | - * @param $id |
|
| 573 | - * @param bool $liveinterval |
|
| 574 | - * @return array the spotter information |
|
| 575 | - */ |
|
| 569 | + /** |
|
| 570 | + * Gets all the spotter information based on a particular id |
|
| 571 | + * |
|
| 572 | + * @param $id |
|
| 573 | + * @param bool $liveinterval |
|
| 574 | + * @return array the spotter information |
|
| 575 | + */ |
|
| 576 | 576 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
| 577 | 577 | { |
| 578 | 578 | global $globalDBdriver, $globalLiveInterval; |
@@ -602,18 +602,18 @@ discard block |
||
| 602 | 602 | return $spotter_array; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - /** |
|
| 606 | - * Gets all the spotter information based on a particular ident |
|
| 607 | - * |
|
| 608 | - * @param $ident |
|
| 609 | - * @return array the spotter information |
|
| 610 | - */ |
|
| 605 | + /** |
|
| 606 | + * Gets all the spotter information based on a particular ident |
|
| 607 | + * |
|
| 608 | + * @param $ident |
|
| 609 | + * @return array the spotter information |
|
| 610 | + */ |
|
| 611 | 611 | public function getAllLiveTrackerDataByIdent($ident) |
| 612 | 612 | { |
| 613 | 613 | date_default_timezone_set('UTC'); |
| 614 | 614 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 615 | 615 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
| 616 | - try { |
|
| 616 | + try { |
|
| 617 | 617 | |
| 618 | 618 | $sth = $this->db->prepare($query); |
| 619 | 619 | $sth->execute(array(':ident' => $ident)); |
@@ -627,23 +627,23 @@ discard block |
||
| 627 | 627 | |
| 628 | 628 | |
| 629 | 629 | /** |
| 630 | - * Deletes all info in the table |
|
| 631 | - * |
|
| 632 | - * @return String success or false |
|
| 633 | - * |
|
| 634 | - */ |
|
| 630 | + * Deletes all info in the table |
|
| 631 | + * |
|
| 632 | + * @return String success or false |
|
| 633 | + * |
|
| 634 | + */ |
|
| 635 | 635 | public function deleteLiveTrackerData() |
| 636 | 636 | { |
| 637 | 637 | global $globalDBdriver; |
| 638 | 638 | if ($globalDBdriver == 'mysql') { |
| 639 | 639 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
| 640 | 640 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
| 641 | - //$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)"; |
|
| 641 | + //$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)"; |
|
| 642 | 642 | } else { |
| 643 | 643 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - try { |
|
| 646 | + try { |
|
| 647 | 647 | |
| 648 | 648 | $sth = $this->db->prepare($query); |
| 649 | 649 | $sth->execute(); |
@@ -655,18 +655,18 @@ discard block |
||
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
| 658 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 659 | - * |
|
| 660 | - * @return String success or false |
|
| 661 | - * |
|
| 662 | - */ |
|
| 658 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 659 | + * |
|
| 660 | + * @return String success or false |
|
| 661 | + * |
|
| 662 | + */ |
|
| 663 | 663 | public function deleteLiveTrackerDataNotUpdated() |
| 664 | 664 | { |
| 665 | 665 | global $globalDBdriver, $globalDebug; |
| 666 | 666 | if ($globalDBdriver == 'mysql') { |
| 667 | 667 | //$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'; |
| 668 | - $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"; |
|
| 669 | - try { |
|
| 668 | + $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"; |
|
| 669 | + try { |
|
| 670 | 670 | |
| 671 | 671 | $sth = $this->db->prepare($query); |
| 672 | 672 | $sth->execute(); |
@@ -674,8 +674,8 @@ discard block |
||
| 674 | 674 | return "error"; |
| 675 | 675 | } |
| 676 | 676 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 677 | - $i = 0; |
|
| 678 | - $j =0; |
|
| 677 | + $i = 0; |
|
| 678 | + $j =0; |
|
| 679 | 679 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 680 | 680 | foreach($all as $row) |
| 681 | 681 | { |
@@ -683,20 +683,20 @@ discard block |
||
| 683 | 683 | $j++; |
| 684 | 684 | if ($j == 30) { |
| 685 | 685 | if ($globalDebug) echo "."; |
| 686 | - try { |
|
| 686 | + try { |
|
| 687 | 687 | |
| 688 | 688 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 689 | 689 | $sth->execute(); |
| 690 | 690 | } catch(PDOException $e) { |
| 691 | 691 | return "error"; |
| 692 | 692 | } |
| 693 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 694 | - $j = 0; |
|
| 693 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 694 | + $j = 0; |
|
| 695 | 695 | } |
| 696 | 696 | $query_delete .= "'".$row['famtrackid']."',"; |
| 697 | 697 | } |
| 698 | 698 | if ($i > 0) { |
| 699 | - try { |
|
| 699 | + try { |
|
| 700 | 700 | |
| 701 | 701 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 702 | 702 | $sth->execute(); |
@@ -707,9 +707,9 @@ discard block |
||
| 707 | 707 | return "success"; |
| 708 | 708 | } elseif ($globalDBdriver == 'pgsql') { |
| 709 | 709 | //$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"; |
| 710 | - //$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"; |
|
| 711 | - $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)"; |
|
| 712 | - try { |
|
| 710 | + //$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"; |
|
| 711 | + $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)"; |
|
| 712 | + try { |
|
| 713 | 713 | |
| 714 | 714 | $sth = $this->db->prepare($query); |
| 715 | 715 | $sth->execute(); |
@@ -752,18 +752,18 @@ discard block |
||
| 752 | 752 | } |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | - /** |
|
| 756 | - * Deletes all info in the table for an ident |
|
| 757 | - * |
|
| 758 | - * @param $ident |
|
| 759 | - * @return String success or false |
|
| 760 | - */ |
|
| 755 | + /** |
|
| 756 | + * Deletes all info in the table for an ident |
|
| 757 | + * |
|
| 758 | + * @param $ident |
|
| 759 | + * @return String success or false |
|
| 760 | + */ |
|
| 761 | 761 | public function deleteLiveTrackerDataByIdent($ident) |
| 762 | 762 | { |
| 763 | 763 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 764 | 764 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
| 765 | 765 | |
| 766 | - try { |
|
| 766 | + try { |
|
| 767 | 767 | |
| 768 | 768 | $sth = $this->db->prepare($query); |
| 769 | 769 | $sth->execute(array(':ident' => $ident)); |
@@ -774,18 +774,18 @@ discard block |
||
| 774 | 774 | return "success"; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - /** |
|
| 778 | - * Deletes all info in the table for an id |
|
| 779 | - * |
|
| 780 | - * @param $id |
|
| 781 | - * @return String success or false |
|
| 782 | - */ |
|
| 777 | + /** |
|
| 778 | + * Deletes all info in the table for an id |
|
| 779 | + * |
|
| 780 | + * @param $id |
|
| 781 | + * @return String success or false |
|
| 782 | + */ |
|
| 783 | 783 | public function deleteLiveTrackerDataById($id) |
| 784 | 784 | { |
| 785 | 785 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 786 | 786 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
| 787 | 787 | |
| 788 | - try { |
|
| 788 | + try { |
|
| 789 | 789 | |
| 790 | 790 | $sth = $this->db->prepare($query); |
| 791 | 791 | $sth->execute(array(':id' => $id)); |
@@ -797,12 +797,12 @@ discard block |
||
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | |
| 800 | - /** |
|
| 801 | - * Gets the aircraft ident within the last hour |
|
| 802 | - * |
|
| 803 | - * @param $ident |
|
| 804 | - * @return String the ident |
|
| 805 | - */ |
|
| 800 | + /** |
|
| 801 | + * Gets the aircraft ident within the last hour |
|
| 802 | + * |
|
| 803 | + * @param $ident |
|
| 804 | + * @return String the ident |
|
| 805 | + */ |
|
| 806 | 806 | public function getIdentFromLastHour($ident) |
| 807 | 807 | { |
| 808 | 808 | global $globalDBdriver, $globalTimezone; |
@@ -828,14 +828,14 @@ discard block |
||
| 828 | 828 | $ident_result = $row['ident']; |
| 829 | 829 | } |
| 830 | 830 | return $ident_result; |
| 831 | - } |
|
| 832 | - |
|
| 833 | - /** |
|
| 834 | - * Check recent aircraft |
|
| 835 | - * |
|
| 836 | - * @param $ident |
|
| 837 | - * @return String the ident |
|
| 838 | - */ |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + /** |
|
| 834 | + * Check recent aircraft |
|
| 835 | + * |
|
| 836 | + * @param $ident |
|
| 837 | + * @return String the ident |
|
| 838 | + */ |
|
| 839 | 839 | public function checkIdentRecent($ident) |
| 840 | 840 | { |
| 841 | 841 | global $globalDBdriver, $globalTimezone; |
@@ -861,14 +861,14 @@ discard block |
||
| 861 | 861 | $ident_result = $row['famtrackid']; |
| 862 | 862 | } |
| 863 | 863 | return $ident_result; |
| 864 | - } |
|
| 865 | - |
|
| 866 | - /** |
|
| 867 | - * Check recent aircraft by id |
|
| 868 | - * |
|
| 869 | - * @param $id |
|
| 870 | - * @return String the ident |
|
| 871 | - */ |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + /** |
|
| 867 | + * Check recent aircraft by id |
|
| 868 | + * |
|
| 869 | + * @param $id |
|
| 870 | + * @return String the ident |
|
| 871 | + */ |
|
| 872 | 872 | public function checkIdRecent($id) |
| 873 | 873 | { |
| 874 | 874 | global $globalDBdriver, $globalTimezone; |
@@ -894,28 +894,28 @@ discard block |
||
| 894 | 894 | $ident_result = $row['famtrackid']; |
| 895 | 895 | } |
| 896 | 896 | return $ident_result; |
| 897 | - } |
|
| 898 | - |
|
| 899 | - /** |
|
| 900 | - * Adds a new spotter data |
|
| 901 | - * |
|
| 902 | - * @param String $famtrackid the ID from flightaware |
|
| 903 | - * @param String $ident the flight ident |
|
| 904 | - * @param string $latitude |
|
| 905 | - * @param string $longitude |
|
| 906 | - * @param string $altitude |
|
| 907 | - * @param string $heading |
|
| 908 | - * @param string $groundspeed |
|
| 909 | - * @param string $date |
|
| 910 | - * @param bool $putinarchive |
|
| 911 | - * @param string $comment |
|
| 912 | - * @param string $type |
|
| 913 | - * @param bool $noarchive |
|
| 914 | - * @param string $format_source |
|
| 915 | - * @param string $source_name |
|
| 916 | - * @param string $over_country |
|
| 917 | - * @return String success or false |
|
| 918 | - */ |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + /** |
|
| 900 | + * Adds a new spotter data |
|
| 901 | + * |
|
| 902 | + * @param String $famtrackid the ID from flightaware |
|
| 903 | + * @param String $ident the flight ident |
|
| 904 | + * @param string $latitude |
|
| 905 | + * @param string $longitude |
|
| 906 | + * @param string $altitude |
|
| 907 | + * @param string $heading |
|
| 908 | + * @param string $groundspeed |
|
| 909 | + * @param string $date |
|
| 910 | + * @param bool $putinarchive |
|
| 911 | + * @param string $comment |
|
| 912 | + * @param string $type |
|
| 913 | + * @param bool $noarchive |
|
| 914 | + * @param string $format_source |
|
| 915 | + * @param string $source_name |
|
| 916 | + * @param string $over_country |
|
| 917 | + * @return String success or false |
|
| 918 | + */ |
|
| 919 | 919 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 920 | 920 | { |
| 921 | 921 | global $globalURL, $globalArchive, $globalDebug; |
@@ -988,8 +988,8 @@ discard block |
||
| 988 | 988 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 989 | 989 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 990 | 990 | |
| 991 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 992 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 991 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 992 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 993 | 993 | |
| 994 | 994 | $query = ''; |
| 995 | 995 | if ($globalArchive) { |
@@ -1007,15 +1007,15 @@ discard block |
||
| 1007 | 1007 | } catch(PDOException $e) { |
| 1008 | 1008 | return "error : ".$e->getMessage(); |
| 1009 | 1009 | } |
| 1010 | - /* |
|
| 1010 | + /* |
|
| 1011 | 1011 | echo 'putinarchive : '.$putinarchive."\n"; |
| 1012 | 1012 | echo 'noarchive : '.$noarchive."\n"; |
| 1013 | 1013 | */ |
| 1014 | 1014 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1015 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 1016 | - $TrackerArchive = new TrackerArchive($this->db); |
|
| 1017 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 1018 | - if ($globalDebug) echo $result.')'; |
|
| 1015 | + if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 1016 | + $TrackerArchive = new TrackerArchive($this->db); |
|
| 1017 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 1018 | + if ($globalDebug) echo $result.')'; |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | return "success"; |
@@ -26,33 +26,33 @@ discard block |
||
| 26 | 26 | * @param bool $and |
| 27 | 27 | * @return string the SQL part |
| 28 | 28 | */ |
| 29 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 29 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 30 | 30 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 31 | 31 | $filters = array(); |
| 32 | 32 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 33 | 33 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 34 | 34 | $filters = $globalStatsFilters[$globalFilterName]; |
| 35 | 35 | } else { |
| 36 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 36 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | if (isset($filter[0]['source'])) { |
| 40 | - $filters = array_merge($filters,$filter); |
|
| 40 | + $filters = array_merge($filters, $filter); |
|
| 41 | 41 | } |
| 42 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 42 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 43 | 43 | $filter_query_join = ''; |
| 44 | 44 | $filter_query_where = ''; |
| 45 | - foreach($filters as $flt) { |
|
| 45 | + foreach ($filters as $flt) { |
|
| 46 | 46 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 47 | 47 | if (isset($flt['source'])) { |
| 48 | - $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"; |
|
| 48 | + $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"; |
|
| 49 | 49 | } else { |
| 50 | - $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"; |
|
| 50 | + $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"; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 55 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 55 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 56 | 56 | } |
| 57 | 57 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 58 | 58 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -84,15 +84,15 @@ discard block |
||
| 84 | 84 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 87 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 88 | 88 | } |
| 89 | 89 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 90 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 90 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 91 | 91 | } |
| 92 | 92 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 93 | 93 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 94 | 94 | if ($filter_query_where != '') { |
| 95 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 95 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 96 | 96 | } |
| 97 | 97 | $filter_query = $filter_query_join.$filter_query_where; |
| 98 | 98 | return $filter_query; |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | if ($limit != '') |
| 118 | 118 | { |
| 119 | 119 | $limit_array = explode(',', $limit); |
| 120 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 121 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 120 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 121 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 122 | 122 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 123 | 123 | { |
| 124 | 124 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } else { |
| 142 | 142 | $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; |
| 143 | 143 | } |
| 144 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 144 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 145 | 145 | |
| 146 | 146 | return $spotter_array; |
| 147 | 147 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | global $globalDBdriver, $globalLiveInterval; |
| 158 | 158 | date_default_timezone_set('UTC'); |
| 159 | 159 | |
| 160 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 160 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 161 | 161 | |
| 162 | 162 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 163 | 163 | if ($globalDBdriver == 'mysql') { |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | try { |
| 176 | 176 | $sth = $this->db->prepare($query); |
| 177 | 177 | $sth->execute(); |
| 178 | - } catch(PDOException $e) { |
|
| 178 | + } catch (PDOException $e) { |
|
| 179 | 179 | echo $e->getMessage(); |
| 180 | 180 | die; |
| 181 | 181 | } |
@@ -192,25 +192,25 @@ discard block |
||
| 192 | 192 | * @param bool $limit |
| 193 | 193 | * @return array the spotter information |
| 194 | 194 | */ |
| 195 | - public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
|
| 195 | + public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false) |
|
| 196 | 196 | { |
| 197 | 197 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
| 198 | 198 | date_default_timezone_set('UTC'); |
| 199 | 199 | $usecoord = false; |
| 200 | 200 | if (is_array($coord) && !empty($coord)) { |
| 201 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 202 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 203 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 204 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 201 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 202 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 203 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 204 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 205 | 205 | $usecoord = true; |
| 206 | 206 | } |
| 207 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 207 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 208 | 208 | |
| 209 | 209 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 210 | 210 | if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300'; |
| 211 | 211 | if ($globalDBdriver == 'mysql') { |
| 212 | 212 | if (isset($globalArchive) && $globalArchive) { |
| 213 | - $query = "SELECT * FROM ( |
|
| 213 | + $query = "SELECT * FROM ( |
|
| 214 | 214 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 215 | 215 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 216 | 216 | if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | } else { |
| 234 | 234 | if (isset($globalArchive) && $globalArchive) { |
| 235 | - $query = "SELECT * FROM ( |
|
| 235 | + $query = "SELECT * FROM ( |
|
| 236 | 236 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 237 | 237 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 238 | 238 | if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | try { |
| 257 | 257 | $sth = $this->db->prepare($query); |
| 258 | 258 | $sth->execute(); |
| 259 | - } catch(PDOException $e) { |
|
| 259 | + } catch (PDOException $e) { |
|
| 260 | 260 | echo $e->getMessage(); |
| 261 | 261 | die; |
| 262 | 262 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | public function getLiveTrackerCount($filter = array()) |
| 274 | 274 | { |
| 275 | 275 | global $globalDBdriver, $globalLiveInterval; |
| 276 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 276 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 277 | 277 | |
| 278 | 278 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 279 | 279 | if ($globalDBdriver == 'mysql') { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | try { |
| 285 | 285 | $sth = $this->db->prepare($query); |
| 286 | 286 | $sth->execute(); |
| 287 | - } catch(PDOException $e) { |
|
| 287 | + } catch (PDOException $e) { |
|
| 288 | 288 | echo $e->getMessage(); |
| 289 | 289 | die; |
| 290 | 290 | } |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | $filter_query = $this->getFilter($filter); |
| 309 | 309 | |
| 310 | 310 | if (is_array($coord)) { |
| 311 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 312 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 313 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 314 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 311 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 312 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 313 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 314 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 315 | 315 | } else return array(); |
| 316 | 316 | if ($globalDBdriver == 'mysql') { |
| 317 | 317 | $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; |
@@ -334,13 +334,13 @@ discard block |
||
| 334 | 334 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 335 | 335 | $Tracker = new Tracker($this->db); |
| 336 | 336 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 337 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 337 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 338 | 338 | |
| 339 | 339 | if (is_array($coord)) { |
| 340 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 341 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 342 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 343 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 340 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 341 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 342 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 343 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 344 | 344 | } else return array(); |
| 345 | 345 | /* |
| 346 | 346 | if ($globalDBdriver == 'mysql') { |
@@ -354,13 +354,13 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | if ($globalDBdriver == 'mysql') { |
| 356 | 356 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 357 | - $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 |
|
| 357 | + $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 |
|
| 358 | 358 | FROM tracker_live |
| 359 | 359 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= tracker_live.date |
| 360 | 360 | AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 361 | 361 | AND tracker_live.latitude <> 0 AND tracker_live.longitude <> 0 ORDER BY date DESC'; |
| 362 | 362 | } else { |
| 363 | - $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 |
|
| 363 | + $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 |
|
| 364 | 364 | FROM tracker_live |
| 365 | 365 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate |
| 366 | 366 | FROM tracker_live l |
@@ -372,14 +372,14 @@ discard block |
||
| 372 | 372 | } |
| 373 | 373 | } else { |
| 374 | 374 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 375 | - $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 |
|
| 375 | + $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 |
|
| 376 | 376 | FROM tracker_live |
| 377 | 377 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date |
| 378 | 378 | AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
| 379 | 379 | AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 380 | 380 | AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ORDER BY date DESC"; |
| 381 | 381 | } else { |
| 382 | - $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 |
|
| 382 | + $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 |
|
| 383 | 383 | FROM tracker_live |
| 384 | 384 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate |
| 385 | 385 | FROM tracker_live l |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | if ($interval == '1m') |
| 440 | 440 | { |
| 441 | 441 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 442 | - } else if ($interval == '15m'){ |
|
| 442 | + } else if ($interval == '15m') { |
|
| 443 | 443 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
| 444 | 444 | } |
| 445 | 445 | } |
@@ -447,14 +447,14 @@ discard block |
||
| 447 | 447 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - $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 |
|
| 450 | + $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 |
|
| 451 | 451 | WHERE tracker_live.latitude <> '' |
| 452 | 452 | AND tracker_live.longitude <> '' |
| 453 | 453 | ".$additional_query." |
| 454 | 454 | HAVING distance < :radius |
| 455 | 455 | ORDER BY distance"; |
| 456 | 456 | |
| 457 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 457 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 458 | 458 | |
| 459 | 459 | return $spotter_array; |
| 460 | 460 | } |
@@ -472,9 +472,9 @@ discard block |
||
| 472 | 472 | date_default_timezone_set('UTC'); |
| 473 | 473 | |
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 475 | - $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'; |
|
| 475 | + $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'; |
|
| 476 | 476 | |
| 477 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 477 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 478 | 478 | |
| 479 | 479 | return $spotter_array; |
| 480 | 480 | } |
@@ -486,16 +486,16 @@ discard block |
||
| 486 | 486 | * @param $date |
| 487 | 487 | * @return array the spotter information |
| 488 | 488 | */ |
| 489 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
| 489 | + public function getDateLiveTrackerDataByIdent($ident, $date) |
|
| 490 | 490 | { |
| 491 | 491 | $Tracker = new Tracker($this->db); |
| 492 | 492 | date_default_timezone_set('UTC'); |
| 493 | 493 | |
| 494 | 494 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 495 | - $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'; |
|
| 495 | + $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'; |
|
| 496 | 496 | |
| 497 | - $date = date('c',$date); |
|
| 498 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 497 | + $date = date('c', $date); |
|
| 498 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 499 | 499 | |
| 500 | 500 | return $spotter_array; |
| 501 | 501 | } |
@@ -512,9 +512,9 @@ discard block |
||
| 512 | 512 | date_default_timezone_set('UTC'); |
| 513 | 513 | |
| 514 | 514 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 515 | - $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'; |
|
| 515 | + $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'; |
|
| 516 | 516 | |
| 517 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 517 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 518 | 518 | |
| 519 | 519 | return $spotter_array; |
| 520 | 520 | } |
@@ -526,15 +526,15 @@ discard block |
||
| 526 | 526 | * @param $date |
| 527 | 527 | * @return array the spotter information |
| 528 | 528 | */ |
| 529 | - public function getDateLiveTrackerDataById($id,$date) |
|
| 529 | + public function getDateLiveTrackerDataById($id, $date) |
|
| 530 | 530 | { |
| 531 | 531 | $Tracker = new Tracker($this->db); |
| 532 | 532 | date_default_timezone_set('UTC'); |
| 533 | 533 | |
| 534 | 534 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 535 | - $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'; |
|
| 536 | - $date = date('c',$date); |
|
| 537 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 535 | + $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'; |
|
| 536 | + $date = date('c', $date); |
|
| 537 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 538 | 538 | |
| 539 | 539 | return $spotter_array; |
| 540 | 540 | } |
@@ -551,13 +551,13 @@ discard block |
||
| 551 | 551 | date_default_timezone_set('UTC'); |
| 552 | 552 | |
| 553 | 553 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 554 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 554 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 555 | 555 | |
| 556 | 556 | try { |
| 557 | 557 | |
| 558 | 558 | $sth = $this->db->prepare($query); |
| 559 | 559 | $sth->execute(array(':ident' => $ident)); |
| 560 | - } catch(PDOException $e) { |
|
| 560 | + } catch (PDOException $e) { |
|
| 561 | 561 | echo $e->getMessage(); |
| 562 | 562 | die; |
| 563 | 563 | } |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | * @param bool $liveinterval |
| 574 | 574 | * @return array the spotter information |
| 575 | 575 | */ |
| 576 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
| 576 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
| 577 | 577 | { |
| 578 | 578 | global $globalDBdriver, $globalLiveInterval; |
| 579 | 579 | date_default_timezone_set('UTC'); |
@@ -582,19 +582,19 @@ discard block |
||
| 582 | 582 | if ($globalDBdriver == 'mysql') { |
| 583 | 583 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 584 | 584 | if ($liveinterval === true) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 585 | - elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'"; |
|
| 585 | + elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'"; |
|
| 586 | 586 | $query .= ' ORDER BY date'; |
| 587 | 587 | } else { |
| 588 | 588 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 589 | 589 | if ($liveinterval === true) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
| 590 | - elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'"; |
|
| 590 | + elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'"; |
|
| 591 | 591 | $query .= ' ORDER BY date'; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | try { |
| 595 | 595 | $sth = $this->db->prepare($query); |
| 596 | 596 | $sth->execute(array(':id' => $id)); |
| 597 | - } catch(PDOException $e) { |
|
| 597 | + } catch (PDOException $e) { |
|
| 598 | 598 | echo $e->getMessage(); |
| 599 | 599 | die; |
| 600 | 600 | } |
@@ -612,12 +612,12 @@ discard block |
||
| 612 | 612 | { |
| 613 | 613 | date_default_timezone_set('UTC'); |
| 614 | 614 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 615 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 615 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 616 | 616 | try { |
| 617 | 617 | |
| 618 | 618 | $sth = $this->db->prepare($query); |
| 619 | 619 | $sth->execute(array(':ident' => $ident)); |
| 620 | - } catch(PDOException $e) { |
|
| 620 | + } catch (PDOException $e) { |
|
| 621 | 621 | echo $e->getMessage(); |
| 622 | 622 | die; |
| 623 | 623 | } |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | |
| 648 | 648 | $sth = $this->db->prepare($query); |
| 649 | 649 | $sth->execute(); |
| 650 | - } catch(PDOException $e) { |
|
| 650 | + } catch (PDOException $e) { |
|
| 651 | 651 | return "error"; |
| 652 | 652 | } |
| 653 | 653 | |
@@ -670,14 +670,14 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | $sth = $this->db->prepare($query); |
| 672 | 672 | $sth->execute(); |
| 673 | - } catch(PDOException $e) { |
|
| 673 | + } catch (PDOException $e) { |
|
| 674 | 674 | return "error"; |
| 675 | 675 | } |
| 676 | 676 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 677 | 677 | $i = 0; |
| 678 | - $j =0; |
|
| 678 | + $j = 0; |
|
| 679 | 679 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 680 | - foreach($all as $row) |
|
| 680 | + foreach ($all as $row) |
|
| 681 | 681 | { |
| 682 | 682 | $i++; |
| 683 | 683 | $j++; |
@@ -685,9 +685,9 @@ discard block |
||
| 685 | 685 | if ($globalDebug) echo "."; |
| 686 | 686 | try { |
| 687 | 687 | |
| 688 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 688 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 689 | 689 | $sth->execute(); |
| 690 | - } catch(PDOException $e) { |
|
| 690 | + } catch (PDOException $e) { |
|
| 691 | 691 | return "error"; |
| 692 | 692 | } |
| 693 | 693 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -698,9 +698,9 @@ discard block |
||
| 698 | 698 | if ($i > 0) { |
| 699 | 699 | try { |
| 700 | 700 | |
| 701 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 701 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 702 | 702 | $sth->execute(); |
| 703 | - } catch(PDOException $e) { |
|
| 703 | + } catch (PDOException $e) { |
|
| 704 | 704 | return "error"; |
| 705 | 705 | } |
| 706 | 706 | } |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | |
| 714 | 714 | $sth = $this->db->prepare($query); |
| 715 | 715 | $sth->execute(); |
| 716 | - } catch(PDOException $e) { |
|
| 716 | + } catch (PDOException $e) { |
|
| 717 | 717 | return "error"; |
| 718 | 718 | } |
| 719 | 719 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -761,13 +761,13 @@ discard block |
||
| 761 | 761 | public function deleteLiveTrackerDataByIdent($ident) |
| 762 | 762 | { |
| 763 | 763 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 764 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 764 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 765 | 765 | |
| 766 | 766 | try { |
| 767 | 767 | |
| 768 | 768 | $sth = $this->db->prepare($query); |
| 769 | 769 | $sth->execute(array(':ident' => $ident)); |
| 770 | - } catch(PDOException $e) { |
|
| 770 | + } catch (PDOException $e) { |
|
| 771 | 771 | return "error"; |
| 772 | 772 | } |
| 773 | 773 | |
@@ -783,13 +783,13 @@ discard block |
||
| 783 | 783 | public function deleteLiveTrackerDataById($id) |
| 784 | 784 | { |
| 785 | 785 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 786 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 786 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 787 | 787 | |
| 788 | 788 | try { |
| 789 | 789 | |
| 790 | 790 | $sth = $this->db->prepare($query); |
| 791 | 791 | $sth->execute(array(':id' => $id)); |
| 792 | - } catch(PDOException $e) { |
|
| 792 | + } catch (PDOException $e) { |
|
| 793 | 793 | return "error"; |
| 794 | 794 | } |
| 795 | 795 | |
@@ -807,13 +807,13 @@ discard block |
||
| 807 | 807 | { |
| 808 | 808 | global $globalDBdriver, $globalTimezone; |
| 809 | 809 | if ($globalDBdriver == 'mysql') { |
| 810 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 810 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 811 | 811 | WHERE tracker_live.ident = :ident |
| 812 | 812 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 813 | 813 | AND tracker_live.date < UTC_TIMESTAMP()'; |
| 814 | 814 | $query_data = array(':ident' => $ident); |
| 815 | 815 | } else { |
| 816 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 816 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 817 | 817 | WHERE tracker_live.ident = :ident |
| 818 | 818 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 819 | 819 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -822,8 +822,8 @@ discard block |
||
| 822 | 822 | |
| 823 | 823 | $sth = $this->db->prepare($query); |
| 824 | 824 | $sth->execute($query_data); |
| 825 | - $ident_result=''; |
|
| 826 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 825 | + $ident_result = ''; |
|
| 826 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 827 | 827 | { |
| 828 | 828 | $ident_result = $row['ident']; |
| 829 | 829 | } |
@@ -840,13 +840,13 @@ discard block |
||
| 840 | 840 | { |
| 841 | 841 | global $globalDBdriver, $globalTimezone; |
| 842 | 842 | if ($globalDBdriver == 'mysql') { |
| 843 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 843 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 844 | 844 | WHERE tracker_live.ident = :ident |
| 845 | 845 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 846 | 846 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 847 | 847 | $query_data = array(':ident' => $ident); |
| 848 | 848 | } else { |
| 849 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 849 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 850 | 850 | WHERE tracker_live.ident = :ident |
| 851 | 851 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 852 | 852 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -855,8 +855,8 @@ discard block |
||
| 855 | 855 | |
| 856 | 856 | $sth = $this->db->prepare($query); |
| 857 | 857 | $sth->execute($query_data); |
| 858 | - $ident_result=''; |
|
| 859 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 858 | + $ident_result = ''; |
|
| 859 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 860 | 860 | { |
| 861 | 861 | $ident_result = $row['famtrackid']; |
| 862 | 862 | } |
@@ -873,13 +873,13 @@ discard block |
||
| 873 | 873 | { |
| 874 | 874 | global $globalDBdriver, $globalTimezone; |
| 875 | 875 | if ($globalDBdriver == 'mysql') { |
| 876 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 876 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 877 | 877 | WHERE tracker_live.famtrackid = :id |
| 878 | 878 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 879 | 879 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 880 | 880 | $query_data = array(':id' => $id); |
| 881 | 881 | } else { |
| 882 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 882 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 883 | 883 | WHERE tracker_live.famtrackid = :id |
| 884 | 884 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 885 | 885 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -888,8 +888,8 @@ discard block |
||
| 888 | 888 | |
| 889 | 889 | $sth = $this->db->prepare($query); |
| 890 | 890 | $sth->execute($query_data); |
| 891 | - $ident_result=''; |
|
| 892 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 891 | + $ident_result = ''; |
|
| 892 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 893 | 893 | { |
| 894 | 894 | $ident_result = $row['famtrackid']; |
| 895 | 895 | } |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | * @param string $over_country |
| 917 | 917 | * @return String success or false |
| 918 | 918 | */ |
| 919 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 919 | + public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 920 | 920 | { |
| 921 | 921 | global $globalURL, $globalArchive, $globalDebug; |
| 922 | 922 | $Common = new Common(); |
@@ -975,21 +975,21 @@ discard block |
||
| 975 | 975 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 976 | 976 | |
| 977 | 977 | |
| 978 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 979 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 980 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 981 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 982 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 983 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 985 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 986 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 987 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 988 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
| 989 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 990 | - |
|
| 991 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 992 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 978 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 979 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 980 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 981 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 982 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 983 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 985 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 986 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 987 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 988 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
| 989 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 990 | + |
|
| 991 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 992 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 993 | 993 | |
| 994 | 994 | $query = ''; |
| 995 | 995 | if ($globalArchive) { |
@@ -999,12 +999,12 @@ discard block |
||
| 999 | 999 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 1000 | 1000 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 1001 | 1001 | |
| 1002 | - $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); |
|
| 1002 | + $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); |
|
| 1003 | 1003 | try { |
| 1004 | 1004 | $sth = $this->db->prepare($query); |
| 1005 | 1005 | $sth->execute($query_values); |
| 1006 | 1006 | $sth->closeCursor(); |
| 1007 | - } catch(PDOException $e) { |
|
| 1007 | + } catch (PDOException $e) { |
|
| 1008 | 1008 | return "error : ".$e->getMessage(); |
| 1009 | 1009 | } |
| 1010 | 1010 | /* |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1015 | 1015 | if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
| 1016 | 1016 | $TrackerArchive = new TrackerArchive($this->db); |
| 1017 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 1017 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country); |
|
| 1018 | 1018 | if ($globalDebug) echo $result.')'; |
| 1019 | 1019 | } |
| 1020 | 1020 | |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | |
| 1025 | 1025 | public function getOrderBy() |
| 1026 | 1026 | { |
| 1027 | - $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")); |
|
| 1027 | + $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")); |
|
| 1028 | 1028 | return $orderby; |
| 1029 | 1029 | } |
| 1030 | 1030 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/libs/Predict/Predict/TLE.php'); |
| 15 | 15 | |
| 16 | 16 | class Satellite { |
| 17 | - /** @var $db PDOStatement */ |
|
| 17 | + /** @var $db PDOStatement */ |
|
| 18 | 18 | public $db; |
| 19 | 19 | |
| 20 | 20 | public function __construct($dbc = null) { |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | else return array(); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Gets all launch site |
|
| 138 | - * |
|
| 139 | - * @param bool $limit |
|
| 140 | - * @param array $filters |
|
| 141 | - * @return array the launch site list |
|
| 142 | - */ |
|
| 136 | + /** |
|
| 137 | + * Gets all launch site |
|
| 138 | + * |
|
| 139 | + * @param bool $limit |
|
| 140 | + * @param array $filters |
|
| 141 | + * @return array the launch site list |
|
| 142 | + */ |
|
| 143 | 143 | public function countAllLaunchSite($limit = true, $filters = array()) |
| 144 | 144 | { |
| 145 | 145 | //$filter_query = $this->getFilter($filters,true,true); |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | - * Gets all owners |
|
| 167 | - * |
|
| 168 | - * @return array the owners list |
|
| 169 | - * |
|
| 170 | - */ |
|
| 166 | + * Gets all owners |
|
| 167 | + * |
|
| 168 | + * @return array the owners list |
|
| 169 | + * |
|
| 170 | + */ |
|
| 171 | 171 | public function countAllOwners($limit = true, $filters = array()) |
| 172 | 172 | { |
| 173 | 173 | //$filter_query = $this->getFilter($filters,true,true); |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | return $owner_array; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Gets all countries owners |
|
| 195 | - * |
|
| 196 | - * @param bool $limit |
|
| 197 | - * @param array $filters |
|
| 198 | - * @return array the countries list |
|
| 199 | - */ |
|
| 193 | + /** |
|
| 194 | + * Gets all countries owners |
|
| 195 | + * |
|
| 196 | + * @param bool $limit |
|
| 197 | + * @param array $filters |
|
| 198 | + * @return array the countries list |
|
| 199 | + */ |
|
| 200 | 200 | public function countAllCountriesOwners($limit = true, $filters = array()) |
| 201 | 201 | { |
| 202 | 202 | global $globalDBdriver; |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | return $owner_array; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - /** |
|
| 224 | - * Counts all launch dates during the last year |
|
| 225 | - * |
|
| 226 | - * @param array $filters |
|
| 227 | - * @param string $sincedate |
|
| 228 | - * @return array the launch date list |
|
| 229 | - */ |
|
| 223 | + /** |
|
| 224 | + * Counts all launch dates during the last year |
|
| 225 | + * |
|
| 226 | + * @param array $filters |
|
| 227 | + * @param string $sincedate |
|
| 228 | + * @return array the launch date list |
|
| 229 | + */ |
|
| 230 | 230 | public function countAllMonthsLastYear($filters = array(), $sincedate = '') |
| 231 | 231 | { |
| 232 | 232 | global $globalTimezone, $globalDBdriver; |
@@ -266,13 +266,13 @@ discard block |
||
| 266 | 266 | return $date_array; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - /** |
|
| 270 | - * Counts all dates during the last 10 years |
|
| 271 | - * |
|
| 272 | - * @param array $filters |
|
| 273 | - * @param string $sincedate |
|
| 274 | - * @return array the date list |
|
| 275 | - */ |
|
| 269 | + /** |
|
| 270 | + * Counts all dates during the last 10 years |
|
| 271 | + * |
|
| 272 | + * @param array $filters |
|
| 273 | + * @param string $sincedate |
|
| 274 | + * @return array the date list |
|
| 275 | + */ |
|
| 276 | 276 | public function countAllYears($filters = array(), $sincedate = '') |
| 277 | 277 | { |
| 278 | 278 | global $globalTimezone, $globalDBdriver; |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | public function __construct($dbc = null) { |
| 21 | 21 | $Connection = new Connection($dbc); |
| 22 | 22 | $this->db = $Connection->db(); |
| 23 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 23 | + if ($this->db === null) { |
|
| 24 | + die('Error: No DB connection.'); |
|
| 25 | + } |
|
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | public function get_tle($name) { |
@@ -32,8 +34,11 @@ discard block |
||
| 32 | 34 | echo $e->getMessage(); |
| 33 | 35 | } |
| 34 | 36 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 35 | - if (isset($result[0])) return $result[0]; |
|
| 36 | - else return array(); |
|
| 37 | + if (isset($result[0])) { |
|
| 38 | + return $result[0]; |
|
| 39 | + } else { |
|
| 40 | + return array(); |
|
| 41 | + } |
|
| 37 | 42 | } |
| 38 | 43 | public function get_tle_types() { |
| 39 | 44 | $query = 'SELECT DISTINCT tle_type FROM tle ORDER BY tle_type'; |
@@ -44,8 +49,11 @@ discard block |
||
| 44 | 49 | echo $e->getMessage(); |
| 45 | 50 | } |
| 46 | 51 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 47 | - if (isset($result[0])) return $result; |
|
| 48 | - else return array(); |
|
| 52 | + if (isset($result[0])) { |
|
| 53 | + return $result; |
|
| 54 | + } else { |
|
| 55 | + return array(); |
|
| 56 | + } |
|
| 49 | 57 | } |
| 50 | 58 | public function get_tle_names() { |
| 51 | 59 | $query = 'SELECT DISTINCT tle_name, tle_type FROM tle'; |
@@ -56,8 +64,11 @@ discard block |
||
| 56 | 64 | echo $e->getMessage(); |
| 57 | 65 | } |
| 58 | 66 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 59 | - if (isset($result[0])) return $result; |
|
| 60 | - else return array(); |
|
| 67 | + if (isset($result[0])) { |
|
| 68 | + return $result; |
|
| 69 | + } else { |
|
| 70 | + return array(); |
|
| 71 | + } |
|
| 61 | 72 | } |
| 62 | 73 | public function get_tle_names_type($type) { |
| 63 | 74 | $query = 'SELECT tle_name, tle_type FROM tle WHERE tle_type = :type ORDER BY tle_name'; |
@@ -68,8 +79,11 @@ discard block |
||
| 68 | 79 | echo $e->getMessage(); |
| 69 | 80 | } |
| 70 | 81 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 71 | - if (isset($result[0])) return $result; |
|
| 72 | - else return array(); |
|
| 82 | + if (isset($result[0])) { |
|
| 83 | + return $result; |
|
| 84 | + } else { |
|
| 85 | + return array(); |
|
| 86 | + } |
|
| 73 | 87 | } |
| 74 | 88 | |
| 75 | 89 | public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) { |
@@ -87,8 +101,11 @@ discard block |
||
| 87 | 101 | $result = array(); |
| 88 | 102 | foreach ($all_sat as $sat) { |
| 89 | 103 | $position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second); |
| 90 | - if (isset($position[0])) $result = array_merge($position,$result); |
|
| 91 | - else $result[] = $position; |
|
| 104 | + if (isset($position[0])) { |
|
| 105 | + $result = array_merge($position,$result); |
|
| 106 | + } else { |
|
| 107 | + $result[] = $position; |
|
| 108 | + } |
|
| 92 | 109 | } |
| 93 | 110 | return $result; |
| 94 | 111 | } |
@@ -104,7 +121,9 @@ discard block |
||
| 104 | 121 | $sat = new Predict_Sat($tle); |
| 105 | 122 | $predict = new Predict(); |
| 106 | 123 | //if ($timestamp == '') $now = Predict_Time::get_current_daynum(); |
| 107 | - if ($timestamp_begin == '') $timestamp_begin = time(); |
|
| 124 | + if ($timestamp_begin == '') { |
|
| 125 | + $timestamp_begin = time(); |
|
| 126 | + } |
|
| 108 | 127 | if ($timestamp_end == '') { |
| 109 | 128 | $now = Predict_Time::unix2daynum($timestamp_begin); |
| 110 | 129 | $predict->predict_calc($sat,$qth,$now); |
@@ -129,8 +148,11 @@ discard block |
||
| 129 | 148 | echo $e->getMessage(); |
| 130 | 149 | } |
| 131 | 150 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 132 | - if (isset($result[0])) return $result[0]; |
|
| 133 | - else return array(); |
|
| 151 | + if (isset($result[0])) { |
|
| 152 | + return $result[0]; |
|
| 153 | + } else { |
|
| 154 | + return array(); |
|
| 155 | + } |
|
| 134 | 156 | } |
| 135 | 157 | |
| 136 | 158 | /** |
@@ -148,7 +170,9 @@ discard block |
||
| 148 | 170 | FROM satellite".$filter_query." satellite.launch_site <> '' AND satellite.launch_site IS NOT NULL"; |
| 149 | 171 | $query_values = array(); |
| 150 | 172 | $query .= " GROUP BY satellite.launch_site ORDER BY launch_site_count DESC"; |
| 151 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 173 | + if ($limit) { |
|
| 174 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 175 | + } |
|
| 152 | 176 | $sth = $this->db->prepare($query); |
| 153 | 177 | $sth->execute($query_values); |
| 154 | 178 | $launch_site_array = array(); |
@@ -176,7 +200,9 @@ discard block |
||
| 176 | 200 | FROM satellite".$filter_query." satellite.owner <> '' AND satellite.owner IS NOT NULL"; |
| 177 | 201 | $query_values = array(); |
| 178 | 202 | $query .= " GROUP BY satellite.owner ORDER BY owner_count DESC"; |
| 179 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 203 | + if ($limit) { |
|
| 204 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 205 | + } |
|
| 180 | 206 | $sth = $this->db->prepare($query); |
| 181 | 207 | $sth->execute($query_values); |
| 182 | 208 | $owner_array = array(); |
@@ -206,7 +232,9 @@ discard block |
||
| 206 | 232 | FROM satellite".$filter_query." satellite.country_owner <> '' AND satellite.country_owner IS NOT NULL"; |
| 207 | 233 | $query_values = array(); |
| 208 | 234 | $query .= " GROUP BY satellite.country_owner ORDER BY country_count DESC"; |
| 209 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 235 | + if ($limit) { |
|
| 236 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 237 | + } |
|
| 210 | 238 | $sth = $this->db->prepare($query); |
| 211 | 239 | $sth->execute($query_values); |
| 212 | 240 | $owner_array = array(); |
@@ -234,20 +262,26 @@ discard block |
||
| 234 | 262 | date_default_timezone_set($globalTimezone); |
| 235 | 263 | $datetime = new DateTime(); |
| 236 | 264 | $offset = $datetime->format('P'); |
| 237 | - } else $offset = '+00:00'; |
|
| 265 | + } else { |
|
| 266 | + $offset = '+00:00'; |
|
| 267 | + } |
|
| 238 | 268 | //$filter_query = $this->getFilter($filters,true,true); |
| 239 | 269 | $filter_query = ' WHERE'; |
| 240 | 270 | if ($globalDBdriver == 'mysql') { |
| 241 | 271 | $query = "SELECT MONTH(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 242 | 272 | FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
| 243 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 273 | + if ($sincedate != '') { |
|
| 274 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 275 | + } |
|
| 244 | 276 | $query .= " GROUP BY year_name, month_name |
| 245 | 277 | ORDER BY year_name, month_name ASC"; |
| 246 | 278 | $query_data = array(':offset' => $offset); |
| 247 | 279 | } else { |
| 248 | 280 | $query = "SELECT EXTRACT(MONTH FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count |
| 249 | 281 | FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'"; |
| 250 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 282 | + if ($sincedate != '') { |
|
| 283 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 284 | + } |
|
| 251 | 285 | $query .= " GROUP BY year_name, month_name |
| 252 | 286 | ORDER BY year_name, month_name ASC"; |
| 253 | 287 | $query_data = array(':offset' => $offset); |
@@ -280,20 +314,26 @@ discard block |
||
| 280 | 314 | date_default_timezone_set($globalTimezone); |
| 281 | 315 | $datetime = new DateTime(); |
| 282 | 316 | $offset = $datetime->format('P'); |
| 283 | - } else $offset = '+00:00'; |
|
| 317 | + } else { |
|
| 318 | + $offset = '+00:00'; |
|
| 319 | + } |
|
| 284 | 320 | //$filter_query = $this->getFilter($filters,true,true); |
| 285 | 321 | $filter_query = ' WHERE'; |
| 286 | 322 | if ($globalDBdriver == 'mysql') { |
| 287 | 323 | $query = "SELECT YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 288 | 324 | FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 YEAR)"; |
| 289 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 325 | + if ($sincedate != '') { |
|
| 326 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 327 | + } |
|
| 290 | 328 | $query .= " GROUP BY year_name |
| 291 | 329 | ORDER BY year_name ASC"; |
| 292 | 330 | $query_data = array(':offset' => $offset); |
| 293 | 331 | } else { |
| 294 | 332 | $query = "SELECT EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count |
| 295 | 333 | FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '10 YEARS'"; |
| 296 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 334 | + if ($sincedate != '') { |
|
| 335 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 336 | + } |
|
| 297 | 337 | $query .= " GROUP BY year_name |
| 298 | 338 | ORDER BY year_name ASC"; |
| 299 | 339 | $query_data = array(':offset' => $offset); |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | if ($this->db === null) die('Error: No DB connection. (MarineArchive)'); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get SQL query part for filter used |
|
| 21 | - * @param array $filter the filter |
|
| 22 | - * @param bool $where |
|
| 23 | - * @param bool $and |
|
| 24 | - * @return string the SQL part |
|
| 25 | - */ |
|
| 19 | + /** |
|
| 20 | + * Get SQL query part for filter used |
|
| 21 | + * @param array $filter the filter |
|
| 22 | + * @param bool $where |
|
| 23 | + * @param bool $and |
|
| 24 | + * @return string the SQL part |
|
| 25 | + */ |
|
| 26 | 26 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
@@ -91,40 +91,40 @@ discard block |
||
| 91 | 91 | return $filter_query; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Add to Mariche archive |
|
| 96 | - * |
|
| 97 | - * @param string $fammarine_id |
|
| 98 | - * @param string $ident |
|
| 99 | - * @param string $latitude |
|
| 100 | - * @param string $longitude |
|
| 101 | - * @param string $heading |
|
| 102 | - * @param string $groundspeed |
|
| 103 | - * @param string $date |
|
| 104 | - * @param bool $putinarchive |
|
| 105 | - * @param string $mmsi |
|
| 106 | - * @param string $type |
|
| 107 | - * @param string $typeid |
|
| 108 | - * @param string $imo |
|
| 109 | - * @param string $callsign |
|
| 110 | - * @param string $arrival_code |
|
| 111 | - * @param string $arrival_date |
|
| 112 | - * @param string $status |
|
| 113 | - * @param string $statusid |
|
| 114 | - * @param bool $noarchive |
|
| 115 | - * @param string $format_source |
|
| 116 | - * @param string $source_name |
|
| 117 | - * @param string $over_country |
|
| 118 | - * @param string $captain_id |
|
| 119 | - * @param string $captain_name |
|
| 120 | - * @param string $race_id |
|
| 121 | - * @param string $race_name |
|
| 122 | - * @param string $distance |
|
| 123 | - * @param string $race_rank |
|
| 124 | - * @param string $race_time |
|
| 125 | - * @return string |
|
| 126 | - */ |
|
| 127 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') { |
|
| 94 | + /** |
|
| 95 | + * Add to Mariche archive |
|
| 96 | + * |
|
| 97 | + * @param string $fammarine_id |
|
| 98 | + * @param string $ident |
|
| 99 | + * @param string $latitude |
|
| 100 | + * @param string $longitude |
|
| 101 | + * @param string $heading |
|
| 102 | + * @param string $groundspeed |
|
| 103 | + * @param string $date |
|
| 104 | + * @param bool $putinarchive |
|
| 105 | + * @param string $mmsi |
|
| 106 | + * @param string $type |
|
| 107 | + * @param string $typeid |
|
| 108 | + * @param string $imo |
|
| 109 | + * @param string $callsign |
|
| 110 | + * @param string $arrival_code |
|
| 111 | + * @param string $arrival_date |
|
| 112 | + * @param string $status |
|
| 113 | + * @param string $statusid |
|
| 114 | + * @param bool $noarchive |
|
| 115 | + * @param string $format_source |
|
| 116 | + * @param string $source_name |
|
| 117 | + * @param string $over_country |
|
| 118 | + * @param string $captain_id |
|
| 119 | + * @param string $captain_name |
|
| 120 | + * @param string $race_id |
|
| 121 | + * @param string $race_name |
|
| 122 | + * @param string $distance |
|
| 123 | + * @param string $race_rank |
|
| 124 | + * @param string $race_time |
|
| 125 | + * @return string |
|
| 126 | + */ |
|
| 127 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') { |
|
| 128 | 128 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Marine = new Marine($this->db); |
@@ -149,42 +149,42 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Gets all the spotter information based on a particular callsign |
|
| 154 | - * |
|
| 155 | - * @param $ident |
|
| 156 | - * @return array the spotter information |
|
| 157 | - */ |
|
| 158 | - public function getLastArchiveMarineDataByIdent($ident) |
|
| 159 | - { |
|
| 160 | - $Marine = new Marine($this->db); |
|
| 161 | - date_default_timezone_set('UTC'); |
|
| 162 | - |
|
| 163 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 164 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 165 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 167 | - return $spotter_array; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Gets last the spotter information based on a particular id |
|
| 173 | - * |
|
| 174 | - * @param $id |
|
| 175 | - * @return array the spotter information |
|
| 176 | - */ |
|
| 177 | - public function getLastArchiveMarineDataById($id) |
|
| 178 | - { |
|
| 179 | - $Marine = new Marine($this->db); |
|
| 180 | - date_default_timezone_set('UTC'); |
|
| 181 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 182 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
| 183 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 184 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 152 | + /** |
|
| 153 | + * Gets all the spotter information based on a particular callsign |
|
| 154 | + * |
|
| 155 | + * @param $ident |
|
| 156 | + * @return array the spotter information |
|
| 157 | + */ |
|
| 158 | + public function getLastArchiveMarineDataByIdent($ident) |
|
| 159 | + { |
|
| 160 | + $Marine = new Marine($this->db); |
|
| 161 | + date_default_timezone_set('UTC'); |
|
| 162 | + |
|
| 163 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 164 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 165 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 167 | + return $spotter_array; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Gets last the spotter information based on a particular id |
|
| 173 | + * |
|
| 174 | + * @param $id |
|
| 175 | + * @return array the spotter information |
|
| 176 | + */ |
|
| 177 | + public function getLastArchiveMarineDataById($id) |
|
| 178 | + { |
|
| 179 | + $Marine = new Marine($this->db); |
|
| 180 | + date_default_timezone_set('UTC'); |
|
| 181 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 182 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
| 183 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 184 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 185 | 185 | |
| 186 | 186 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 187 | - /* |
|
| 187 | + /* |
|
| 188 | 188 | try { |
| 189 | 189 | $Connection = new Connection(); |
| 190 | 190 | $sth = Connection->$db->prepare($query); |
@@ -194,196 +194,196 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 196 | 196 | */ |
| 197 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 198 | - return $spotter_array; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Gets all the spotter information based on a particular id |
|
| 203 | - * |
|
| 204 | - * @param $id |
|
| 205 | - * @return array the spotter information |
|
| 206 | - */ |
|
| 207 | - public function getAllArchiveMarineDataById($id) |
|
| 197 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 198 | + return $spotter_array; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Gets all the spotter information based on a particular id |
|
| 203 | + * |
|
| 204 | + * @param $id |
|
| 205 | + * @return array the spotter information |
|
| 206 | + */ |
|
| 207 | + public function getAllArchiveMarineDataById($id) |
|
| 208 | 208 | { |
| 209 | - date_default_timezone_set('UTC'); |
|
| 210 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 211 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 209 | + date_default_timezone_set('UTC'); |
|
| 210 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 211 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 212 | 212 | |
| 213 | 213 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 214 | 214 | |
| 215 | - try { |
|
| 216 | - $sth = $this->db->prepare($query); |
|
| 217 | - $sth->execute(array(':id' => $id)); |
|
| 218 | - } catch(PDOException $e) { |
|
| 219 | - echo $e->getMessage(); |
|
| 220 | - die; |
|
| 221 | - } |
|
| 222 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 223 | - return $spotter_array; |
|
| 215 | + try { |
|
| 216 | + $sth = $this->db->prepare($query); |
|
| 217 | + $sth->execute(array(':id' => $id)); |
|
| 218 | + } catch(PDOException $e) { |
|
| 219 | + echo $e->getMessage(); |
|
| 220 | + die; |
|
| 221 | + } |
|
| 222 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 223 | + return $spotter_array; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Gets coordinate & time spotter information based on a particular id |
|
| 228 | - * |
|
| 229 | - * @param $id |
|
| 230 | - * @return array the spotter information |
|
| 231 | - */ |
|
| 232 | - public function getCoordArchiveMarineDataById($id) |
|
| 233 | - { |
|
| 234 | - date_default_timezone_set('UTC'); |
|
| 235 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 236 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 226 | + /** |
|
| 227 | + * Gets coordinate & time spotter information based on a particular id |
|
| 228 | + * |
|
| 229 | + * @param $id |
|
| 230 | + * @return array the spotter information |
|
| 231 | + */ |
|
| 232 | + public function getCoordArchiveMarineDataById($id) |
|
| 233 | + { |
|
| 234 | + date_default_timezone_set('UTC'); |
|
| 235 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 236 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 237 | 237 | |
| 238 | 238 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 239 | 239 | |
| 240 | - try { |
|
| 241 | - $sth = $this->db->prepare($query); |
|
| 242 | - $sth->execute(array(':id' => $id)); |
|
| 243 | - } catch(PDOException $e) { |
|
| 244 | - echo $e->getMessage(); |
|
| 245 | - die; |
|
| 246 | - } |
|
| 247 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 248 | - |
|
| 249 | - return $spotter_array; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Gets altitude information based on a particular callsign |
|
| 255 | - * |
|
| 256 | - * @param $ident |
|
| 257 | - * @return array the spotter information |
|
| 258 | - */ |
|
| 259 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
| 260 | - { |
|
| 261 | - |
|
| 262 | - date_default_timezone_set('UTC'); |
|
| 263 | - |
|
| 264 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 265 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | - |
|
| 267 | - try { |
|
| 268 | - $sth = $this->db->prepare($query); |
|
| 269 | - $sth->execute(array(':ident' => $ident)); |
|
| 270 | - } catch(PDOException $e) { |
|
| 271 | - echo $e->getMessage(); |
|
| 272 | - die; |
|
| 273 | - } |
|
| 274 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 275 | - |
|
| 276 | - return $spotter_array; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Gets altitude information based on a particular id |
|
| 281 | - * |
|
| 282 | - * @param $id |
|
| 283 | - * @return array the spotter information |
|
| 284 | - */ |
|
| 285 | - public function getAltitudeArchiveMarineDataById($id) |
|
| 286 | - { |
|
| 287 | - |
|
| 288 | - date_default_timezone_set('UTC'); |
|
| 289 | - |
|
| 290 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 291 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | - |
|
| 293 | - try { |
|
| 294 | - $sth = $this->db->prepare($query); |
|
| 295 | - $sth->execute(array(':id' => $id)); |
|
| 296 | - } catch(PDOException $e) { |
|
| 297 | - echo $e->getMessage(); |
|
| 298 | - die; |
|
| 299 | - } |
|
| 300 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 301 | - |
|
| 302 | - return $spotter_array; |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Gets altitude & speed information based on a particular id |
|
| 307 | - * |
|
| 308 | - * @param $id |
|
| 309 | - * @return array the spotter information |
|
| 310 | - */ |
|
| 311 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
| 312 | - { |
|
| 313 | - date_default_timezone_set('UTC'); |
|
| 314 | - |
|
| 315 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 316 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | - |
|
| 318 | - try { |
|
| 319 | - $sth = $this->db->prepare($query); |
|
| 320 | - $sth->execute(array(':id' => $id)); |
|
| 321 | - } catch(PDOException $e) { |
|
| 322 | - echo $e->getMessage(); |
|
| 323 | - die; |
|
| 324 | - } |
|
| 325 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 326 | - |
|
| 327 | - return $spotter_array; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * Gets altitude information based on a particular callsign |
|
| 333 | - * |
|
| 334 | - * @param $ident |
|
| 335 | - * @return array the spotter information |
|
| 336 | - */ |
|
| 337 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
| 338 | - { |
|
| 339 | - |
|
| 340 | - date_default_timezone_set('UTC'); |
|
| 341 | - |
|
| 342 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 343 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 240 | + try { |
|
| 241 | + $sth = $this->db->prepare($query); |
|
| 242 | + $sth->execute(array(':id' => $id)); |
|
| 243 | + } catch(PDOException $e) { |
|
| 244 | + echo $e->getMessage(); |
|
| 245 | + die; |
|
| 246 | + } |
|
| 247 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 248 | + |
|
| 249 | + return $spotter_array; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Gets altitude information based on a particular callsign |
|
| 255 | + * |
|
| 256 | + * @param $ident |
|
| 257 | + * @return array the spotter information |
|
| 258 | + */ |
|
| 259 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
| 260 | + { |
|
| 261 | + |
|
| 262 | + date_default_timezone_set('UTC'); |
|
| 263 | + |
|
| 264 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 265 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | + |
|
| 267 | + try { |
|
| 268 | + $sth = $this->db->prepare($query); |
|
| 269 | + $sth->execute(array(':ident' => $ident)); |
|
| 270 | + } catch(PDOException $e) { |
|
| 271 | + echo $e->getMessage(); |
|
| 272 | + die; |
|
| 273 | + } |
|
| 274 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 275 | + |
|
| 276 | + return $spotter_array; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Gets altitude information based on a particular id |
|
| 281 | + * |
|
| 282 | + * @param $id |
|
| 283 | + * @return array the spotter information |
|
| 284 | + */ |
|
| 285 | + public function getAltitudeArchiveMarineDataById($id) |
|
| 286 | + { |
|
| 287 | + |
|
| 288 | + date_default_timezone_set('UTC'); |
|
| 289 | + |
|
| 290 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 291 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | + |
|
| 293 | + try { |
|
| 294 | + $sth = $this->db->prepare($query); |
|
| 295 | + $sth->execute(array(':id' => $id)); |
|
| 296 | + } catch(PDOException $e) { |
|
| 297 | + echo $e->getMessage(); |
|
| 298 | + die; |
|
| 299 | + } |
|
| 300 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 301 | + |
|
| 302 | + return $spotter_array; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Gets altitude & speed information based on a particular id |
|
| 307 | + * |
|
| 308 | + * @param $id |
|
| 309 | + * @return array the spotter information |
|
| 310 | + */ |
|
| 311 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
| 312 | + { |
|
| 313 | + date_default_timezone_set('UTC'); |
|
| 314 | + |
|
| 315 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 316 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | + |
|
| 318 | + try { |
|
| 319 | + $sth = $this->db->prepare($query); |
|
| 320 | + $sth->execute(array(':id' => $id)); |
|
| 321 | + } catch(PDOException $e) { |
|
| 322 | + echo $e->getMessage(); |
|
| 323 | + die; |
|
| 324 | + } |
|
| 325 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 326 | + |
|
| 327 | + return $spotter_array; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * Gets altitude information based on a particular callsign |
|
| 333 | + * |
|
| 334 | + * @param $ident |
|
| 335 | + * @return array the spotter information |
|
| 336 | + */ |
|
| 337 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
| 338 | + { |
|
| 339 | + |
|
| 340 | + date_default_timezone_set('UTC'); |
|
| 341 | + |
|
| 342 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 343 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 344 | 344 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 345 | 345 | |
| 346 | - try { |
|
| 347 | - $sth = $this->db->prepare($query); |
|
| 348 | - $sth->execute(array(':ident' => $ident)); |
|
| 349 | - } catch(PDOException $e) { |
|
| 350 | - echo $e->getMessage(); |
|
| 351 | - die; |
|
| 352 | - } |
|
| 353 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 354 | - |
|
| 355 | - return $spotter_array; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * Gets all the archive spotter information |
|
| 361 | - * |
|
| 362 | - * @param $ident |
|
| 363 | - * @param $fammarine_id |
|
| 364 | - * @param $date |
|
| 365 | - * @return array the spotter information |
|
| 366 | - */ |
|
| 367 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 368 | - { |
|
| 369 | - $Marine = new Marine($this->db); |
|
| 370 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 371 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 372 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 373 | - return $spotter_array; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Delete all tracking data |
|
| 378 | - * |
|
| 379 | - */ |
|
| 380 | - public function deleteMarineArchiveTrackData() |
|
| 381 | - { |
|
| 382 | - global $globalArchiveKeepTrackMonths, $globalDBdriver; |
|
| 383 | - if ($globalDBdriver == 'mysql') { |
|
| 384 | - $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
|
| 385 | - } else { |
|
| 386 | - $query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)"; |
|
| 346 | + try { |
|
| 347 | + $sth = $this->db->prepare($query); |
|
| 348 | + $sth->execute(array(':ident' => $ident)); |
|
| 349 | + } catch(PDOException $e) { |
|
| 350 | + echo $e->getMessage(); |
|
| 351 | + die; |
|
| 352 | + } |
|
| 353 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 354 | + |
|
| 355 | + return $spotter_array; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * Gets all the archive spotter information |
|
| 361 | + * |
|
| 362 | + * @param $ident |
|
| 363 | + * @param $fammarine_id |
|
| 364 | + * @param $date |
|
| 365 | + * @return array the spotter information |
|
| 366 | + */ |
|
| 367 | + public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 368 | + { |
|
| 369 | + $Marine = new Marine($this->db); |
|
| 370 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 371 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 372 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 373 | + return $spotter_array; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Delete all tracking data |
|
| 378 | + * |
|
| 379 | + */ |
|
| 380 | + public function deleteMarineArchiveTrackData() |
|
| 381 | + { |
|
| 382 | + global $globalArchiveKeepTrackMonths, $globalDBdriver; |
|
| 383 | + if ($globalDBdriver == 'mysql') { |
|
| 384 | + $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
|
| 385 | + } else { |
|
| 386 | + $query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)"; |
|
| 387 | 387 | } |
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
@@ -394,42 +394,42 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - /** |
|
| 398 | - * Gets Minimal Live Marine data |
|
| 399 | - * |
|
| 400 | - * @param $begindate |
|
| 401 | - * @param $enddate |
|
| 402 | - * @param array $filter |
|
| 403 | - * @return array the spotter information |
|
| 404 | - */ |
|
| 405 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 406 | - { |
|
| 407 | - global $globalDBdriver; |
|
| 408 | - date_default_timezone_set('UTC'); |
|
| 409 | - |
|
| 410 | - $filter_query = ''; |
|
| 411 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 413 | - } |
|
| 414 | - // Use spotter_output also ? |
|
| 415 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | - } |
|
| 418 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 420 | - } |
|
| 421 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | - if ($globalDBdriver == 'mysql') { |
|
| 427 | - /* |
|
| 397 | + /** |
|
| 398 | + * Gets Minimal Live Marine data |
|
| 399 | + * |
|
| 400 | + * @param $begindate |
|
| 401 | + * @param $enddate |
|
| 402 | + * @param array $filter |
|
| 403 | + * @return array the spotter information |
|
| 404 | + */ |
|
| 405 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 406 | + { |
|
| 407 | + global $globalDBdriver; |
|
| 408 | + date_default_timezone_set('UTC'); |
|
| 409 | + |
|
| 410 | + $filter_query = ''; |
|
| 411 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 412 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 413 | + } |
|
| 414 | + // Use spotter_output also ? |
|
| 415 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | + } |
|
| 418 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 420 | + } |
|
| 421 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | + if ($globalDBdriver == 'mysql') { |
|
| 427 | + /* |
|
| 428 | 428 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 429 | 429 | FROM marine_archive |
| 430 | 430 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 431 | 431 | */ |
| 432 | - /* |
|
| 432 | + /* |
|
| 433 | 433 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 434 | 434 | FROM marine_archive |
| 435 | 435 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
@@ -438,541 +438,541 @@ discard block |
||
| 438 | 438 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 439 | 439 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 440 | 440 | */ |
| 441 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 441 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 442 | 442 | FROM marine_archive |
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY fammarine_id'; |
| 446 | - } else { |
|
| 447 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
| 448 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 446 | + } else { |
|
| 447 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
| 448 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 449 | 449 | FROM marine_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
| 452 | 452 | '.$filter_query.' ORDER BY fammarine_id'; |
| 453 | - } |
|
| 454 | - //echo $query; |
|
| 455 | - try { |
|
| 456 | - $sth = $this->db->prepare($query); |
|
| 457 | - $sth->execute(); |
|
| 458 | - } catch(PDOException $e) { |
|
| 459 | - echo $e->getMessage(); |
|
| 460 | - die; |
|
| 461 | - } |
|
| 462 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | - |
|
| 464 | - return $spotter_array; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * Gets Minimal Live Marine data |
|
| 469 | - * |
|
| 470 | - * @param $begindate |
|
| 471 | - * @param $enddate |
|
| 472 | - * @param array $filter |
|
| 473 | - * @return array the spotter information |
|
| 474 | - */ |
|
| 475 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 476 | - { |
|
| 477 | - global $globalDBdriver; |
|
| 478 | - date_default_timezone_set('UTC'); |
|
| 479 | - |
|
| 480 | - $filter_query = ''; |
|
| 481 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 482 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 483 | - } |
|
| 484 | - // Should use spotter_output also ? |
|
| 485 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 486 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | - } |
|
| 488 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 489 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 490 | - } |
|
| 491 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 492 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 496 | - if ($globalDBdriver == 'mysql') { |
|
| 497 | - /* |
|
| 453 | + } |
|
| 454 | + //echo $query; |
|
| 455 | + try { |
|
| 456 | + $sth = $this->db->prepare($query); |
|
| 457 | + $sth->execute(); |
|
| 458 | + } catch(PDOException $e) { |
|
| 459 | + echo $e->getMessage(); |
|
| 460 | + die; |
|
| 461 | + } |
|
| 462 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | + |
|
| 464 | + return $spotter_array; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * Gets Minimal Live Marine data |
|
| 469 | + * |
|
| 470 | + * @param $begindate |
|
| 471 | + * @param $enddate |
|
| 472 | + * @param array $filter |
|
| 473 | + * @return array the spotter information |
|
| 474 | + */ |
|
| 475 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 476 | + { |
|
| 477 | + global $globalDBdriver; |
|
| 478 | + date_default_timezone_set('UTC'); |
|
| 479 | + |
|
| 480 | + $filter_query = ''; |
|
| 481 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 482 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 483 | + } |
|
| 484 | + // Should use spotter_output also ? |
|
| 485 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 486 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | + } |
|
| 488 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 489 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 490 | + } |
|
| 491 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 492 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 496 | + if ($globalDBdriver == 'mysql') { |
|
| 497 | + /* |
|
| 498 | 498 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 499 | 499 | FROM marine_archive |
| 500 | 500 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 501 | 501 | */ |
| 502 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 502 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 503 | 503 | FROM marine_archive_output |
| 504 | 504 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 505 | 505 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 506 | 506 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 507 | 507 | |
| 508 | - } else { |
|
| 509 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
| 510 | - /* |
|
| 508 | + } else { |
|
| 509 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
| 510 | + /* |
|
| 511 | 511 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
| 512 | 512 | FROM marine_archive_output |
| 513 | 513 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 514 | 514 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 515 | 515 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 516 | 516 | */ |
| 517 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 517 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 518 | 518 | FROM marine_archive_output |
| 519 | 519 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 520 | 520 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 521 | 521 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 522 | 522 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 523 | 523 | |
| 524 | - } |
|
| 525 | - //echo $query; |
|
| 526 | - try { |
|
| 527 | - $sth = $this->db->prepare($query); |
|
| 528 | - $sth->execute(); |
|
| 529 | - } catch(PDOException $e) { |
|
| 530 | - echo $e->getMessage(); |
|
| 531 | - die; |
|
| 532 | - } |
|
| 533 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 534 | - |
|
| 535 | - return $spotter_array; |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Gets count Live Marine data |
|
| 540 | - * |
|
| 541 | - * @param $begindate |
|
| 542 | - * @param $enddate |
|
| 543 | - * @param array $filter |
|
| 544 | - * @return array the spotter information |
|
| 545 | - */ |
|
| 546 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 547 | - { |
|
| 548 | - global $globalDBdriver, $globalLiveInterval; |
|
| 549 | - date_default_timezone_set('UTC'); |
|
| 550 | - |
|
| 551 | - $filter_query = ''; |
|
| 552 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | - } |
|
| 555 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | - } |
|
| 558 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 560 | - } |
|
| 561 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | - if ($globalDBdriver == 'mysql') { |
|
| 567 | - $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
|
| 524 | + } |
|
| 525 | + //echo $query; |
|
| 526 | + try { |
|
| 527 | + $sth = $this->db->prepare($query); |
|
| 528 | + $sth->execute(); |
|
| 529 | + } catch(PDOException $e) { |
|
| 530 | + echo $e->getMessage(); |
|
| 531 | + die; |
|
| 532 | + } |
|
| 533 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 534 | + |
|
| 535 | + return $spotter_array; |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * Gets count Live Marine data |
|
| 540 | + * |
|
| 541 | + * @param $begindate |
|
| 542 | + * @param $enddate |
|
| 543 | + * @param array $filter |
|
| 544 | + * @return array the spotter information |
|
| 545 | + */ |
|
| 546 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 547 | + { |
|
| 548 | + global $globalDBdriver, $globalLiveInterval; |
|
| 549 | + date_default_timezone_set('UTC'); |
|
| 550 | + |
|
| 551 | + $filter_query = ''; |
|
| 552 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | + } |
|
| 555 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | + } |
|
| 558 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 560 | + } |
|
| 561 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | + if ($globalDBdriver == 'mysql') { |
|
| 567 | + $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
|
| 568 | 568 | FROM marine_archive l |
| 569 | 569 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 570 | - } else { |
|
| 571 | - $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
|
| 572 | - } |
|
| 573 | - //echo $query; |
|
| 574 | - try { |
|
| 575 | - $sth = $this->db->prepare($query); |
|
| 576 | - $sth->execute(); |
|
| 577 | - } catch(PDOException $e) { |
|
| 578 | - echo $e->getMessage(); |
|
| 579 | - die; |
|
| 580 | - } |
|
| 581 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 582 | - $sth->closeCursor(); |
|
| 583 | - return $result['nb']; |
|
| 584 | - } |
|
| 570 | + } else { |
|
| 571 | + $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
|
| 572 | + } |
|
| 573 | + //echo $query; |
|
| 574 | + try { |
|
| 575 | + $sth = $this->db->prepare($query); |
|
| 576 | + $sth->execute(); |
|
| 577 | + } catch(PDOException $e) { |
|
| 578 | + echo $e->getMessage(); |
|
| 579 | + die; |
|
| 580 | + } |
|
| 581 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 582 | + $sth->closeCursor(); |
|
| 583 | + return $result['nb']; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | |
| 587 | 587 | |
| 588 | 588 | // marine_archive_output |
| 589 | 589 | |
| 590 | - /** |
|
| 591 | - * Gets all the spotter information |
|
| 592 | - * |
|
| 593 | - * @param string $q |
|
| 594 | - * @param string $registration |
|
| 595 | - * @param string $aircraft_icao |
|
| 596 | - * @param string $aircraft_manufacturer |
|
| 597 | - * @param string $highlights |
|
| 598 | - * @param string $airline_icao |
|
| 599 | - * @param string $airline_country |
|
| 600 | - * @param string $airline_type |
|
| 601 | - * @param string $airport |
|
| 602 | - * @param string $airport_country |
|
| 603 | - * @param string $callsign |
|
| 604 | - * @param string $departure_airport_route |
|
| 605 | - * @param string $arrival_airport_route |
|
| 606 | - * @param string $owner |
|
| 607 | - * @param string $pilot_id |
|
| 608 | - * @param string $pilot_name |
|
| 609 | - * @param string $altitude |
|
| 610 | - * @param string $date_posted |
|
| 611 | - * @param string $limit |
|
| 612 | - * @param string $sort |
|
| 613 | - * @param string $includegeodata |
|
| 614 | - * @param string $origLat |
|
| 615 | - * @param string $origLon |
|
| 616 | - * @param string $dist |
|
| 617 | - * @param array $filters |
|
| 618 | - * @return array the spotter information |
|
| 619 | - */ |
|
| 620 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 621 | - { |
|
| 622 | - global $globalTimezone, $globalDBdriver; |
|
| 623 | - require_once(dirname(__FILE__).'/class.Translation.php'); |
|
| 624 | - $Translation = new Translation($this->db); |
|
| 625 | - $Marine = new Marine($this->db); |
|
| 626 | - |
|
| 627 | - date_default_timezone_set('UTC'); |
|
| 590 | + /** |
|
| 591 | + * Gets all the spotter information |
|
| 592 | + * |
|
| 593 | + * @param string $q |
|
| 594 | + * @param string $registration |
|
| 595 | + * @param string $aircraft_icao |
|
| 596 | + * @param string $aircraft_manufacturer |
|
| 597 | + * @param string $highlights |
|
| 598 | + * @param string $airline_icao |
|
| 599 | + * @param string $airline_country |
|
| 600 | + * @param string $airline_type |
|
| 601 | + * @param string $airport |
|
| 602 | + * @param string $airport_country |
|
| 603 | + * @param string $callsign |
|
| 604 | + * @param string $departure_airport_route |
|
| 605 | + * @param string $arrival_airport_route |
|
| 606 | + * @param string $owner |
|
| 607 | + * @param string $pilot_id |
|
| 608 | + * @param string $pilot_name |
|
| 609 | + * @param string $altitude |
|
| 610 | + * @param string $date_posted |
|
| 611 | + * @param string $limit |
|
| 612 | + * @param string $sort |
|
| 613 | + * @param string $includegeodata |
|
| 614 | + * @param string $origLat |
|
| 615 | + * @param string $origLon |
|
| 616 | + * @param string $dist |
|
| 617 | + * @param array $filters |
|
| 618 | + * @return array the spotter information |
|
| 619 | + */ |
|
| 620 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 621 | + { |
|
| 622 | + global $globalTimezone, $globalDBdriver; |
|
| 623 | + require_once(dirname(__FILE__).'/class.Translation.php'); |
|
| 624 | + $Translation = new Translation($this->db); |
|
| 625 | + $Marine = new Marine($this->db); |
|
| 626 | + |
|
| 627 | + date_default_timezone_set('UTC'); |
|
| 628 | 628 | |
| 629 | - $query_values = array(); |
|
| 630 | - $additional_query = ''; |
|
| 631 | - $limit_query = ''; |
|
| 632 | - $filter_query = $this->getFilter($filters); |
|
| 633 | - if ($q != "") |
|
| 634 | - { |
|
| 635 | - if (!is_string($q)) |
|
| 636 | - { |
|
| 637 | - return array(); |
|
| 638 | - } else { |
|
| 639 | - $q_array = explode(" ", $q); |
|
| 629 | + $query_values = array(); |
|
| 630 | + $additional_query = ''; |
|
| 631 | + $limit_query = ''; |
|
| 632 | + $filter_query = $this->getFilter($filters); |
|
| 633 | + if ($q != "") |
|
| 634 | + { |
|
| 635 | + if (!is_string($q)) |
|
| 636 | + { |
|
| 637 | + return array(); |
|
| 638 | + } else { |
|
| 639 | + $q_array = explode(" ", $q); |
|
| 640 | 640 | |
| 641 | - foreach ($q_array as $q_item){ |
|
| 642 | - $additional_query .= " AND ("; |
|
| 643 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 644 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 645 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 646 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 647 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 648 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 649 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 650 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 651 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 652 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 653 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 654 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 655 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 656 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 657 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 658 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
| 659 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 660 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 661 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 662 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
| 663 | - $translate = $Translation->ident2icao($q_item); |
|
| 664 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 665 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
| 666 | - $additional_query .= ")"; |
|
| 667 | - } |
|
| 668 | - } |
|
| 669 | - } |
|
| 641 | + foreach ($q_array as $q_item){ |
|
| 642 | + $additional_query .= " AND ("; |
|
| 643 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 644 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 645 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 646 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 647 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 648 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 649 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 650 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 651 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 652 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 653 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 654 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 655 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 656 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 657 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 658 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
| 659 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 660 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 661 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 662 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
| 663 | + $translate = $Translation->ident2icao($q_item); |
|
| 664 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 665 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
| 666 | + $additional_query .= ")"; |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | - if ($registration != "") |
|
| 672 | - { |
|
| 673 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 674 | - if (!is_string($registration)) |
|
| 675 | - { |
|
| 676 | - return array(); |
|
| 677 | - } else { |
|
| 678 | - $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
|
| 679 | - } |
|
| 680 | - } |
|
| 671 | + if ($registration != "") |
|
| 672 | + { |
|
| 673 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 674 | + if (!is_string($registration)) |
|
| 675 | + { |
|
| 676 | + return array(); |
|
| 677 | + } else { |
|
| 678 | + $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | 681 | |
| 682 | - if ($aircraft_icao != "") |
|
| 683 | - { |
|
| 684 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 685 | - if (!is_string($aircraft_icao)) |
|
| 686 | - { |
|
| 687 | - return array(); |
|
| 688 | - } else { |
|
| 689 | - $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
|
| 690 | - } |
|
| 691 | - } |
|
| 682 | + if ($aircraft_icao != "") |
|
| 683 | + { |
|
| 684 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 685 | + if (!is_string($aircraft_icao)) |
|
| 686 | + { |
|
| 687 | + return array(); |
|
| 688 | + } else { |
|
| 689 | + $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
|
| 690 | + } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | - if ($aircraft_manufacturer != "") |
|
| 694 | - { |
|
| 695 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 696 | - if (!is_string($aircraft_manufacturer)) |
|
| 697 | - { |
|
| 698 | - return array(); |
|
| 699 | - } else { |
|
| 700 | - $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
|
| 701 | - } |
|
| 702 | - } |
|
| 693 | + if ($aircraft_manufacturer != "") |
|
| 694 | + { |
|
| 695 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 696 | + if (!is_string($aircraft_manufacturer)) |
|
| 697 | + { |
|
| 698 | + return array(); |
|
| 699 | + } else { |
|
| 700 | + $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | 703 | |
| 704 | - if ($highlights == "true") |
|
| 705 | - { |
|
| 706 | - if (!is_string($highlights)) |
|
| 707 | - { |
|
| 708 | - return array(); |
|
| 709 | - } else { |
|
| 710 | - $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
|
| 711 | - } |
|
| 712 | - } |
|
| 704 | + if ($highlights == "true") |
|
| 705 | + { |
|
| 706 | + if (!is_string($highlights)) |
|
| 707 | + { |
|
| 708 | + return array(); |
|
| 709 | + } else { |
|
| 710 | + $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - if ($airline_icao != "") |
|
| 715 | - { |
|
| 716 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 717 | - if (!is_string($airline_icao)) |
|
| 718 | - { |
|
| 719 | - return array(); |
|
| 720 | - } else { |
|
| 721 | - $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
|
| 722 | - } |
|
| 723 | - } |
|
| 714 | + if ($airline_icao != "") |
|
| 715 | + { |
|
| 716 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 717 | + if (!is_string($airline_icao)) |
|
| 718 | + { |
|
| 719 | + return array(); |
|
| 720 | + } else { |
|
| 721 | + $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
|
| 722 | + } |
|
| 723 | + } |
|
| 724 | 724 | |
| 725 | - if ($airline_country != "") |
|
| 726 | - { |
|
| 727 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 728 | - if (!is_string($airline_country)) |
|
| 729 | - { |
|
| 730 | - return array(); |
|
| 731 | - } else { |
|
| 732 | - $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
|
| 733 | - } |
|
| 734 | - } |
|
| 725 | + if ($airline_country != "") |
|
| 726 | + { |
|
| 727 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 728 | + if (!is_string($airline_country)) |
|
| 729 | + { |
|
| 730 | + return array(); |
|
| 731 | + } else { |
|
| 732 | + $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
|
| 733 | + } |
|
| 734 | + } |
|
| 735 | 735 | |
| 736 | - if ($airline_type != "") |
|
| 737 | - { |
|
| 738 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 739 | - if (!is_string($airline_type)) |
|
| 740 | - { |
|
| 741 | - return array(); |
|
| 742 | - } else { |
|
| 743 | - if ($airline_type == "passenger") |
|
| 744 | - { |
|
| 745 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
| 746 | - } |
|
| 747 | - if ($airline_type == "cargo") |
|
| 748 | - { |
|
| 749 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
| 750 | - } |
|
| 751 | - if ($airline_type == "military") |
|
| 752 | - { |
|
| 753 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
| 754 | - } |
|
| 755 | - } |
|
| 756 | - } |
|
| 736 | + if ($airline_type != "") |
|
| 737 | + { |
|
| 738 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 739 | + if (!is_string($airline_type)) |
|
| 740 | + { |
|
| 741 | + return array(); |
|
| 742 | + } else { |
|
| 743 | + if ($airline_type == "passenger") |
|
| 744 | + { |
|
| 745 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
| 746 | + } |
|
| 747 | + if ($airline_type == "cargo") |
|
| 748 | + { |
|
| 749 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
| 750 | + } |
|
| 751 | + if ($airline_type == "military") |
|
| 752 | + { |
|
| 753 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
| 754 | + } |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | - if ($airport != "") |
|
| 759 | - { |
|
| 760 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 761 | - if (!is_string($airport)) |
|
| 762 | - { |
|
| 763 | - return array(); |
|
| 764 | - } else { |
|
| 765 | - $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
|
| 766 | - } |
|
| 767 | - } |
|
| 758 | + if ($airport != "") |
|
| 759 | + { |
|
| 760 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 761 | + if (!is_string($airport)) |
|
| 762 | + { |
|
| 763 | + return array(); |
|
| 764 | + } else { |
|
| 765 | + $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
|
| 766 | + } |
|
| 767 | + } |
|
| 768 | 768 | |
| 769 | - if ($airport_country != "") |
|
| 770 | - { |
|
| 771 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 772 | - if (!is_string($airport_country)) |
|
| 773 | - { |
|
| 774 | - return array(); |
|
| 775 | - } else { |
|
| 776 | - $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
|
| 777 | - } |
|
| 778 | - } |
|
| 769 | + if ($airport_country != "") |
|
| 770 | + { |
|
| 771 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 772 | + if (!is_string($airport_country)) |
|
| 773 | + { |
|
| 774 | + return array(); |
|
| 775 | + } else { |
|
| 776 | + $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
|
| 777 | + } |
|
| 778 | + } |
|
| 779 | 779 | |
| 780 | - if ($callsign != "") |
|
| 781 | - { |
|
| 782 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 783 | - if (!is_string($callsign)) |
|
| 784 | - { |
|
| 785 | - return array(); |
|
| 786 | - } else { |
|
| 787 | - $translate = $Translation->ident2icao($callsign); |
|
| 788 | - if ($translate != $callsign) { |
|
| 789 | - $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
|
| 790 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 791 | - } else { |
|
| 792 | - $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
|
| 793 | - } |
|
| 794 | - } |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - if ($owner != "") |
|
| 798 | - { |
|
| 799 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 800 | - if (!is_string($owner)) |
|
| 801 | - { |
|
| 802 | - return array(); |
|
| 803 | - } else { |
|
| 804 | - $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
|
| 805 | - } |
|
| 806 | - } |
|
| 807 | - |
|
| 808 | - if ($pilot_name != "") |
|
| 809 | - { |
|
| 810 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 811 | - if (!is_string($pilot_name)) |
|
| 812 | - { |
|
| 813 | - return array(); |
|
| 814 | - } else { |
|
| 815 | - $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
|
| 816 | - } |
|
| 817 | - } |
|
| 780 | + if ($callsign != "") |
|
| 781 | + { |
|
| 782 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 783 | + if (!is_string($callsign)) |
|
| 784 | + { |
|
| 785 | + return array(); |
|
| 786 | + } else { |
|
| 787 | + $translate = $Translation->ident2icao($callsign); |
|
| 788 | + if ($translate != $callsign) { |
|
| 789 | + $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
|
| 790 | + $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 791 | + } else { |
|
| 792 | + $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
|
| 793 | + } |
|
| 794 | + } |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + if ($owner != "") |
|
| 798 | + { |
|
| 799 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 800 | + if (!is_string($owner)) |
|
| 801 | + { |
|
| 802 | + return array(); |
|
| 803 | + } else { |
|
| 804 | + $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
|
| 805 | + } |
|
| 806 | + } |
|
| 807 | + |
|
| 808 | + if ($pilot_name != "") |
|
| 809 | + { |
|
| 810 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 811 | + if (!is_string($pilot_name)) |
|
| 812 | + { |
|
| 813 | + return array(); |
|
| 814 | + } else { |
|
| 815 | + $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
|
| 816 | + } |
|
| 817 | + } |
|
| 818 | 818 | |
| 819 | - if ($pilot_id != "") |
|
| 820 | - { |
|
| 821 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | - if (!is_string($pilot_id)) |
|
| 823 | - { |
|
| 824 | - return array(); |
|
| 825 | - } else { |
|
| 826 | - $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
|
| 827 | - } |
|
| 828 | - } |
|
| 819 | + if ($pilot_id != "") |
|
| 820 | + { |
|
| 821 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | + if (!is_string($pilot_id)) |
|
| 823 | + { |
|
| 824 | + return array(); |
|
| 825 | + } else { |
|
| 826 | + $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
|
| 827 | + } |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | - if ($departure_airport_route != "") |
|
| 831 | - { |
|
| 832 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 833 | - if (!is_string($departure_airport_route)) |
|
| 834 | - { |
|
| 835 | - return array(); |
|
| 836 | - } else { |
|
| 837 | - $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
|
| 838 | - } |
|
| 839 | - } |
|
| 830 | + if ($departure_airport_route != "") |
|
| 831 | + { |
|
| 832 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 833 | + if (!is_string($departure_airport_route)) |
|
| 834 | + { |
|
| 835 | + return array(); |
|
| 836 | + } else { |
|
| 837 | + $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | 840 | |
| 841 | - if ($arrival_airport_route != "") |
|
| 842 | - { |
|
| 843 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 844 | - if (!is_string($arrival_airport_route)) |
|
| 845 | - { |
|
| 846 | - return array(); |
|
| 847 | - } else { |
|
| 848 | - $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
|
| 849 | - } |
|
| 850 | - } |
|
| 841 | + if ($arrival_airport_route != "") |
|
| 842 | + { |
|
| 843 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 844 | + if (!is_string($arrival_airport_route)) |
|
| 845 | + { |
|
| 846 | + return array(); |
|
| 847 | + } else { |
|
| 848 | + $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
|
| 849 | + } |
|
| 850 | + } |
|
| 851 | 851 | |
| 852 | - if ($altitude != "") |
|
| 853 | - { |
|
| 854 | - $altitude_array = explode(",", $altitude); |
|
| 852 | + if ($altitude != "") |
|
| 853 | + { |
|
| 854 | + $altitude_array = explode(",", $altitude); |
|
| 855 | 855 | |
| 856 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 856 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | 858 | |
| 859 | 859 | |
| 860 | - if ($altitude_array[1] != "") |
|
| 861 | - { |
|
| 862 | - $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 863 | - $altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
| 864 | - $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
| 865 | - } else { |
|
| 866 | - $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 867 | - $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
| 868 | - } |
|
| 869 | - } |
|
| 860 | + if ($altitude_array[1] != "") |
|
| 861 | + { |
|
| 862 | + $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 863 | + $altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
| 864 | + $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
| 865 | + } else { |
|
| 866 | + $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 867 | + $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
| 868 | + } |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | - if ($date_posted != "") |
|
| 872 | - { |
|
| 873 | - $date_array = explode(",", $date_posted); |
|
| 871 | + if ($date_posted != "") |
|
| 872 | + { |
|
| 873 | + $date_array = explode(",", $date_posted); |
|
| 874 | 874 | |
| 875 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 875 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 877 | 877 | |
| 878 | - if ($globalTimezone != '') { |
|
| 879 | - date_default_timezone_set($globalTimezone); |
|
| 880 | - $datetime = new DateTime(); |
|
| 881 | - $offset = $datetime->format('P'); |
|
| 882 | - } else $offset = '+00:00'; |
|
| 883 | - |
|
| 884 | - |
|
| 885 | - if ($date_array[1] != "") |
|
| 886 | - { |
|
| 887 | - $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 888 | - $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
| 889 | - if ($globalDBdriver == 'mysql') { |
|
| 890 | - $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
| 891 | - } else { |
|
| 892 | - $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
|
| 893 | - } |
|
| 894 | - } else { |
|
| 895 | - $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 896 | - if ($globalDBdriver == 'mysql') { |
|
| 897 | - $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
| 898 | - } else { |
|
| 899 | - $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
|
| 900 | - } |
|
| 901 | - } |
|
| 902 | - } |
|
| 878 | + if ($globalTimezone != '') { |
|
| 879 | + date_default_timezone_set($globalTimezone); |
|
| 880 | + $datetime = new DateTime(); |
|
| 881 | + $offset = $datetime->format('P'); |
|
| 882 | + } else $offset = '+00:00'; |
|
| 883 | + |
|
| 884 | + |
|
| 885 | + if ($date_array[1] != "") |
|
| 886 | + { |
|
| 887 | + $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 888 | + $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
| 889 | + if ($globalDBdriver == 'mysql') { |
|
| 890 | + $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
| 891 | + } else { |
|
| 892 | + $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
|
| 893 | + } |
|
| 894 | + } else { |
|
| 895 | + $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 896 | + if ($globalDBdriver == 'mysql') { |
|
| 897 | + $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
| 898 | + } else { |
|
| 899 | + $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
|
| 900 | + } |
|
| 901 | + } |
|
| 902 | + } |
|
| 903 | 903 | |
| 904 | - if ($limit != "") |
|
| 905 | - { |
|
| 906 | - $limit_array = explode(",", $limit); |
|
| 904 | + if ($limit != "") |
|
| 905 | + { |
|
| 906 | + $limit_array = explode(",", $limit); |
|
| 907 | 907 | |
| 908 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 908 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 910 | 910 | |
| 911 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 912 | - { |
|
| 913 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 914 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 915 | - } |
|
| 916 | - } |
|
| 911 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 912 | + { |
|
| 913 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 914 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 915 | + } |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | 918 | |
| 919 | - if ($origLat != "" && $origLon != "" && $dist != "") { |
|
| 920 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 919 | + if ($origLat != "" && $origLon != "" && $dist != "") { |
|
| 920 | + $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | + $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 922 | 922 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 923 | 923 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 924 | - } else { |
|
| 925 | - if ($sort != "") |
|
| 926 | - { |
|
| 927 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 928 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 929 | - } else { |
|
| 930 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 931 | - } |
|
| 924 | + } else { |
|
| 925 | + if ($sort != "") |
|
| 926 | + { |
|
| 927 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 928 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 929 | + } else { |
|
| 930 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 931 | + } |
|
| 932 | 932 | |
| 933 | - if ($includegeodata == "true") |
|
| 934 | - { |
|
| 935 | - $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
|
| 936 | - } |
|
| 933 | + if ($includegeodata == "true") |
|
| 934 | + { |
|
| 935 | + $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
|
| 936 | + } |
|
| 937 | 937 | |
| 938 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 938 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 939 | 939 | WHERE marine_archive_output.ident <> '' |
| 940 | 940 | ".$additional_query." |
| 941 | 941 | ".$filter_query.$orderby_query; |
| 942 | - } |
|
| 943 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 944 | - |
|
| 945 | - return $spotter_array; |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - public function deleteMarineArchiveData() |
|
| 949 | - { |
|
| 950 | - global $globalArchiveKeepMonths, $globalDBdriver; |
|
| 951 | - date_default_timezone_set('UTC'); |
|
| 952 | - if ($globalDBdriver == 'mysql') { |
|
| 953 | - $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
|
| 954 | - } else { |
|
| 955 | - $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
|
| 956 | - } |
|
| 957 | - try { |
|
| 958 | - $sth = $this->db->prepare($query); |
|
| 959 | - $sth->execute(); |
|
| 960 | - } catch(PDOException $e) { |
|
| 961 | - return "error"; |
|
| 962 | - } |
|
| 963 | - return ''; |
|
| 964 | - } |
|
| 965 | - |
|
| 966 | - /** |
|
| 967 | - * Gets all the spotter information based on the callsign |
|
| 968 | - * |
|
| 969 | - * @param string $ident |
|
| 970 | - * @param string $limit |
|
| 971 | - * @param string $sort |
|
| 972 | - * @return array the spotter information |
|
| 973 | - */ |
|
| 974 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 975 | - { |
|
| 942 | + } |
|
| 943 | + $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 944 | + |
|
| 945 | + return $spotter_array; |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + public function deleteMarineArchiveData() |
|
| 949 | + { |
|
| 950 | + global $globalArchiveKeepMonths, $globalDBdriver; |
|
| 951 | + date_default_timezone_set('UTC'); |
|
| 952 | + if ($globalDBdriver == 'mysql') { |
|
| 953 | + $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
|
| 954 | + } else { |
|
| 955 | + $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
|
| 956 | + } |
|
| 957 | + try { |
|
| 958 | + $sth = $this->db->prepare($query); |
|
| 959 | + $sth->execute(); |
|
| 960 | + } catch(PDOException $e) { |
|
| 961 | + return "error"; |
|
| 962 | + } |
|
| 963 | + return ''; |
|
| 964 | + } |
|
| 965 | + |
|
| 966 | + /** |
|
| 967 | + * Gets all the spotter information based on the callsign |
|
| 968 | + * |
|
| 969 | + * @param string $ident |
|
| 970 | + * @param string $limit |
|
| 971 | + * @param string $sort |
|
| 972 | + * @return array the spotter information |
|
| 973 | + */ |
|
| 974 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 975 | + { |
|
| 976 | 976 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 977 | 977 | |
| 978 | 978 | date_default_timezone_set('UTC'); |
@@ -984,35 +984,35 @@ discard block |
||
| 984 | 984 | |
| 985 | 985 | if ($ident != "") |
| 986 | 986 | { |
| 987 | - if (!is_string($ident)) |
|
| 988 | - { |
|
| 989 | - return array(); |
|
| 990 | - } else { |
|
| 991 | - $additional_query = " AND (marine_archive_output.ident = :ident)"; |
|
| 992 | - $query_values = array(':ident' => $ident); |
|
| 993 | - } |
|
| 987 | + if (!is_string($ident)) |
|
| 988 | + { |
|
| 989 | + return array(); |
|
| 990 | + } else { |
|
| 991 | + $additional_query = " AND (marine_archive_output.ident = :ident)"; |
|
| 992 | + $query_values = array(':ident' => $ident); |
|
| 993 | + } |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | if ($limit != "") |
| 997 | 997 | { |
| 998 | - $limit_array = explode(",", $limit); |
|
| 998 | + $limit_array = explode(",", $limit); |
|
| 999 | 999 | |
| 1000 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1002 | 1002 | |
| 1003 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1004 | - { |
|
| 1003 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1004 | + { |
|
| 1005 | 1005 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1006 | 1006 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1007 | - } |
|
| 1007 | + } |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | if ($sort != "") |
| 1011 | 1011 | { |
| 1012 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1013 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1012 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1013 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1014 | 1014 | } else { |
| 1015 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1015 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -1020,20 +1020,20 @@ discard block |
||
| 1020 | 1020 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1021 | 1021 | |
| 1022 | 1022 | return $spotter_array; |
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - |
|
| 1026 | - /** |
|
| 1027 | - * Gets all the spotter information based on the owner |
|
| 1028 | - * |
|
| 1029 | - * @param string $owner |
|
| 1030 | - * @param string $limit |
|
| 1031 | - * @param string $sort |
|
| 1032 | - * @param array $filter |
|
| 1033 | - * @return array the spotter information |
|
| 1034 | - */ |
|
| 1035 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1036 | - { |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + |
|
| 1026 | + /** |
|
| 1027 | + * Gets all the spotter information based on the owner |
|
| 1028 | + * |
|
| 1029 | + * @param string $owner |
|
| 1030 | + * @param string $limit |
|
| 1031 | + * @param string $sort |
|
| 1032 | + * @param array $filter |
|
| 1033 | + * @return array the spotter information |
|
| 1034 | + */ |
|
| 1035 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1036 | + { |
|
| 1037 | 1037 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 1038 | 1038 | |
| 1039 | 1039 | date_default_timezone_set('UTC'); |
@@ -1046,35 +1046,35 @@ discard block |
||
| 1046 | 1046 | |
| 1047 | 1047 | if ($owner != "") |
| 1048 | 1048 | { |
| 1049 | - if (!is_string($owner)) |
|
| 1050 | - { |
|
| 1049 | + if (!is_string($owner)) |
|
| 1050 | + { |
|
| 1051 | 1051 | return array(); |
| 1052 | - } else { |
|
| 1052 | + } else { |
|
| 1053 | 1053 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
| 1054 | 1054 | $query_values = array(':owner' => $owner); |
| 1055 | - } |
|
| 1055 | + } |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | if ($limit != "") |
| 1059 | 1059 | { |
| 1060 | - $limit_array = explode(",", $limit); |
|
| 1060 | + $limit_array = explode(",", $limit); |
|
| 1061 | 1061 | |
| 1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | 1064 | |
| 1065 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1066 | - { |
|
| 1065 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1066 | + { |
|
| 1067 | 1067 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1068 | 1068 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1069 | - } |
|
| 1069 | + } |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | if ($sort != "") |
| 1073 | 1073 | { |
| 1074 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1075 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1074 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1075 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1076 | 1076 | } else { |
| 1077 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1077 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1082,19 +1082,19 @@ discard block |
||
| 1082 | 1082 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1083 | 1083 | |
| 1084 | 1084 | return $spotter_array; |
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - /** |
|
| 1088 | - * Gets all the spotter information based on the pilot |
|
| 1089 | - * |
|
| 1090 | - * @param string $pilot |
|
| 1091 | - * @param string $limit |
|
| 1092 | - * @param string $sort |
|
| 1093 | - * @param array $filter |
|
| 1094 | - * @return array the spotter information |
|
| 1095 | - */ |
|
| 1096 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1097 | - { |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + /** |
|
| 1088 | + * Gets all the spotter information based on the pilot |
|
| 1089 | + * |
|
| 1090 | + * @param string $pilot |
|
| 1091 | + * @param string $limit |
|
| 1092 | + * @param string $sort |
|
| 1093 | + * @param array $filter |
|
| 1094 | + * @return array the spotter information |
|
| 1095 | + */ |
|
| 1096 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1097 | + { |
|
| 1098 | 1098 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 1099 | 1099 | |
| 1100 | 1100 | date_default_timezone_set('UTC'); |
@@ -1113,24 +1113,24 @@ discard block |
||
| 1113 | 1113 | |
| 1114 | 1114 | if ($limit != "") |
| 1115 | 1115 | { |
| 1116 | - $limit_array = explode(",", $limit); |
|
| 1116 | + $limit_array = explode(",", $limit); |
|
| 1117 | 1117 | |
| 1118 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1120 | 1120 | |
| 1121 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1122 | - { |
|
| 1121 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1122 | + { |
|
| 1123 | 1123 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1124 | 1124 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1125 | - } |
|
| 1125 | + } |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | if ($sort != "") |
| 1129 | 1129 | { |
| 1130 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1131 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1130 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1131 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1132 | 1132 | } else { |
| 1133 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1133 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1138,18 +1138,18 @@ discard block |
||
| 1138 | 1138 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1139 | 1139 | |
| 1140 | 1140 | return $spotter_array; |
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - /** |
|
| 1144 | - * Gets all number of flight over countries |
|
| 1145 | - * |
|
| 1146 | - * @param bool $limit |
|
| 1147 | - * @param int $olderthanmonths |
|
| 1148 | - * @param string $sincedate |
|
| 1149 | - * @return array the airline country list |
|
| 1150 | - */ |
|
| 1151 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1152 | - { |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + /** |
|
| 1144 | + * Gets all number of flight over countries |
|
| 1145 | + * |
|
| 1146 | + * @param bool $limit |
|
| 1147 | + * @param int $olderthanmonths |
|
| 1148 | + * @param string $sincedate |
|
| 1149 | + * @return array the airline country list |
|
| 1150 | + */ |
|
| 1151 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1152 | + { |
|
| 1153 | 1153 | global $globalDBdriver; |
| 1154 | 1154 | /* |
| 1155 | 1155 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1159,14 +1159,14 @@ discard block |
||
| 1159 | 1159 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1160 | 1160 | FROM countries c, marine_archive s |
| 1161 | 1161 | WHERE c.iso2 = s.over_country "; |
| 1162 | - if ($olderthanmonths > 0) { |
|
| 1163 | - if ($globalDBdriver == 'mysql') { |
|
| 1162 | + if ($olderthanmonths > 0) { |
|
| 1163 | + if ($globalDBdriver == 'mysql') { |
|
| 1164 | 1164 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1165 | 1165 | } else { |
| 1166 | 1166 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1167 | 1167 | } |
| 1168 | 1168 | } |
| 1169 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1169 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1170 | 1170 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1171 | 1171 | if ($limit) $query .= " LIMIT 0,10"; |
| 1172 | 1172 | |
@@ -1179,25 +1179,25 @@ discard block |
||
| 1179 | 1179 | |
| 1180 | 1180 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1181 | 1181 | { |
| 1182 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1183 | - $temp_array['flight_country'] = $row['name']; |
|
| 1184 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1185 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1186 | - $flight_array[] = $temp_array; |
|
| 1182 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1183 | + $temp_array['flight_country'] = $row['name']; |
|
| 1184 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1185 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1186 | + $flight_array[] = $temp_array; |
|
| 1187 | 1187 | } |
| 1188 | 1188 | return $flight_array; |
| 1189 | - } |
|
| 1190 | - |
|
| 1191 | - /** |
|
| 1192 | - * Gets all number of flight over countries |
|
| 1193 | - * |
|
| 1194 | - * @param bool $limit |
|
| 1195 | - * @param int $olderthanmonths |
|
| 1196 | - * @param string $sincedate |
|
| 1197 | - * @return array the airline country list |
|
| 1198 | - */ |
|
| 1199 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1200 | - { |
|
| 1189 | + } |
|
| 1190 | + |
|
| 1191 | + /** |
|
| 1192 | + * Gets all number of flight over countries |
|
| 1193 | + * |
|
| 1194 | + * @param bool $limit |
|
| 1195 | + * @param int $olderthanmonths |
|
| 1196 | + * @param string $sincedate |
|
| 1197 | + * @return array the airline country list |
|
| 1198 | + */ |
|
| 1199 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1200 | + { |
|
| 1201 | 1201 | global $globalDBdriver; |
| 1202 | 1202 | /* |
| 1203 | 1203 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1207,14 +1207,14 @@ discard block |
||
| 1207 | 1207 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1208 | 1208 | FROM countries c, marine_archive s, spotter_output o |
| 1209 | 1209 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
| 1210 | - if ($olderthanmonths > 0) { |
|
| 1211 | - if ($globalDBdriver == 'mysql') { |
|
| 1210 | + if ($olderthanmonths > 0) { |
|
| 1211 | + if ($globalDBdriver == 'mysql') { |
|
| 1212 | 1212 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1213 | 1213 | } else { |
| 1214 | 1214 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1215 | 1215 | } |
| 1216 | 1216 | } |
| 1217 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1217 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1218 | 1218 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1219 | 1219 | if ($limit) $query .= " LIMIT 0,10"; |
| 1220 | 1220 | |
@@ -1227,25 +1227,25 @@ discard block |
||
| 1227 | 1227 | |
| 1228 | 1228 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1229 | 1229 | { |
| 1230 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1231 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1232 | - $temp_array['flight_country'] = $row['name']; |
|
| 1233 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1234 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1235 | - $flight_array[] = $temp_array; |
|
| 1230 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1231 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1232 | + $temp_array['flight_country'] = $row['name']; |
|
| 1233 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1234 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1235 | + $flight_array[] = $temp_array; |
|
| 1236 | 1236 | } |
| 1237 | 1237 | return $flight_array; |
| 1238 | - } |
|
| 1239 | - |
|
| 1240 | - /** |
|
| 1241 | - * Gets last spotter information based on a particular callsign |
|
| 1242 | - * |
|
| 1243 | - * @param $id |
|
| 1244 | - * @param $date |
|
| 1245 | - * @return array the spotter information |
|
| 1246 | - */ |
|
| 1247 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1248 | - { |
|
| 1238 | + } |
|
| 1239 | + |
|
| 1240 | + /** |
|
| 1241 | + * Gets last spotter information based on a particular callsign |
|
| 1242 | + * |
|
| 1243 | + * @param $id |
|
| 1244 | + * @param $date |
|
| 1245 | + * @return array the spotter information |
|
| 1246 | + */ |
|
| 1247 | + public function getDateArchiveMarineDataById($id,$date) |
|
| 1248 | + { |
|
| 1249 | 1249 | $Marine = new Marine($this->db); |
| 1250 | 1250 | date_default_timezone_set('UTC'); |
| 1251 | 1251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1253,17 +1253,17 @@ discard block |
||
| 1253 | 1253 | $date = date('c',$date); |
| 1254 | 1254 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1255 | 1255 | return $spotter_array; |
| 1256 | - } |
|
| 1257 | - |
|
| 1258 | - /** |
|
| 1259 | - * Gets all the spotter information based on a particular callsign |
|
| 1260 | - * |
|
| 1261 | - * @param $ident |
|
| 1262 | - * @param $date |
|
| 1263 | - * @return array the spotter information |
|
| 1264 | - */ |
|
| 1265 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1266 | - { |
|
| 1256 | + } |
|
| 1257 | + |
|
| 1258 | + /** |
|
| 1259 | + * Gets all the spotter information based on a particular callsign |
|
| 1260 | + * |
|
| 1261 | + * @param $ident |
|
| 1262 | + * @param $date |
|
| 1263 | + * @return array the spotter information |
|
| 1264 | + */ |
|
| 1265 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1266 | + { |
|
| 1267 | 1267 | $Marine = new Marine($this->db); |
| 1268 | 1268 | date_default_timezone_set('UTC'); |
| 1269 | 1269 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1271,65 +1271,65 @@ discard block |
||
| 1271 | 1271 | $date = date('c',$date); |
| 1272 | 1272 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1273 | 1273 | return $spotter_array; |
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - /** |
|
| 1277 | - * Gets all the spotter information based on the airport |
|
| 1278 | - * |
|
| 1279 | - * @param string $airport |
|
| 1280 | - * @param string $limit |
|
| 1281 | - * @param string $sort |
|
| 1282 | - * @param array $filters |
|
| 1283 | - * @return array the spotter information |
|
| 1284 | - */ |
|
| 1285 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1286 | - { |
|
| 1287 | - global $global_query; |
|
| 1288 | - $Marine = new Marine($this->db); |
|
| 1289 | - date_default_timezone_set('UTC'); |
|
| 1290 | - $query_values = array(); |
|
| 1291 | - $limit_query = ''; |
|
| 1292 | - $additional_query = ''; |
|
| 1293 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1274 | + } |
|
| 1275 | + |
|
| 1276 | + /** |
|
| 1277 | + * Gets all the spotter information based on the airport |
|
| 1278 | + * |
|
| 1279 | + * @param string $airport |
|
| 1280 | + * @param string $limit |
|
| 1281 | + * @param string $sort |
|
| 1282 | + * @param array $filters |
|
| 1283 | + * @return array the spotter information |
|
| 1284 | + */ |
|
| 1285 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1286 | + { |
|
| 1287 | + global $global_query; |
|
| 1288 | + $Marine = new Marine($this->db); |
|
| 1289 | + date_default_timezone_set('UTC'); |
|
| 1290 | + $query_values = array(); |
|
| 1291 | + $limit_query = ''; |
|
| 1292 | + $additional_query = ''; |
|
| 1293 | + $filter_query = $this->getFilter($filters,true,true); |
|
| 1294 | 1294 | |
| 1295 | - if ($airport != "") |
|
| 1296 | - { |
|
| 1297 | - if (!is_string($airport)) |
|
| 1298 | - { |
|
| 1299 | - return array(); |
|
| 1300 | - } else { |
|
| 1301 | - $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
|
| 1302 | - $query_values = array(':airport' => $airport); |
|
| 1303 | - } |
|
| 1304 | - } |
|
| 1295 | + if ($airport != "") |
|
| 1296 | + { |
|
| 1297 | + if (!is_string($airport)) |
|
| 1298 | + { |
|
| 1299 | + return array(); |
|
| 1300 | + } else { |
|
| 1301 | + $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
|
| 1302 | + $query_values = array(':airport' => $airport); |
|
| 1303 | + } |
|
| 1304 | + } |
|
| 1305 | 1305 | |
| 1306 | - if ($limit != "") |
|
| 1307 | - { |
|
| 1308 | - $limit_array = explode(",", $limit); |
|
| 1306 | + if ($limit != "") |
|
| 1307 | + { |
|
| 1308 | + $limit_array = explode(",", $limit); |
|
| 1309 | 1309 | |
| 1310 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1312 | 1312 | |
| 1313 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1314 | - { |
|
| 1315 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1316 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1317 | - } |
|
| 1318 | - } |
|
| 1313 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1314 | + { |
|
| 1315 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1316 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1317 | + } |
|
| 1318 | + } |
|
| 1319 | 1319 | |
| 1320 | - if ($sort != "") |
|
| 1321 | - { |
|
| 1322 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1323 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1324 | - } else { |
|
| 1325 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1326 | - } |
|
| 1320 | + if ($sort != "") |
|
| 1321 | + { |
|
| 1322 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1323 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1324 | + } else { |
|
| 1325 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1326 | + } |
|
| 1327 | 1327 | |
| 1328 | - $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
| 1328 | + $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
| 1329 | 1329 | |
| 1330 | - $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 1330 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 1331 | 1331 | |
| 1332 | - return $spotter_array; |
|
| 1333 | - } |
|
| 1332 | + return $spotter_array; |
|
| 1333 | + } |
|
| 1334 | 1334 | } |
| 1335 | 1335 | ?> |
| 1336 | 1336 | \ No newline at end of file |
@@ -23,33 +23,33 @@ discard block |
||
| 23 | 23 | * @param bool $and |
| 24 | 24 | * @return string the SQL part |
| 25 | 25 | */ |
| 26 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 26 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
| 29 | 29 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 30 | 30 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 31 | 31 | $filters = $globalStatsFilters[$globalFilterName]; |
| 32 | 32 | } else { |
| 33 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 33 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | if (isset($filter[0]['source'])) { |
| 37 | - $filters = array_merge($filters,$filter); |
|
| 37 | + $filters = array_merge($filters, $filter); |
|
| 38 | 38 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 39 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 40 | 40 | $filter_query_join = ''; |
| 41 | 41 | $filter_query_where = ''; |
| 42 | - foreach($filters as $flt) { |
|
| 42 | + foreach ($filters as $flt) { |
|
| 43 | 43 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 52 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 52 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 55 | 55 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 80 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 86 | 86 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 87 | 87 | if ($filter_query_where != '') { |
| 88 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 88 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 89 | 89 | } |
| 90 | 90 | $filter_query = $filter_query_join.$filter_query_where; |
| 91 | 91 | return $filter_query; |
@@ -128,21 +128,21 @@ discard block |
||
| 128 | 128 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Marine = new Marine($this->db); |
| 131 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 131 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 132 | 132 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 133 | 133 | else $country = ''; |
| 134 | 134 | } else $country = $over_country; |
| 135 | 135 | |
| 136 | 136 | //$country = $over_country; |
| 137 | 137 | // Route is not added in marine_archive |
| 138 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
| 138 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
| 139 | 139 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)'; |
| 140 | - $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' => $country,':mmsi' => $mmsi,':type' => $type,':type_id' => $typeid,':status' => $status,':status_id' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 140 | + $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' => $country, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $typeid, ':status' => $status, ':status_id' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
| 141 | 141 | try { |
| 142 | 142 | $sth = $this->db->prepare($query); |
| 143 | 143 | $sth->execute($query_values); |
| 144 | 144 | $sth->closeCursor(); |
| 145 | - } catch(PDOException $e) { |
|
| 145 | + } catch (PDOException $e) { |
|
| 146 | 146 | return "error : ".$e->getMessage(); |
| 147 | 147 | } |
| 148 | 148 | return "success"; |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 164 | 164 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 165 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 165 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
| 167 | 167 | return $spotter_array; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 182 | 182 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
| 183 | 183 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 184 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 184 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 185 | 185 | |
| 186 | 186 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 187 | 187 | /* |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 196 | 196 | */ |
| 197 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 197 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
| 198 | 198 | return $spotter_array; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | date_default_timezone_set('UTC'); |
| 210 | 210 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 211 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 211 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 212 | 212 | |
| 213 | 213 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 214 | 214 | |
| 215 | 215 | try { |
| 216 | 216 | $sth = $this->db->prepare($query); |
| 217 | 217 | $sth->execute(array(':id' => $id)); |
| 218 | - } catch(PDOException $e) { |
|
| 218 | + } catch (PDOException $e) { |
|
| 219 | 219 | echo $e->getMessage(); |
| 220 | 220 | die; |
| 221 | 221 | } |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | { |
| 234 | 234 | date_default_timezone_set('UTC'); |
| 235 | 235 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 236 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 236 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 237 | 237 | |
| 238 | 238 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 239 | 239 | |
| 240 | 240 | try { |
| 241 | 241 | $sth = $this->db->prepare($query); |
| 242 | 242 | $sth->execute(array(':id' => $id)); |
| 243 | - } catch(PDOException $e) { |
|
| 243 | + } catch (PDOException $e) { |
|
| 244 | 244 | echo $e->getMessage(); |
| 245 | 245 | die; |
| 246 | 246 | } |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | date_default_timezone_set('UTC'); |
| 263 | 263 | |
| 264 | 264 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 265 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 265 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | 266 | |
| 267 | 267 | try { |
| 268 | 268 | $sth = $this->db->prepare($query); |
| 269 | 269 | $sth->execute(array(':ident' => $ident)); |
| 270 | - } catch(PDOException $e) { |
|
| 270 | + } catch (PDOException $e) { |
|
| 271 | 271 | echo $e->getMessage(); |
| 272 | 272 | die; |
| 273 | 273 | } |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | date_default_timezone_set('UTC'); |
| 289 | 289 | |
| 290 | 290 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 291 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 291 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | 292 | |
| 293 | 293 | try { |
| 294 | 294 | $sth = $this->db->prepare($query); |
| 295 | 295 | $sth->execute(array(':id' => $id)); |
| 296 | - } catch(PDOException $e) { |
|
| 296 | + } catch (PDOException $e) { |
|
| 297 | 297 | echo $e->getMessage(); |
| 298 | 298 | die; |
| 299 | 299 | } |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | date_default_timezone_set('UTC'); |
| 314 | 314 | |
| 315 | 315 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 316 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 316 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | 317 | |
| 318 | 318 | try { |
| 319 | 319 | $sth = $this->db->prepare($query); |
| 320 | 320 | $sth->execute(array(':id' => $id)); |
| 321 | - } catch(PDOException $e) { |
|
| 321 | + } catch (PDOException $e) { |
|
| 322 | 322 | echo $e->getMessage(); |
| 323 | 323 | die; |
| 324 | 324 | } |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | |
| 342 | 342 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 343 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 343 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 344 | 344 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 345 | 345 | |
| 346 | 346 | try { |
| 347 | 347 | $sth = $this->db->prepare($query); |
| 348 | 348 | $sth->execute(array(':ident' => $ident)); |
| 349 | - } catch(PDOException $e) { |
|
| 349 | + } catch (PDOException $e) { |
|
| 350 | 350 | echo $e->getMessage(); |
| 351 | 351 | die; |
| 352 | 352 | } |
@@ -364,12 +364,12 @@ discard block |
||
| 364 | 364 | * @param $date |
| 365 | 365 | * @return array the spotter information |
| 366 | 366 | */ |
| 367 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 367 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
| 368 | 368 | { |
| 369 | 369 | $Marine = new Marine($this->db); |
| 370 | 370 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 371 | 371 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
| 372 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 372 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
| 373 | 373 | return $spotter_array; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
| 390 | 390 | $sth->execute(); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | echo $e->getMessage(); |
| 393 | 393 | die; |
| 394 | 394 | } |
@@ -402,24 +402,24 @@ discard block |
||
| 402 | 402 | * @param array $filter |
| 403 | 403 | * @return array the spotter information |
| 404 | 404 | */ |
| 405 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 405 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
| 406 | 406 | { |
| 407 | 407 | global $globalDBdriver; |
| 408 | 408 | date_default_timezone_set('UTC'); |
| 409 | 409 | |
| 410 | 410 | $filter_query = ''; |
| 411 | 411 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 412 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 413 | 413 | } |
| 414 | 414 | // Use spotter_output also ? |
| 415 | 415 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 416 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | 417 | } |
| 418 | 418 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 419 | 419 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 420 | 420 | } |
| 421 | 421 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 439 | 439 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 440 | 440 | */ |
| 441 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 441 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 442 | 442 | FROM marine_archive |
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY fammarine_id'; |
| 446 | 446 | } else { |
| 447 | 447 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
| 448 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 448 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 449 | 449 | FROM marine_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | try { |
| 456 | 456 | $sth = $this->db->prepare($query); |
| 457 | 457 | $sth->execute(); |
| 458 | - } catch(PDOException $e) { |
|
| 458 | + } catch (PDOException $e) { |
|
| 459 | 459 | echo $e->getMessage(); |
| 460 | 460 | die; |
| 461 | 461 | } |
@@ -472,24 +472,24 @@ discard block |
||
| 472 | 472 | * @param array $filter |
| 473 | 473 | * @return array the spotter information |
| 474 | 474 | */ |
| 475 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 475 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
| 476 | 476 | { |
| 477 | 477 | global $globalDBdriver; |
| 478 | 478 | date_default_timezone_set('UTC'); |
| 479 | 479 | |
| 480 | 480 | $filter_query = ''; |
| 481 | 481 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 482 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 482 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 483 | 483 | } |
| 484 | 484 | // Should use spotter_output also ? |
| 485 | 485 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 486 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 486 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | 487 | } |
| 488 | 488 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 489 | 489 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 490 | 490 | } |
| 491 | 491 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 492 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 492 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | FROM marine_archive |
| 500 | 500 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 501 | 501 | */ |
| 502 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 502 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 503 | 503 | FROM marine_archive_output |
| 504 | 504 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 505 | 505 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 515 | 515 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 516 | 516 | */ |
| 517 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 517 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 518 | 518 | FROM marine_archive_output |
| 519 | 519 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 520 | 520 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | try { |
| 527 | 527 | $sth = $this->db->prepare($query); |
| 528 | 528 | $sth->execute(); |
| 529 | - } catch(PDOException $e) { |
|
| 529 | + } catch (PDOException $e) { |
|
| 530 | 530 | echo $e->getMessage(); |
| 531 | 531 | die; |
| 532 | 532 | } |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | * @param array $filter |
| 544 | 544 | * @return array the spotter information |
| 545 | 545 | */ |
| 546 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 546 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
| 547 | 547 | { |
| 548 | 548 | global $globalDBdriver, $globalLiveInterval; |
| 549 | 549 | date_default_timezone_set('UTC'); |
| 550 | 550 | |
| 551 | 551 | $filter_query = ''; |
| 552 | 552 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 554 | 554 | } |
| 555 | 555 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 556 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | 557 | } |
| 558 | 558 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 559 | 559 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 560 | 560 | } |
| 561 | 561 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | try { |
| 575 | 575 | $sth = $this->db->prepare($query); |
| 576 | 576 | $sth->execute(); |
| 577 | - } catch(PDOException $e) { |
|
| 577 | + } catch (PDOException $e) { |
|
| 578 | 578 | echo $e->getMessage(); |
| 579 | 579 | die; |
| 580 | 580 | } |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | * @param array $filters |
| 618 | 618 | * @return array the spotter information |
| 619 | 619 | */ |
| 620 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 620 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 621 | 621 | { |
| 622 | 622 | global $globalTimezone, $globalDBdriver; |
| 623 | 623 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | } else { |
| 639 | 639 | $q_array = explode(" ", $q); |
| 640 | 640 | |
| 641 | - foreach ($q_array as $q_item){ |
|
| 641 | + foreach ($q_array as $q_item) { |
|
| 642 | 642 | $additional_query .= " AND ("; |
| 643 | 643 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 644 | 644 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | if ($registration != "") |
| 672 | 672 | { |
| 673 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 673 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 674 | 674 | if (!is_string($registration)) |
| 675 | 675 | { |
| 676 | 676 | return array(); |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | if ($aircraft_icao != "") |
| 683 | 683 | { |
| 684 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 684 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 685 | 685 | if (!is_string($aircraft_icao)) |
| 686 | 686 | { |
| 687 | 687 | return array(); |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | if ($aircraft_manufacturer != "") |
| 694 | 694 | { |
| 695 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 695 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 696 | 696 | if (!is_string($aircraft_manufacturer)) |
| 697 | 697 | { |
| 698 | 698 | return array(); |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | |
| 714 | 714 | if ($airline_icao != "") |
| 715 | 715 | { |
| 716 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 716 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 717 | 717 | if (!is_string($airline_icao)) |
| 718 | 718 | { |
| 719 | 719 | return array(); |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | if ($airline_country != "") |
| 726 | 726 | { |
| 727 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 727 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 728 | 728 | if (!is_string($airline_country)) |
| 729 | 729 | { |
| 730 | 730 | return array(); |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if ($airline_type != "") |
| 737 | 737 | { |
| 738 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 738 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | if (!is_string($airline_type)) |
| 740 | 740 | { |
| 741 | 741 | return array(); |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ($airport != "") |
| 759 | 759 | { |
| 760 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 760 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 761 | 761 | if (!is_string($airport)) |
| 762 | 762 | { |
| 763 | 763 | return array(); |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | if ($airport_country != "") |
| 770 | 770 | { |
| 771 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 771 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 772 | 772 | if (!is_string($airport_country)) |
| 773 | 773 | { |
| 774 | 774 | return array(); |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | if ($callsign != "") |
| 781 | 781 | { |
| 782 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 782 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 783 | 783 | if (!is_string($callsign)) |
| 784 | 784 | { |
| 785 | 785 | return array(); |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | $translate = $Translation->ident2icao($callsign); |
| 788 | 788 | if ($translate != $callsign) { |
| 789 | 789 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
| 790 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 790 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 791 | 791 | } else { |
| 792 | 792 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
| 793 | 793 | } |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | if ($owner != "") |
| 798 | 798 | { |
| 799 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 799 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 800 | 800 | if (!is_string($owner)) |
| 801 | 801 | { |
| 802 | 802 | return array(); |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | if ($pilot_name != "") |
| 809 | 809 | { |
| 810 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 810 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 811 | 811 | if (!is_string($pilot_name)) |
| 812 | 812 | { |
| 813 | 813 | return array(); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | if ($pilot_id != "") |
| 820 | 820 | { |
| 821 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 821 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | 822 | if (!is_string($pilot_id)) |
| 823 | 823 | { |
| 824 | 824 | return array(); |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | if ($departure_airport_route != "") |
| 831 | 831 | { |
| 832 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 832 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 833 | 833 | if (!is_string($departure_airport_route)) |
| 834 | 834 | { |
| 835 | 835 | return array(); |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | if ($arrival_airport_route != "") |
| 842 | 842 | { |
| 843 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 843 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 844 | 844 | if (!is_string($arrival_airport_route)) |
| 845 | 845 | { |
| 846 | 846 | return array(); |
@@ -853,8 +853,8 @@ discard block |
||
| 853 | 853 | { |
| 854 | 854 | $altitude_array = explode(",", $altitude); |
| 855 | 855 | |
| 856 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 856 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | 858 | |
| 859 | 859 | |
| 860 | 860 | if ($altitude_array[1] != "") |
@@ -872,8 +872,8 @@ discard block |
||
| 872 | 872 | { |
| 873 | 873 | $date_array = explode(",", $date_posted); |
| 874 | 874 | |
| 875 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 875 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 876 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 877 | 877 | |
| 878 | 878 | if ($globalTimezone != '') { |
| 879 | 879 | date_default_timezone_set($globalTimezone); |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | { |
| 906 | 906 | $limit_array = explode(",", $limit); |
| 907 | 907 | |
| 908 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 908 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 910 | 910 | |
| 911 | 911 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 912 | 912 | { |
@@ -917,8 +917,8 @@ discard block |
||
| 917 | 917 | |
| 918 | 918 | |
| 919 | 919 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 920 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 920 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 921 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 922 | 922 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 923 | 923 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 924 | 924 | } else { |
@@ -935,12 +935,12 @@ discard block |
||
| 935 | 935 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 938 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 939 | 939 | WHERE marine_archive_output.ident <> '' |
| 940 | 940 | ".$additional_query." |
| 941 | 941 | ".$filter_query.$orderby_query; |
| 942 | 942 | } |
| 943 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 943 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 944 | 944 | |
| 945 | 945 | return $spotter_array; |
| 946 | 946 | } |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | try { |
| 958 | 958 | $sth = $this->db->prepare($query); |
| 959 | 959 | $sth->execute(); |
| 960 | - } catch(PDOException $e) { |
|
| 960 | + } catch (PDOException $e) { |
|
| 961 | 961 | return "error"; |
| 962 | 962 | } |
| 963 | 963 | return ''; |
@@ -997,8 +997,8 @@ discard block |
||
| 997 | 997 | { |
| 998 | 998 | $limit_array = explode(",", $limit); |
| 999 | 999 | |
| 1000 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1002 | 1002 | |
| 1003 | 1003 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1004 | 1004 | { |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | $query_values = array(); |
| 1043 | 1043 | $limit_query = ''; |
| 1044 | 1044 | $additional_query = ''; |
| 1045 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1045 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1046 | 1046 | |
| 1047 | 1047 | if ($owner != "") |
| 1048 | 1048 | { |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | { |
| 1060 | 1060 | $limit_array = explode(",", $limit); |
| 1061 | 1061 | |
| 1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | 1064 | |
| 1065 | 1065 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1066 | 1066 | { |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | $query_values = array(); |
| 1104 | 1104 | $limit_query = ''; |
| 1105 | 1105 | $additional_query = ''; |
| 1106 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1106 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1107 | 1107 | |
| 1108 | 1108 | if ($pilot != "") |
| 1109 | 1109 | { |
@@ -1115,8 +1115,8 @@ discard block |
||
| 1115 | 1115 | { |
| 1116 | 1116 | $limit_array = explode(",", $limit); |
| 1117 | 1117 | |
| 1118 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1120 | 1120 | |
| 1121 | 1121 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1122 | 1122 | { |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | * @param string $sincedate |
| 1149 | 1149 | * @return array the airline country list |
| 1150 | 1150 | */ |
| 1151 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1151 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1152 | 1152 | { |
| 1153 | 1153 | global $globalDBdriver; |
| 1154 | 1154 | /* |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | $flight_array = array(); |
| 1178 | 1178 | $temp_array = array(); |
| 1179 | 1179 | |
| 1180 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1180 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1181 | 1181 | { |
| 1182 | 1182 | $temp_array['flight_count'] = $row['nb']; |
| 1183 | 1183 | $temp_array['flight_country'] = $row['name']; |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | * @param string $sincedate |
| 1197 | 1197 | * @return array the airline country list |
| 1198 | 1198 | */ |
| 1199 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1199 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1200 | 1200 | { |
| 1201 | 1201 | global $globalDBdriver; |
| 1202 | 1202 | /* |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | $flight_array = array(); |
| 1226 | 1226 | $temp_array = array(); |
| 1227 | 1227 | |
| 1228 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1228 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1231 | 1231 | $temp_array['flight_count'] = $row['nb']; |
@@ -1244,14 +1244,14 @@ discard block |
||
| 1244 | 1244 | * @param $date |
| 1245 | 1245 | * @return array the spotter information |
| 1246 | 1246 | */ |
| 1247 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1247 | + public function getDateArchiveMarineDataById($id, $date) |
|
| 1248 | 1248 | { |
| 1249 | 1249 | $Marine = new Marine($this->db); |
| 1250 | 1250 | date_default_timezone_set('UTC'); |
| 1251 | 1251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1252 | 1252 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1253 | - $date = date('c',$date); |
|
| 1254 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1253 | + $date = date('c', $date); |
|
| 1254 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1255 | 1255 | return $spotter_array; |
| 1256 | 1256 | } |
| 1257 | 1257 | |
@@ -1262,14 +1262,14 @@ discard block |
||
| 1262 | 1262 | * @param $date |
| 1263 | 1263 | * @return array the spotter information |
| 1264 | 1264 | */ |
| 1265 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1265 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
| 1266 | 1266 | { |
| 1267 | 1267 | $Marine = new Marine($this->db); |
| 1268 | 1268 | date_default_timezone_set('UTC'); |
| 1269 | 1269 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1270 | 1270 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1271 | - $date = date('c',$date); |
|
| 1272 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1271 | + $date = date('c', $date); |
|
| 1272 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1273 | 1273 | return $spotter_array; |
| 1274 | 1274 | } |
| 1275 | 1275 | |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | * @param array $filters |
| 1283 | 1283 | * @return array the spotter information |
| 1284 | 1284 | */ |
| 1285 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1285 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1286 | 1286 | { |
| 1287 | 1287 | global $global_query; |
| 1288 | 1288 | $Marine = new Marine($this->db); |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | $query_values = array(); |
| 1291 | 1291 | $limit_query = ''; |
| 1292 | 1292 | $additional_query = ''; |
| 1293 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1293 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1294 | 1294 | |
| 1295 | 1295 | if ($airport != "") |
| 1296 | 1296 | { |
@@ -1307,8 +1307,8 @@ discard block |
||
| 1307 | 1307 | { |
| 1308 | 1308 | $limit_array = explode(",", $limit); |
| 1309 | 1309 | |
| 1310 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1312 | 1312 | |
| 1313 | 1313 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1314 | 1314 | { |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | * @param bool $and |
| 29 | 29 | * @return String the SQL part |
| 30 | 30 | */ |
| 31 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 31 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 32 | 32 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 33 | 33 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 34 | 34 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 35 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
| 35 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
| 36 | 36 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
| 37 | 37 | } |
| 38 | 38 | } else { |
| 39 | 39 | $filter = $globalStatsFilters[$globalFilterName]; |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 42 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 43 | 43 | $filter_query_join = ''; |
| 44 | 44 | $filter_query_where = ''; |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 49 | 49 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | try { |
| 63 | 63 | $sth = $this->db->prepare($query); |
| 64 | 64 | $sth->execute($query_values); |
| 65 | - } catch(PDOException $e) { |
|
| 65 | + } catch (PDOException $e) { |
|
| 66 | 66 | return "error : ".$e->getMessage(); |
| 67 | 67 | } |
| 68 | 68 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | * @return Array Return ATC |
| 76 | 76 | */ |
| 77 | 77 | public function getById($id) { |
| 78 | - $filter_query = $this->getFilter(array(),true,true); |
|
| 78 | + $filter_query = $this->getFilter(array(), true, true); |
|
| 79 | 79 | $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
| 80 | 80 | $query_values = array(':id' => $id); |
| 81 | 81 | try { |
| 82 | 82 | $sth = $this->db->prepare($query); |
| 83 | 83 | $sth->execute($query_values); |
| 84 | - } catch(PDOException $e) { |
|
| 84 | + } catch (PDOException $e) { |
|
| 85 | 85 | return "error : ".$e->getMessage(); |
| 86 | 86 | } |
| 87 | 87 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -94,19 +94,19 @@ discard block |
||
| 94 | 94 | * @param String $format_source Format source |
| 95 | 95 | * @return Array Return ATC |
| 96 | 96 | */ |
| 97 | - public function getByIdent($ident,$format_source = '') { |
|
| 98 | - $filter_query = $this->getFilter(array(),true,true); |
|
| 97 | + public function getByIdent($ident, $format_source = '') { |
|
| 98 | + $filter_query = $this->getFilter(array(), true, true); |
|
| 99 | 99 | if ($format_source == '') { |
| 100 | 100 | $query = "SELECT * FROM atc".$filter_query." ident = :ident"; |
| 101 | 101 | $query_values = array(':ident' => $ident); |
| 102 | 102 | } else { |
| 103 | 103 | $query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source"; |
| 104 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 104 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 105 | 105 | } |
| 106 | 106 | try { |
| 107 | 107 | $sth = $this->db->prepare($query); |
| 108 | 108 | $sth->execute($query_values); |
| 109 | - } catch(PDOException $e) { |
|
| 109 | + } catch (PDOException $e) { |
|
| 110 | 110 | return "error : ".$e->getMessage(); |
| 111 | 111 | } |
| 112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | * @param String $format_source Format source |
| 129 | 129 | * @param String $source_name Source name |
| 130 | 130 | */ |
| 131 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 132 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 133 | - $info = str_replace('^','<br />',$info); |
|
| 134 | - $info = str_replace('&sect;','',$info); |
|
| 135 | - $info = str_replace('"','',$info); |
|
| 131 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 132 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 133 | + $info = str_replace('^', '<br />', $info); |
|
| 134 | + $info = str_replace('&sect;', '', $info); |
|
| 135 | + $info = str_replace('"', '', $info); |
|
| 136 | 136 | if ($type == '') $type = NULL; |
| 137 | 137 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 138 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 138 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 139 | 139 | try { |
| 140 | 140 | $sth = $this->db->prepare($query); |
| 141 | 141 | $sth->execute($query_values); |
| 142 | - } catch(PDOException $e) { |
|
| 142 | + } catch (PDOException $e) { |
|
| 143 | 143 | return "error : ".$e->getMessage(); |
| 144 | 144 | } |
| 145 | 145 | return ''; |
@@ -160,18 +160,18 @@ discard block |
||
| 160 | 160 | * @param String $format_source Format source |
| 161 | 161 | * @param String $source_name Source name |
| 162 | 162 | */ |
| 163 | - public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 164 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 165 | - $info = str_replace('^','<br />',$info); |
|
| 166 | - $info = str_replace('&sect;','',$info); |
|
| 167 | - $info = str_replace('"','',$info); |
|
| 163 | + public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 164 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 165 | + $info = str_replace('^', '<br />', $info); |
|
| 166 | + $info = str_replace('&sect;', '', $info); |
|
| 167 | + $info = str_replace('"', '', $info); |
|
| 168 | 168 | if ($type == '') $type = NULL; |
| 169 | 169 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 170 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 170 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 171 | 171 | try { |
| 172 | 172 | $sth = $this->db->prepare($query); |
| 173 | 173 | $sth->execute($query_values); |
| 174 | - } catch(PDOException $e) { |
|
| 174 | + } catch (PDOException $e) { |
|
| 175 | 175 | return "error : ".$e->getMessage(); |
| 176 | 176 | } |
| 177 | 177 | return ''; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | try { |
| 188 | 188 | $sth = $this->db->prepare($query); |
| 189 | 189 | $sth->execute($query_values); |
| 190 | - } catch(PDOException $e) { |
|
| 190 | + } catch (PDOException $e) { |
|
| 191 | 191 | return "error : ".$e->getMessage(); |
| 192 | 192 | } |
| 193 | 193 | return ''; |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | * @param String $ident Flight ident |
| 199 | 199 | * @param String $format_source Format source |
| 200 | 200 | */ |
| 201 | - public function deleteByIdent($ident,$format_source) { |
|
| 201 | + public function deleteByIdent($ident, $format_source) { |
|
| 202 | 202 | $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
| 203 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 203 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 204 | 204 | try { |
| 205 | 205 | $sth = $this->db->prepare($query); |
| 206 | 206 | $sth->execute($query_values); |
| 207 | - } catch(PDOException $e) { |
|
| 207 | + } catch (PDOException $e) { |
|
| 208 | 208 | return "error : ".$e->getMessage(); |
| 209 | 209 | } |
| 210 | 210 | return ''; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | try { |
| 220 | 220 | $sth = $this->db->prepare($query); |
| 221 | 221 | $sth->execute($query_values); |
| 222 | - } catch(PDOException $e) { |
|
| 222 | + } catch (PDOException $e) { |
|
| 223 | 223 | return "error : ".$e->getMessage(); |
| 224 | 224 | } |
| 225 | 225 | return ''; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | try { |
| 239 | 239 | $sth = $this->db->prepare($query); |
| 240 | 240 | $sth->execute(); |
| 241 | - } catch(PDOException $e) { |
|
| 241 | + } catch (PDOException $e) { |
|
| 242 | 242 | return "error"; |
| 243 | 243 | } |
| 244 | 244 | return "success"; |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * Change IATA to ICAO value for ident |
|
| 36 | - * |
|
| 37 | - * @param String $ident ident |
|
| 38 | - * @return String the icao |
|
| 39 | - */ |
|
| 35 | + * Change IATA to ICAO value for ident |
|
| 36 | + * |
|
| 37 | + * @param String $ident ident |
|
| 38 | + * @return String the icao |
|
| 39 | + */ |
|
| 40 | 40 | public function ident2icao($ident) { |
| 41 | 41 | if (substr($ident,0,2) == 'AF') { |
| 42 | 42 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * Deletes all info in the live table |
|
| 56 | - * |
|
| 57 | - * @return String success or false |
|
| 58 | - * |
|
| 59 | - */ |
|
| 55 | + * Deletes all info in the live table |
|
| 56 | + * |
|
| 57 | + * @return String success or false |
|
| 58 | + * |
|
| 59 | + */ |
|
| 60 | 60 | public function deleteLiveAcarsData() |
| 61 | 61 | { |
| 62 | 62 | global $globalDBdriver; |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * Deletes all info in the archive table |
|
| 80 | - * |
|
| 81 | - * @return String success or false |
|
| 82 | - * |
|
| 83 | - */ |
|
| 79 | + * Deletes all info in the archive table |
|
| 80 | + * |
|
| 81 | + * @return String success or false |
|
| 82 | + * |
|
| 83 | + */ |
|
| 84 | 84 | public function deleteArchiveAcarsData() |
| 85 | 85 | { |
| 86 | 86 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Parse ACARS data |
|
| 105 | - * |
|
| 106 | - * @param String ACARS data in acarsdec data |
|
| 107 | - * |
|
| 108 | - * @return array |
|
| 109 | - */ |
|
| 103 | + /** |
|
| 104 | + * Parse ACARS data |
|
| 105 | + * |
|
| 106 | + * @param String ACARS data in acarsdec data |
|
| 107 | + * |
|
| 108 | + * @return array |
|
| 109 | + */ |
|
| 110 | 110 | public function parse($data) { |
| 111 | 111 | global $globalDebug; |
| 112 | 112 | //$Image = new Image($this->db); |
@@ -736,11 +736,11 @@ discard block |
||
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
| 739 | - * Add ACARS data |
|
| 740 | - * |
|
| 741 | - * @param String ACARS data in acarsdec data |
|
| 742 | - * |
|
| 743 | - */ |
|
| 739 | + * Add ACARS data |
|
| 740 | + * |
|
| 741 | + * @param String ACARS data in acarsdec data |
|
| 742 | + * |
|
| 743 | + */ |
|
| 744 | 744 | public function add($data) { |
| 745 | 745 | global $globalDebug, $globalACARSArchive; |
| 746 | 746 | $Image = new Image($this->db); |
@@ -786,18 +786,18 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | - /** |
|
| 790 | - * Add Live ACARS data in DB |
|
| 791 | - * |
|
| 792 | - * @param String $ident ident |
|
| 793 | - * @param String $registration Registration of the aircraft |
|
| 794 | - * @param String $label Label of the ACARS message |
|
| 795 | - * @param String $block_id Block id of the ACARS message |
|
| 796 | - * @param String $msg_no Number of the ACARS message |
|
| 797 | - * @param String $message ACARS message |
|
| 798 | - * @param string $decode |
|
| 799 | - * @return bool |
|
| 800 | - */ |
|
| 789 | + /** |
|
| 790 | + * Add Live ACARS data in DB |
|
| 791 | + * |
|
| 792 | + * @param String $ident ident |
|
| 793 | + * @param String $registration Registration of the aircraft |
|
| 794 | + * @param String $label Label of the ACARS message |
|
| 795 | + * @param String $block_id Block id of the ACARS message |
|
| 796 | + * @param String $msg_no Number of the ACARS message |
|
| 797 | + * @param String $message ACARS message |
|
| 798 | + * @param string $decode |
|
| 799 | + * @return bool |
|
| 800 | + */ |
|
| 801 | 801 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 802 | 802 | global $globalDebug; |
| 803 | 803 | date_default_timezone_set('UTC'); |
@@ -835,18 +835,18 @@ discard block |
||
| 835 | 835 | return false; |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - /** |
|
| 839 | - * Add Archive ACARS data in DB |
|
| 840 | - * |
|
| 841 | - * @param String $ident ident |
|
| 842 | - * @param String $registration Registration of the aircraft |
|
| 843 | - * @param String $label Label of the ACARS message |
|
| 844 | - * @param String $block_id Block id of the ACARS message |
|
| 845 | - * @param String $msg_no Number of the ACARS message |
|
| 846 | - * @param String $message ACARS message |
|
| 847 | - * @param string $decode |
|
| 848 | - * @return string |
|
| 849 | - */ |
|
| 838 | + /** |
|
| 839 | + * Add Archive ACARS data in DB |
|
| 840 | + * |
|
| 841 | + * @param String $ident ident |
|
| 842 | + * @param String $registration Registration of the aircraft |
|
| 843 | + * @param String $label Label of the ACARS message |
|
| 844 | + * @param String $block_id Block id of the ACARS message |
|
| 845 | + * @param String $msg_no Number of the ACARS message |
|
| 846 | + * @param String $message ACARS message |
|
| 847 | + * @param string $decode |
|
| 848 | + * @return string |
|
| 849 | + */ |
|
| 850 | 850 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 851 | 851 | global $globalDebug; |
| 852 | 852 | date_default_timezone_set('UTC'); |
@@ -878,11 +878,11 @@ discard block |
||
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | /** |
| 881 | - * Get Message title from label from DB |
|
| 882 | - * |
|
| 883 | - * @param String $label |
|
| 884 | - * @return String Return ACARS title |
|
| 885 | - */ |
|
| 881 | + * Get Message title from label from DB |
|
| 882 | + * |
|
| 883 | + * @param String $label |
|
| 884 | + * @return String Return ACARS title |
|
| 885 | + */ |
|
| 886 | 886 | public function getTitlefromLabel($label) { |
| 887 | 887 | $Connection = new Connection($this->db); |
| 888 | 888 | $this->db = $Connection->db; |
@@ -901,10 +901,10 @@ discard block |
||
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
| 904 | - * List all Message title & label from DB |
|
| 905 | - * |
|
| 906 | - * @return array Return ACARS data in array |
|
| 907 | - */ |
|
| 904 | + * List all Message title & label from DB |
|
| 905 | + * |
|
| 906 | + * @return array Return ACARS data in array |
|
| 907 | + */ |
|
| 908 | 908 | public function getAllTitleLabel() { |
| 909 | 909 | $query = "SELECT * FROM acars_label ORDER BY title"; |
| 910 | 910 | $query_values = array(); |
@@ -921,11 +921,11 @@ discard block |
||
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
| 924 | - * Get Live ACARS data from DB |
|
| 925 | - * |
|
| 926 | - * @param String $ident |
|
| 927 | - * @return array Return ACARS data in array |
|
| 928 | - */ |
|
| 924 | + * Get Live ACARS data from DB |
|
| 925 | + * |
|
| 926 | + * @param String $ident |
|
| 927 | + * @return array Return ACARS data in array |
|
| 928 | + */ |
|
| 929 | 929 | public function getLiveAcarsData($ident) { |
| 930 | 930 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
| 931 | 931 | $query_values = array(':ident' => $ident); |
@@ -941,13 +941,13 @@ discard block |
||
| 941 | 941 | else return array(); |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | - /** |
|
| 945 | - * Get Latest ACARS data from DB |
|
| 946 | - * |
|
| 947 | - * @param string $limit |
|
| 948 | - * @param string $label |
|
| 949 | - * @return array Return ACARS data in array |
|
| 950 | - */ |
|
| 944 | + /** |
|
| 945 | + * Get Latest ACARS data from DB |
|
| 946 | + * |
|
| 947 | + * @param string $limit |
|
| 948 | + * @param string $label |
|
| 949 | + * @return array Return ACARS data in array |
|
| 950 | + */ |
|
| 951 | 951 | public function getLatestAcarsData($limit = '',$label = '') { |
| 952 | 952 | global $globalURL; |
| 953 | 953 | $Image = new Image($this->db); |
@@ -1035,13 +1035,13 @@ discard block |
||
| 1035 | 1035 | else return array(); |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | - /** |
|
| 1039 | - * Get Archive ACARS data from DB |
|
| 1040 | - * |
|
| 1041 | - * @param string $limit |
|
| 1042 | - * @param string $label |
|
| 1043 | - * @return array Return ACARS data in array |
|
| 1044 | - */ |
|
| 1038 | + /** |
|
| 1039 | + * Get Archive ACARS data from DB |
|
| 1040 | + * |
|
| 1041 | + * @param string $limit |
|
| 1042 | + * @param string $label |
|
| 1043 | + * @return array Return ACARS data in array |
|
| 1044 | + */ |
|
| 1045 | 1045 | public function getArchiveAcarsData($limit = '',$label = '') { |
| 1046 | 1046 | global $globalURL; |
| 1047 | 1047 | $Image = new Image($this->db); |
@@ -1130,17 +1130,17 @@ discard block |
||
| 1130 | 1130 | } else return array(); |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | - /** |
|
| 1134 | - * Add ModeS data to DB |
|
| 1135 | - * |
|
| 1136 | - * @param String $ident ident |
|
| 1137 | - * @param String $registration Registration of the aircraft |
|
| 1138 | - * @param String $icao |
|
| 1139 | - * @param String $ICAOTypeCode |
|
| 1140 | - * @param string $latitude |
|
| 1141 | - * @param string $longitude |
|
| 1142 | - * @return string |
|
| 1143 | - */ |
|
| 1133 | + /** |
|
| 1134 | + * Add ModeS data to DB |
|
| 1135 | + * |
|
| 1136 | + * @param String $ident ident |
|
| 1137 | + * @param String $registration Registration of the aircraft |
|
| 1138 | + * @param String $icao |
|
| 1139 | + * @param String $ICAOTypeCode |
|
| 1140 | + * @param string $latitude |
|
| 1141 | + * @param string $longitude |
|
| 1142 | + * @return string |
|
| 1143 | + */ |
|
| 1144 | 1144 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
| 1145 | 1145 | global $globalDebug, $globalDBdriver; |
| 1146 | 1146 | $ident = trim($ident); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /* |
| 22 | 22 | * Initialize DB connection |
| 23 | 23 | */ |
| 24 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
| 24 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
| 25 | 25 | $Connection = new Connection($dbc); |
| 26 | 26 | $this->db = $Connection->db(); |
| 27 | 27 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | * @return String the icao |
| 39 | 39 | */ |
| 40 | 40 | public function ident2icao($ident) { |
| 41 | - if (substr($ident,0,2) == 'AF') { |
|
| 42 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 43 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 41 | + if (substr($ident, 0, 2) == 'AF') { |
|
| 42 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 43 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
| 44 | 44 | } else { |
| 45 | 45 | $Spotter = new Spotter($this->db); |
| 46 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
| 46 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
| 47 | 47 | if (isset($identicao[0])) { |
| 48 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
| 48 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
| 49 | 49 | } else $icao = $ident; |
| 50 | 50 | } |
| 51 | 51 | return $icao; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $sth = $this->db->prepare($query); |
| 71 | 71 | $sth->execute(); |
| 72 | - } catch(PDOException $e) { |
|
| 72 | + } catch (PDOException $e) { |
|
| 73 | 73 | return "error"; |
| 74 | 74 | } |
| 75 | 75 | return "success"; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $sth = $this->db->prepare($query); |
| 95 | 95 | $sth->execute(); |
| 96 | - } catch(PDOException $e) { |
|
| 96 | + } catch (PDOException $e) { |
|
| 97 | 97 | return "error"; |
| 98 | 98 | } |
| 99 | 99 | return "success"; |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | $ident = ''; |
| 120 | 120 | $message = ''; |
| 121 | 121 | $result = array(); |
| 122 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 123 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 124 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 125 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 122 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 123 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 124 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 125 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 126 | 126 | if ($n != 0) { |
| 127 | - $registration = str_replace('.','',$registration); |
|
| 128 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
| 127 | + $registration = str_replace('.', '', $registration); |
|
| 128 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
| 129 | 129 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
| 130 | 130 | } else $message = $data; |
| 131 | 131 | $decode = array(); |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | $temp = ''; |
| 146 | 146 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
| 147 | 147 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 148 | - $latitude = $la / 10000.0; |
|
| 149 | - $longitude = $ln / 10000.0; |
|
| 148 | + $latitude = $la/10000.0; |
|
| 149 | + $longitude = $ln/10000.0; |
|
| 150 | 150 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 151 | 151 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 152 | 152 | // Temp not always available |
| 153 | 153 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
| 154 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 155 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 154 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
| 155 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
| 156 | 156 | |
| 157 | 157 | //$icao = $Translation->checkTranslation($ident); |
| 158 | 158 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | $dhour = ''; |
| 165 | 165 | $darr = ''; |
| 166 | 166 | $ahour = ''; |
| 167 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
| 167 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
| 168 | 168 | if ($n == 4 && strlen($darr) == 4) { |
| 169 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 170 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 171 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 169 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 170 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
| 171 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
| 172 | 172 | //$icao = ACARS->ident2icao($ident); |
| 173 | 173 | //$icao = $Translation->checkTranslation($ident); |
| 174 | 174 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 175 | 175 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 176 | 176 | $found = true; |
| 177 | 177 | } |
| 178 | - elseif ($n == 2 || $n == 4) { |
|
| 179 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 178 | + elseif ($n == 2 || $n == 4) { |
|
| 179 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 180 | 180 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
| 181 | 181 | //$icao = ACARS->ident2icao($ident); |
| 182 | 182 | //$icao = $Translation->checkTranslation($ident); |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | $ahour = ''; |
| 235 | 235 | $aair = ''; |
| 236 | 236 | $apiste = ''; |
| 237 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
| 237 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
| 238 | 238 | if ($n > 8) { |
| 239 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 240 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 241 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 239 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 240 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 241 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
| 242 | 242 | $icao = trim($aident); |
| 243 | 243 | |
| 244 | 244 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 264 | 264 | $las = $las.'.'.$lass; |
| 265 | 265 | $lns = $lns.'.'.$lns; |
| 266 | - $latitude = $las / 1000.0; |
|
| 267 | - $longitude = $lns / 1000.0; |
|
| 266 | + $latitude = $las/1000.0; |
|
| 267 | + $longitude = $lns/1000.0; |
|
| 268 | 268 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 269 | 269 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 270 | 270 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -359,17 +359,17 @@ discard block |
||
| 359 | 359 | $alt = ''; |
| 360 | 360 | $fuel = ''; |
| 361 | 361 | $speed = ''; |
| 362 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
| 362 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
| 363 | 363 | if ($n == 9) { |
| 364 | 364 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 365 | 365 | $icao = trim($aident); |
| 366 | 366 | $decode['icao'] = $icao; |
| 367 | - $latitude = $las / 100.0; |
|
| 368 | - $longitude = $lns / 100.0; |
|
| 367 | + $latitude = $las/100.0; |
|
| 368 | + $longitude = $lns/100.0; |
|
| 369 | 369 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 370 | 370 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 371 | 371 | |
| 372 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
| 372 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
| 373 | 373 | $found = true; |
| 374 | 374 | } |
| 375 | 375 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 389 | 389 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 390 | 390 | |
| 391 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
| 391 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
| 392 | 392 | $found = true; |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | $dair = ''; |
| 422 | 422 | $darr = ''; |
| 423 | 423 | $aident = ''; |
| 424 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
| 424 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
| 425 | 425 | if ($n == 8) { |
| 426 | 426 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 427 | 427 | $icao = trim($aident); |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | $dair = ''; |
| 455 | 455 | $darr = ''; |
| 456 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
| 456 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
| 457 | 457 | if ($n == 3) { |
| 458 | 458 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 459 | 459 | //$icao = $Translation->checkTranslation($ident); |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | */ |
| 469 | 469 | $dair = ''; |
| 470 | 470 | $darr = ''; |
| 471 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
| 471 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
| 472 | 472 | if ($n == 3) { |
| 473 | 473 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 474 | 474 | //$icao = $Translation->checkTranslation($ident); |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | if (!$found) { |
| 481 | - $n = sscanf($message,'MET01%4c',$airport); |
|
| 481 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
| 482 | 482 | if ($n == 1) { |
| 483 | 483 | if ($globalDebug) echo 'airport name : '.$airport; |
| 484 | 484 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -486,241 +486,241 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | if ($label == 'H1') { |
| 489 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
| 490 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
| 489 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
| 490 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
| 491 | 491 | } |
| 492 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 493 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
| 492 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
| 493 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
| 494 | 494 | } |
| 495 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 496 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
| 495 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
| 496 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
| 497 | 497 | } |
| 498 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 499 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
| 498 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
| 499 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
| 500 | 500 | } |
| 501 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 502 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
| 501 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
| 502 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
| 503 | 503 | } |
| 504 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 505 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
| 504 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
| 505 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
| 506 | 506 | } |
| 507 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 508 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
| 507 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
| 508 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
| 509 | 509 | } |
| 510 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 511 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
| 510 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
| 511 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
| 512 | 512 | } |
| 513 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 514 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
| 513 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
| 514 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
| 515 | 515 | } |
| 516 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 517 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
| 516 | + elseif (preg_match(':^#CF:', $message)) { |
|
| 517 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
| 518 | 518 | } |
| 519 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 520 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
| 519 | + elseif (preg_match(':^#DF:', $message)) { |
|
| 520 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
| 521 | 521 | } |
| 522 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 523 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
| 522 | + elseif (preg_match(':^#EC:', $message)) { |
|
| 523 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
| 524 | 524 | } |
| 525 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 526 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
| 525 | + elseif (preg_match(':^#EI:', $message)) { |
|
| 526 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
| 527 | 527 | } |
| 528 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 529 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
| 528 | + elseif (preg_match(':^#H1:', $message)) { |
|
| 529 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
| 530 | 530 | } |
| 531 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 532 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
| 531 | + elseif (preg_match(':^#H2:', $message)) { |
|
| 532 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
| 533 | 533 | } |
| 534 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 535 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
| 534 | + elseif (preg_match(':^#HD:', $message)) { |
|
| 535 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
| 536 | 536 | } |
| 537 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 538 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
| 537 | + elseif (preg_match(':^#M1:', $message)) { |
|
| 538 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
| 539 | 539 | } |
| 540 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 541 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
| 540 | + elseif (preg_match(':^#M2:', $message)) { |
|
| 541 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
| 542 | 542 | } |
| 543 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 544 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
| 543 | + elseif (preg_match(':^#M3:', $message)) { |
|
| 544 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
| 545 | 545 | } |
| 546 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 547 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
| 546 | + elseif (preg_match(':^#MD:', $message)) { |
|
| 547 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
| 548 | 548 | } |
| 549 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 550 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
| 549 | + elseif (preg_match(':^#PS:', $message)) { |
|
| 550 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
| 551 | 551 | } |
| 552 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 553 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
| 552 | + elseif (preg_match(':^#S1:', $message)) { |
|
| 553 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
| 554 | 554 | } |
| 555 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 556 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
| 555 | + elseif (preg_match(':^#S2:', $message)) { |
|
| 556 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
| 557 | 557 | } |
| 558 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 559 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
| 558 | + elseif (preg_match(':^#SD:', $message)) { |
|
| 559 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
| 560 | 560 | } |
| 561 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 562 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
| 561 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
| 562 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
| 563 | 563 | } |
| 564 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 565 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
| 564 | + elseif (preg_match(':^#WO:', $message)) { |
|
| 565 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
| 566 | 566 | } |
| 567 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 568 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
| 567 | + elseif (preg_match(':^#A1:', $message)) { |
|
| 568 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
| 569 | 569 | } |
| 570 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 571 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
| 570 | + elseif (preg_match(':^#A3:', $message)) { |
|
| 571 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
| 572 | 572 | } |
| 573 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 574 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
| 573 | + elseif (preg_match(':^#A4:', $message)) { |
|
| 574 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
| 575 | 575 | } |
| 576 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 577 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
| 576 | + elseif (preg_match(':^#A6:', $message)) { |
|
| 577 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
| 578 | 578 | } |
| 579 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 580 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
| 579 | + elseif (preg_match(':^#A8:', $message)) { |
|
| 580 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
| 581 | 581 | } |
| 582 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 583 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
| 582 | + elseif (preg_match(':^#A9:', $message)) { |
|
| 583 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
| 584 | 584 | } |
| 585 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 586 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
| 585 | + elseif (preg_match(':^#A0:', $message)) { |
|
| 586 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
| 587 | 587 | } |
| 588 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 589 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
| 588 | + elseif (preg_match(':^#AA:', $message)) { |
|
| 589 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
| 590 | 590 | } |
| 591 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 592 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
| 591 | + elseif (preg_match(':^#AB:', $message)) { |
|
| 592 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
| 593 | 593 | } |
| 594 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 595 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
| 594 | + elseif (preg_match(':^#AC:', $message)) { |
|
| 595 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
| 596 | 596 | } |
| 597 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 598 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
| 597 | + elseif (preg_match(':^#AD:', $message)) { |
|
| 598 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
| 599 | 599 | } |
| 600 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 601 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
| 600 | + elseif (preg_match(':^#AF:', $message)) { |
|
| 601 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
| 602 | 602 | } |
| 603 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 604 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
| 603 | + elseif (preg_match(':^#B1:', $message)) { |
|
| 604 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
| 605 | 605 | } |
| 606 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 607 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
| 606 | + elseif (preg_match(':^#B2:', $message)) { |
|
| 607 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
| 608 | 608 | } |
| 609 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 610 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
| 609 | + elseif (preg_match(':^#B3:', $message)) { |
|
| 610 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
| 611 | 611 | } |
| 612 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 613 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
| 612 | + elseif (preg_match(':^#B4:', $message)) { |
|
| 613 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
| 614 | 614 | } |
| 615 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 616 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
| 615 | + elseif (preg_match(':^#B6:', $message)) { |
|
| 616 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
| 617 | 617 | } |
| 618 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 619 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
| 618 | + elseif (preg_match(':^#B8:', $message)) { |
|
| 619 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
| 620 | 620 | } |
| 621 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 622 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
| 621 | + elseif (preg_match(':^#B9:', $message)) { |
|
| 622 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
| 623 | 623 | } |
| 624 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 625 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
| 624 | + elseif (preg_match(':^#B0:', $message)) { |
|
| 625 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
| 626 | 626 | } |
| 627 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 628 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
| 627 | + elseif (preg_match(':^#BA:', $message)) { |
|
| 628 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
| 629 | 629 | } |
| 630 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 631 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
| 630 | + elseif (preg_match(':^#BB:', $message)) { |
|
| 631 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
| 632 | 632 | } |
| 633 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 634 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
| 633 | + elseif (preg_match(':^#BC:', $message)) { |
|
| 634 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
| 635 | 635 | } |
| 636 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 637 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
| 636 | + elseif (preg_match(':^#BD:', $message)) { |
|
| 637 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
| 638 | 638 | } |
| 639 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 640 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
| 639 | + elseif (preg_match(':^#BE:', $message)) { |
|
| 640 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
| 641 | 641 | } |
| 642 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 643 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
| 642 | + elseif (preg_match(':^#BF:', $message)) { |
|
| 643 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
| 644 | 644 | } |
| 645 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 646 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
| 645 | + elseif (preg_match(':^#H3:', $message)) { |
|
| 646 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | if ($label == '10') { |
| 650 | - if (preg_match(':^DTO01:',$message)) { |
|
| 651 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
| 650 | + if (preg_match(':^DTO01:', $message)) { |
|
| 651 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
| 652 | 652 | } |
| 653 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 654 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
| 653 | + elseif (preg_match(':^AIS01:', $message)) { |
|
| 654 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
| 655 | 655 | } |
| 656 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 657 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
| 656 | + elseif (preg_match(':^FTX01:', $message)) { |
|
| 657 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
| 658 | 658 | } |
| 659 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 660 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
| 659 | + elseif (preg_match(':^FPL01:', $message)) { |
|
| 660 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
| 661 | 661 | } |
| 662 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 663 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
| 662 | + elseif (preg_match(':^WAB01:', $message)) { |
|
| 663 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
| 664 | 664 | } |
| 665 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 666 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
| 665 | + elseif (preg_match(':^MET01:', $message)) { |
|
| 666 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
| 667 | 667 | } |
| 668 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 669 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
| 668 | + elseif (preg_match(':^WAB02:', $message)) { |
|
| 669 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | if ($label == '15') { |
| 673 | - if (preg_match(':^FST01:',$message)) { |
|
| 674 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
| 673 | + if (preg_match(':^FST01:', $message)) { |
|
| 674 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | if (!$found && $label == 'SA') { |
| 678 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
| 678 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
| 679 | 679 | if ($n == 4) { |
| 680 | 680 | $vsta = array('Version' => $version); |
| 681 | 681 | if ($state == 'E') { |
| 682 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
| 682 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
| 683 | 683 | } |
| 684 | 684 | elseif ($state == 'L') { |
| 685 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
| 685 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
| 686 | 686 | } |
| 687 | 687 | else { |
| 688 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
| 688 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
| 689 | 689 | } |
| 690 | 690 | if ($type == 'V') { |
| 691 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
| 691 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
| 692 | 692 | } |
| 693 | 693 | elseif ($type == 'S') { |
| 694 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
| 694 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
| 695 | 695 | } |
| 696 | 696 | elseif ($type == 'H') { |
| 697 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
| 697 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
| 698 | 698 | } |
| 699 | 699 | elseif ($type == 'G') { |
| 700 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
| 700 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
| 701 | 701 | } |
| 702 | 702 | elseif ($type == 'C') { |
| 703 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
| 703 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
| 704 | 704 | } |
| 705 | 705 | elseif ($type == '2') { |
| 706 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
| 706 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
| 707 | 707 | } |
| 708 | 708 | elseif ($type == 'X') { |
| 709 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
| 709 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
| 710 | 710 | } |
| 711 | 711 | elseif ($type == 'I') { |
| 712 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
| 712 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
| 713 | 713 | } |
| 714 | 714 | else { |
| 715 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
| 715 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
| 716 | 716 | } |
| 717 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
| 718 | - $decode = array_merge($vsta,$decode); |
|
| 717 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
| 718 | + $decode = array_merge($vsta, $decode); |
|
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | $title = $this->getTitlefromLabel($label); |
| 723 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 723 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
| 724 | 724 | /* |
| 725 | 725 | // Business jets always use GS0001 |
| 726 | 726 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -748,13 +748,13 @@ discard block |
||
| 748 | 748 | $Translation = new Translation($this->db); |
| 749 | 749 | $message = $this->parse($data); |
| 750 | 750 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
| 751 | - $ident = (string)$message['ident']; |
|
| 751 | + $ident = (string) $message['ident']; |
|
| 752 | 752 | $label = $message['label']; |
| 753 | 753 | $block_id = $message['block_id']; |
| 754 | 754 | $msg_no = $message['msg_no']; |
| 755 | 755 | $msg = $message['message']; |
| 756 | 756 | $decode = $message['decode']; |
| 757 | - $registration = (string)$message['registration']; |
|
| 757 | + $registration = (string) $message['registration']; |
|
| 758 | 758 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
| 759 | 759 | else $latitude = ''; |
| 760 | 760 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -768,20 +768,20 @@ discard block |
||
| 768 | 768 | $Image->addSpotterImage($registration); |
| 769 | 769 | } |
| 770 | 770 | // Business jets always use GS0001 |
| 771 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 771 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
| 772 | 772 | if ($globalDebug && isset($info) && $info != '') echo $info; |
| 773 | 773 | if (count($decode) > 0) $decode_json = json_encode($decode); |
| 774 | 774 | else $decode_json = ''; |
| 775 | 775 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 776 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
| 776 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
| 777 | 777 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 778 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
| 778 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
| 779 | 779 | } |
| 780 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 781 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 782 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 780 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
| 781 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
| 782 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
| 783 | 783 | if ($globalDebug && count($decode) > 0) { |
| 784 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
| 784 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | } |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | * @param string $decode |
| 799 | 799 | * @return bool |
| 800 | 800 | */ |
| 801 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
| 801 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
| 802 | 802 | global $globalDebug; |
| 803 | 803 | date_default_timezone_set('UTC'); |
| 804 | 804 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -806,22 +806,22 @@ discard block |
||
| 806 | 806 | $this->db = $Connection->db; |
| 807 | 807 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
| 808 | 808 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 809 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
| 809 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
| 810 | 810 | try { |
| 811 | 811 | $stht = $this->db->prepare($query_test); |
| 812 | 812 | $stht->execute($query_test_values); |
| 813 | - } catch(PDOException $e) { |
|
| 813 | + } catch (PDOException $e) { |
|
| 814 | 814 | echo "error : ".$e->getMessage(); |
| 815 | 815 | return false; |
| 816 | 816 | } |
| 817 | 817 | if ($stht->fetchColumn() == 0) { |
| 818 | 818 | if ($globalDebug) echo "Add Live ACARS data..."; |
| 819 | 819 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
| 820 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
| 820 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
| 821 | 821 | try { |
| 822 | 822 | $sth = $this->db->prepare($query); |
| 823 | 823 | $sth->execute($query_values); |
| 824 | - } catch(PDOException $e) { |
|
| 824 | + } catch (PDOException $e) { |
|
| 825 | 825 | echo "error : ".$e->getMessage(); |
| 826 | 826 | return false; |
| 827 | 827 | } |
@@ -847,10 +847,10 @@ discard block |
||
| 847 | 847 | * @param string $decode |
| 848 | 848 | * @return string |
| 849 | 849 | */ |
| 850 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
| 850 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
| 851 | 851 | global $globalDebug; |
| 852 | 852 | date_default_timezone_set('UTC'); |
| 853 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
| 853 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
| 854 | 854 | /* |
| 855 | 855 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
| 856 | 856 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -865,11 +865,11 @@ discard block |
||
| 865 | 865 | */ |
| 866 | 866 | if ($globalDebug) echo "Add Live ACARS data..."; |
| 867 | 867 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 868 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
| 868 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
| 869 | 869 | try { |
| 870 | 870 | $sth = $this->db->prepare($query); |
| 871 | 871 | $sth->execute($query_values); |
| 872 | - } catch(PDOException $e) { |
|
| 872 | + } catch (PDOException $e) { |
|
| 873 | 873 | return "error : ".$e->getMessage(); |
| 874 | 874 | } |
| 875 | 875 | if ($globalDebug) echo "Done\n"; |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | try { |
| 892 | 892 | $sth = $this->db->prepare($query); |
| 893 | 893 | $sth->execute($query_values); |
| 894 | - } catch(PDOException $e) { |
|
| 894 | + } catch (PDOException $e) { |
|
| 895 | 895 | echo "error : ".$e->getMessage(); |
| 896 | 896 | return ''; |
| 897 | 897 | } |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | try { |
| 912 | 912 | $sth = $this->db->prepare($query); |
| 913 | 913 | $sth->execute($query_values); |
| 914 | - } catch(PDOException $e) { |
|
| 914 | + } catch (PDOException $e) { |
|
| 915 | 915 | echo "error : ".$e->getMessage(); |
| 916 | 916 | return array(); |
| 917 | 917 | } |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | try { |
| 933 | 933 | $sth = $this->db->prepare($query); |
| 934 | 934 | $sth->execute($query_values); |
| 935 | - } catch(PDOException $e) { |
|
| 935 | + } catch (PDOException $e) { |
|
| 936 | 936 | echo "error : ".$e->getMessage(); |
| 937 | 937 | return array(); |
| 938 | 938 | } |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | * @param string $label |
| 949 | 949 | * @return array Return ACARS data in array |
| 950 | 950 | */ |
| 951 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
| 951 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
| 952 | 952 | global $globalURL; |
| 953 | 953 | $Image = new Image($this->db); |
| 954 | 954 | $Spotter = new Spotter($this->db); |
@@ -959,8 +959,8 @@ discard block |
||
| 959 | 959 | if ($limit != "") |
| 960 | 960 | { |
| 961 | 961 | $limit_array = explode(",", $limit); |
| 962 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 963 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 962 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 963 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 964 | 964 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 965 | 965 | { |
| 966 | 966 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | try { |
| 977 | 977 | $sth = $this->db->prepare($query); |
| 978 | 978 | $sth->execute($query_values); |
| 979 | - } catch(PDOException $e) { |
|
| 979 | + } catch (PDOException $e) { |
|
| 980 | 980 | echo "error : ".$e->getMessage(); |
| 981 | 981 | return array(); |
| 982 | 982 | } |
@@ -984,39 +984,39 @@ discard block |
||
| 984 | 984 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 985 | 985 | $data = array(); |
| 986 | 986 | if ($row['registration'] != '') { |
| 987 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
| 987 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
| 988 | 988 | $image_array = $Image->getSpotterImage($row['registration']); |
| 989 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 990 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 991 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 989 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 990 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 991 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 992 | 992 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 993 | 993 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 994 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
| 994 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
| 995 | 995 | if (isset($identicao[0])) { |
| 996 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 997 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 998 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 999 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1000 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 996 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 997 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 998 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 999 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 1000 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 1001 | 1001 | } else $icao = $row['ident']; |
| 1002 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 1003 | - $decode = json_decode($row['decode'],true); |
|
| 1002 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 1003 | + $decode = json_decode($row['decode'], true); |
|
| 1004 | 1004 | $found = false; |
| 1005 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
| 1005 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
| 1006 | 1006 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1007 | 1007 | if (isset($airport_info[0]['icao'])) { |
| 1008 | 1008 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1009 | 1009 | $found = true; |
| 1010 | 1010 | } |
| 1011 | 1011 | } |
| 1012 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
| 1012 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
| 1013 | 1013 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1014 | 1014 | if (isset($airport_info[0]['icao'])) { |
| 1015 | 1015 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1016 | 1016 | $found = true; |
| 1017 | 1017 | } |
| 1018 | 1018 | } |
| 1019 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
| 1019 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
| 1020 | 1020 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
| 1021 | 1021 | if (isset($airport_info[0]['icao'])) { |
| 1022 | 1022 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | if ($found) $row['decode'] = json_encode($decode); |
| 1027 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1027 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1028 | 1028 | $result[] = $data; |
| 1029 | 1029 | $i++; |
| 1030 | 1030 | } |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | * @param string $label |
| 1043 | 1043 | * @return array Return ACARS data in array |
| 1044 | 1044 | */ |
| 1045 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
| 1045 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
| 1046 | 1046 | global $globalURL; |
| 1047 | 1047 | $Image = new Image($this->db); |
| 1048 | 1048 | $Spotter = new Spotter($this->db); |
@@ -1052,8 +1052,8 @@ discard block |
||
| 1052 | 1052 | if ($limit != "") |
| 1053 | 1053 | { |
| 1054 | 1054 | $limit_array = explode(",", $limit); |
| 1055 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1056 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1055 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1056 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1057 | 1057 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1058 | 1058 | { |
| 1059 | 1059 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1074,45 +1074,45 @@ discard block |
||
| 1074 | 1074 | try { |
| 1075 | 1075 | $sth = $this->db->prepare($query); |
| 1076 | 1076 | $sth->execute($query_values); |
| 1077 | - } catch(PDOException $e) { |
|
| 1077 | + } catch (PDOException $e) { |
|
| 1078 | 1078 | echo "error : ".$e->getMessage(); |
| 1079 | 1079 | return array(); |
| 1080 | 1080 | } |
| 1081 | - $i=0; |
|
| 1081 | + $i = 0; |
|
| 1082 | 1082 | $result = array(); |
| 1083 | 1083 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 1084 | 1084 | $data = array(); |
| 1085 | 1085 | if ($row['registration'] != '') { |
| 1086 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
| 1086 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
| 1087 | 1087 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1088 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1089 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1090 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1088 | + if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1089 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 1090 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 1091 | 1091 | $icao = ''; |
| 1092 | 1092 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 1093 | 1093 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 1094 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
| 1094 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
| 1095 | 1095 | if (isset($identicao[0])) { |
| 1096 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 1097 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1098 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1099 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1100 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 1096 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 1097 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1098 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 1099 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 1100 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 1101 | 1101 | } else $icao = $row['ident']; |
| 1102 | 1102 | $icao = $Translation->checkTranslation($icao); |
| 1103 | - $decode = json_decode($row['decode'],true); |
|
| 1103 | + $decode = json_decode($row['decode'], true); |
|
| 1104 | 1104 | $found = false; |
| 1105 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
| 1105 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
| 1106 | 1106 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1107 | 1107 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1108 | 1108 | $found = true; |
| 1109 | 1109 | } |
| 1110 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
| 1110 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
| 1111 | 1111 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1112 | 1112 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1113 | 1113 | $found = true; |
| 1114 | 1114 | } |
| 1115 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
| 1115 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
| 1116 | 1116 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
| 1117 | 1117 | if (isset($airport_info[0]['icao'])) { |
| 1118 | 1118 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | } |
| 1121 | 1121 | } |
| 1122 | 1122 | if ($found) $row['decode'] = json_encode($decode); |
| 1123 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1123 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1124 | 1124 | $result[] = $data; |
| 1125 | 1125 | $i++; |
| 1126 | 1126 | } |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | * @param string $longitude |
| 1142 | 1142 | * @return string |
| 1143 | 1143 | */ |
| 1144 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
| 1144 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
| 1145 | 1145 | global $globalDebug, $globalDBdriver; |
| 1146 | 1146 | $ident = trim($ident); |
| 1147 | 1147 | $Translation = new Translation($this->db); |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
| 1155 | 1155 | return ''; |
| 1156 | 1156 | } |
| 1157 | - $registration = str_replace('.','',$registration); |
|
| 1157 | + $registration = str_replace('.', '', $registration); |
|
| 1158 | 1158 | $ident = $Translation->ident2icao($ident); |
| 1159 | 1159 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1160 | 1160 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1163,7 +1163,7 @@ discard block |
||
| 1163 | 1163 | try { |
| 1164 | 1164 | $sthsi = $this->db->prepare($querysi); |
| 1165 | 1165 | $sthsi->execute($querysi_values); |
| 1166 | - } catch(PDOException $e) { |
|
| 1166 | + } catch (PDOException $e) { |
|
| 1167 | 1167 | if ($globalDebug) echo $e->getMessage(); |
| 1168 | 1168 | return "error : ".$e->getMessage(); |
| 1169 | 1169 | } |
@@ -1173,8 +1173,8 @@ discard block |
||
| 1173 | 1173 | $Translation = new Translation($this->db); |
| 1174 | 1174 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1175 | 1175 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
| 1176 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1177 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1176 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
| 1177 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
| 1178 | 1178 | } else { |
| 1179 | 1179 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1180 | 1180 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | try { |
| 1183 | 1183 | $sth = $this->db->prepare($query); |
| 1184 | 1184 | $sth->execute($query_values); |
| 1185 | - } catch(PDOException $e) { |
|
| 1185 | + } catch (PDOException $e) { |
|
| 1186 | 1186 | if ($globalDebug) echo $e->getMessage(); |
| 1187 | 1187 | return "error : ".$e->getMessage(); |
| 1188 | 1188 | } |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | $sth->closeCursor(); |
| 1191 | 1191 | if (isset($result['modes'])) $hex = $result['modes']; |
| 1192 | 1192 | else $hex = ''; |
| 1193 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
| 1193 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
| 1194 | 1194 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
| 1195 | 1195 | } |
| 1196 | 1196 | } |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | try { |
| 1201 | 1201 | $sth = $this->db->prepare($query); |
| 1202 | 1202 | $sth->execute($query_values); |
| 1203 | - } catch(PDOException $e) { |
|
| 1203 | + } catch (PDOException $e) { |
|
| 1204 | 1204 | if ($globalDebug) echo $e->getMessage(); |
| 1205 | 1205 | return "error : ".$e->getMessage(); |
| 1206 | 1206 | } |
@@ -1210,7 +1210,7 @@ discard block |
||
| 1210 | 1210 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
| 1211 | 1211 | else $ModeS = ''; |
| 1212 | 1212 | if ($ModeS == '') { |
| 1213 | - $id = explode('-',$result['flightaware_id']); |
|
| 1213 | + $id = explode('-', $result['flightaware_id']); |
|
| 1214 | 1214 | $ModeS = $id[0]; |
| 1215 | 1215 | } |
| 1216 | 1216 | if ($ModeS != '') { |
@@ -1220,20 +1220,20 @@ discard block |
||
| 1220 | 1220 | try { |
| 1221 | 1221 | $sthc = $this->db->prepare($queryc); |
| 1222 | 1222 | $sthc->execute($queryc_values); |
| 1223 | - } catch(PDOException $e) { |
|
| 1223 | + } catch (PDOException $e) { |
|
| 1224 | 1224 | if ($globalDebug) echo $e->getMessage(); |
| 1225 | 1225 | return "error : ".$e->getMessage(); |
| 1226 | 1226 | } |
| 1227 | 1227 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1228 | 1228 | $sthc->closeCursor(); |
| 1229 | - if (count($row) == 0) { |
|
| 1229 | + if (count($row) == 0) { |
|
| 1230 | 1230 | if ($globalDebug) echo " Add to ModeS table - "; |
| 1231 | 1231 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1232 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1232 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1233 | 1233 | try { |
| 1234 | 1234 | $sthi = $this->db->prepare($queryi); |
| 1235 | 1235 | $sthi->execute($queryi_values); |
| 1236 | - } catch(PDOException $e) { |
|
| 1236 | + } catch (PDOException $e) { |
|
| 1237 | 1237 | if ($globalDebug) echo $e->getMessage(); |
| 1238 | 1238 | return "error : ".$e->getMessage(); |
| 1239 | 1239 | } |
@@ -1241,15 +1241,15 @@ discard block |
||
| 1241 | 1241 | if ($globalDebug) echo " Update ModeS table - "; |
| 1242 | 1242 | if ($ICAOTypeCode != '') { |
| 1243 | 1243 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1244 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1244 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1245 | 1245 | } else { |
| 1246 | 1246 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1247 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
| 1247 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
| 1248 | 1248 | } |
| 1249 | 1249 | try { |
| 1250 | 1250 | $sthi = $this->db->prepare($queryi); |
| 1251 | 1251 | $sthi->execute($queryi_values); |
| 1252 | - } catch(PDOException $e) { |
|
| 1252 | + } catch (PDOException $e) { |
|
| 1253 | 1253 | if ($globalDebug) echo $e->getMessage(); |
| 1254 | 1254 | return "error : ".$e->getMessage(); |
| 1255 | 1255 | } |
@@ -1286,12 +1286,12 @@ discard block |
||
| 1286 | 1286 | elseif ($globalDBdriver == 'pgsql') { |
| 1287 | 1287 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1288 | 1288 | } |
| 1289 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
| 1289 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | try { |
| 1292 | 1292 | $sthi = $this->db->prepare($queryi); |
| 1293 | 1293 | $sthi->execute($queryi_values); |
| 1294 | - } catch(PDOException $e) { |
|
| 1294 | + } catch (PDOException $e) { |
|
| 1295 | 1295 | if ($globalDebug) echo $e->getMessage(); |
| 1296 | 1296 | return "error : ".$e->getMessage(); |
| 1297 | 1297 | } |
@@ -24,7 +24,9 @@ discard block |
||
| 24 | 24 | public function __construct($dbc = null,$fromACARSscript = false) { |
| 25 | 25 | $Connection = new Connection($dbc); |
| 26 | 26 | $this->db = $Connection->db(); |
| 27 | - if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
|
| 27 | + if ($this->db === null) { |
|
| 28 | + die('Error: No DB connection. (ACARS)'); |
|
| 29 | + } |
|
| 28 | 30 | if ($fromACARSscript) { |
| 29 | 31 | $this->fromACARSscript = true; |
| 30 | 32 | $this->SI = new SpotterImport($this->db); |
@@ -39,14 +41,19 @@ discard block |
||
| 39 | 41 | */ |
| 40 | 42 | public function ident2icao($ident) { |
| 41 | 43 | if (substr($ident,0,2) == 'AF') { |
| 42 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 43 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 44 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 45 | + $icao = $ident; |
|
| 46 | + } else { |
|
| 47 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 48 | + } |
|
| 44 | 49 | } else { |
| 45 | 50 | $Spotter = new Spotter($this->db); |
| 46 | 51 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
| 47 | 52 | if (isset($identicao[0])) { |
| 48 | 53 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 49 | - } else $icao = $ident; |
|
| 54 | + } else { |
|
| 55 | + $icao = $ident; |
|
| 56 | + } |
|
| 50 | 57 | } |
| 51 | 58 | return $icao; |
| 52 | 59 | } |
@@ -120,14 +127,24 @@ discard block |
||
| 120 | 127 | $message = ''; |
| 121 | 128 | $result = array(); |
| 122 | 129 | $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
| 123 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 124 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 125 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 130 | + if ($n == 0) { |
|
| 131 | + $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 132 | + } |
|
| 133 | + if ($n == 0) { |
|
| 134 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 135 | + } |
|
| 136 | + if ($n == 0) { |
|
| 137 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 138 | + } |
|
| 126 | 139 | if ($n != 0) { |
| 127 | 140 | $registration = str_replace('.','',$registration); |
| 128 | 141 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
| 129 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 130 | - } else $message = $data; |
|
| 142 | + if ($globalDebug) { |
|
| 143 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 144 | + } |
|
| 145 | + } else { |
|
| 146 | + $message = $data; |
|
| 147 | + } |
|
| 131 | 148 | $decode = array(); |
| 132 | 149 | $found = false; |
| 133 | 150 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -147,12 +164,21 @@ discard block |
||
| 147 | 164 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 148 | 165 | $latitude = $la / 10000.0; |
| 149 | 166 | $longitude = $ln / 10000.0; |
| 150 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 151 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 167 | + if ($lac == 'S') { |
|
| 168 | + $latitude = '-'.$latitude; |
|
| 169 | + } |
|
| 170 | + if ($lnc == 'W') { |
|
| 171 | + $longitude = '-'.$longitude; |
|
| 172 | + } |
|
| 152 | 173 | // Temp not always available |
| 153 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 154 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 155 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 174 | + if ($globalDebug) { |
|
| 175 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 176 | + } |
|
| 177 | + if ($temp == '') { |
|
| 178 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 179 | + } else { |
|
| 180 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 181 | + } |
|
| 156 | 182 | |
| 157 | 183 | //$icao = $Translation->checkTranslation($ident); |
| 158 | 184 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -166,25 +192,35 @@ discard block |
||
| 166 | 192 | $ahour = ''; |
| 167 | 193 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
| 168 | 194 | if ($n == 4 && strlen($darr) == 4) { |
| 169 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 170 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 171 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 195 | + if ($dhour != '') { |
|
| 196 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 197 | + } |
|
| 198 | + if ($ahour != '') { |
|
| 199 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 200 | + } |
|
| 201 | + if ($globalDebug) { |
|
| 202 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 203 | + } |
|
| 172 | 204 | //$icao = ACARS->ident2icao($ident); |
| 173 | 205 | //$icao = $Translation->checkTranslation($ident); |
| 174 | 206 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 175 | 207 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 176 | 208 | $found = true; |
| 177 | - } |
|
| 178 | - elseif ($n == 2 || $n == 4) { |
|
| 179 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 180 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 209 | + } elseif ($n == 2 || $n == 4) { |
|
| 210 | + if ($dhour != '') { |
|
| 211 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 212 | + } |
|
| 213 | + if ($globalDebug) { |
|
| 214 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 215 | + } |
|
| 181 | 216 | //$icao = ACARS->ident2icao($ident); |
| 182 | 217 | //$icao = $Translation->checkTranslation($ident); |
| 183 | 218 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
| 184 | 219 | $found = true; |
| 185 | - } |
|
| 186 | - elseif ($n == 1) { |
|
| 187 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
| 220 | + } elseif ($n == 1) { |
|
| 221 | + if ($globalDebug) { |
|
| 222 | + echo 'airport arrival : '.$darr."\n"; |
|
| 223 | + } |
|
| 188 | 224 | //$icao = ACARS->ident2icao($ident); |
| 189 | 225 | //$icao = $Translation->checkTranslation($ident); |
| 190 | 226 | $decode = array('Arrival airport' => $darr); |
@@ -202,7 +238,9 @@ discard block |
||
| 202 | 238 | $darr = ''; |
| 203 | 239 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
| 204 | 240 | if ($n == 4) { |
| 205 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 241 | + if ($globalDebug) { |
|
| 242 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 243 | + } |
|
| 206 | 244 | //$icao = ACARS->ident2icao($ident); |
| 207 | 245 | //$icao = $Translation->checkTranslation($ident); |
| 208 | 246 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -236,14 +274,23 @@ discard block |
||
| 236 | 274 | $apiste = ''; |
| 237 | 275 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
| 238 | 276 | if ($n > 8) { |
| 239 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 240 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 241 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 277 | + if ($globalDebug) { |
|
| 278 | + echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 279 | + } |
|
| 280 | + if ($dhour != '') { |
|
| 281 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 282 | + } |
|
| 283 | + if ($ahour != '') { |
|
| 284 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 285 | + } |
|
| 242 | 286 | $icao = trim($aident); |
| 243 | 287 | |
| 244 | 288 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
| 245 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 246 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 289 | + if ($ahour == '') { |
|
| 290 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 291 | + } else { |
|
| 292 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 293 | + } |
|
| 247 | 294 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 248 | 295 | $decode['icao'] = $icao; |
| 249 | 296 | $found = true; |
@@ -265,9 +312,15 @@ discard block |
||
| 265 | 312 | $lns = $lns.'.'.$lns; |
| 266 | 313 | $latitude = $las / 1000.0; |
| 267 | 314 | $longitude = $lns / 1000.0; |
| 268 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 269 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 270 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 315 | + if ($lac == 'S') { |
|
| 316 | + $latitude = '-'.$latitude; |
|
| 317 | + } |
|
| 318 | + if ($lnc == 'W') { |
|
| 319 | + $longitude = '-'.$longitude; |
|
| 320 | + } |
|
| 321 | + if ($globalDebug) { |
|
| 322 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 323 | + } |
|
| 271 | 324 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
| 272 | 325 | $found = true; |
| 273 | 326 | } |
@@ -285,7 +338,9 @@ discard block |
||
| 285 | 338 | $darr = ''; |
| 286 | 339 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
| 287 | 340 | if ($n == 4) { |
| 288 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 341 | + if ($globalDebug) { |
|
| 342 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 343 | + } |
|
| 289 | 344 | //$icao = $Translation->checkTranslation($ident); |
| 290 | 345 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 291 | 346 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -298,7 +353,9 @@ discard block |
||
| 298 | 353 | $darr = ''; |
| 299 | 354 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
| 300 | 355 | if ($n == 4) { |
| 301 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 356 | + if ($globalDebug) { |
|
| 357 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 358 | + } |
|
| 302 | 359 | //$icao = $Translation->checkTranslation($ident); |
| 303 | 360 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 304 | 361 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -311,7 +368,9 @@ discard block |
||
| 311 | 368 | $darr = ''; |
| 312 | 369 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
| 313 | 370 | if ($n == 2) { |
| 314 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 371 | + if ($globalDebug) { |
|
| 372 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 373 | + } |
|
| 315 | 374 | //$icao = $Translation->checkTranslation($ident); |
| 316 | 375 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
| 317 | 376 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -325,7 +384,9 @@ discard block |
||
| 325 | 384 | $darr = ''; |
| 326 | 385 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 327 | 386 | if ($n == 6) { |
| 328 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 387 | + if ($globalDebug) { |
|
| 388 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 389 | + } |
|
| 329 | 390 | //$icao = $Translation->checkTranslation($ident); |
| 330 | 391 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 331 | 392 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -338,7 +399,9 @@ discard block |
||
| 338 | 399 | $darr = ''; |
| 339 | 400 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 340 | 401 | if ($n == 7) { |
| 341 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 402 | + if ($globalDebug) { |
|
| 403 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 404 | + } |
|
| 342 | 405 | //$icao = $Translation->checkTranslation($ident); |
| 343 | 406 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 344 | 407 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -366,8 +429,12 @@ discard block |
||
| 366 | 429 | $decode['icao'] = $icao; |
| 367 | 430 | $latitude = $las / 100.0; |
| 368 | 431 | $longitude = $lns / 100.0; |
| 369 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 370 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 432 | + if ($lac == 'S') { |
|
| 433 | + $latitude = '-'.$latitude; |
|
| 434 | + } |
|
| 435 | + if ($lnc == 'W') { |
|
| 436 | + $longitude = '-'.$longitude; |
|
| 437 | + } |
|
| 371 | 438 | |
| 372 | 439 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
| 373 | 440 | $found = true; |
@@ -385,8 +452,12 @@ discard block |
||
| 385 | 452 | if ($n == 4) { |
| 386 | 453 | $latitude = $las; |
| 387 | 454 | $longitude = $lns; |
| 388 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 389 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 455 | + if ($lac == 'S') { |
|
| 456 | + $latitude = '-'.$latitude; |
|
| 457 | + } |
|
| 458 | + if ($lnc == 'W') { |
|
| 459 | + $longitude = '-'.$longitude; |
|
| 460 | + } |
|
| 390 | 461 | |
| 391 | 462 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
| 392 | 463 | $found = true; |
@@ -402,7 +473,9 @@ discard block |
||
| 402 | 473 | $darr = ''; |
| 403 | 474 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
| 404 | 475 | if ($n == 5) { |
| 405 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 476 | + if ($globalDebug) { |
|
| 477 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 478 | + } |
|
| 406 | 479 | //$icao = $Translation->checkTranslation($ident); |
| 407 | 480 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 408 | 481 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -423,7 +496,9 @@ discard block |
||
| 423 | 496 | $aident = ''; |
| 424 | 497 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
| 425 | 498 | if ($n == 8) { |
| 426 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 499 | + if ($globalDebug) { |
|
| 500 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 501 | + } |
|
| 427 | 502 | $icao = trim($aident); |
| 428 | 503 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 429 | 504 | $decode['icao'] = $icao; |
@@ -440,7 +515,9 @@ discard block |
||
| 440 | 515 | $darr = ''; |
| 441 | 516 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
| 442 | 517 | if ($n == 5) { |
| 443 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 518 | + if ($globalDebug) { |
|
| 519 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 520 | + } |
|
| 444 | 521 | //$icao = $Translation->checkTranslation($ident); |
| 445 | 522 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 446 | 523 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -455,7 +532,9 @@ discard block |
||
| 455 | 532 | $darr = ''; |
| 456 | 533 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
| 457 | 534 | if ($n == 3) { |
| 458 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 535 | + if ($globalDebug) { |
|
| 536 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 537 | + } |
|
| 459 | 538 | //$icao = $Translation->checkTranslation($ident); |
| 460 | 539 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 461 | 540 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -470,7 +549,9 @@ discard block |
||
| 470 | 549 | $darr = ''; |
| 471 | 550 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
| 472 | 551 | if ($n == 3) { |
| 473 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 552 | + if ($globalDebug) { |
|
| 553 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 554 | + } |
|
| 474 | 555 | //$icao = $Translation->checkTranslation($ident); |
| 475 | 556 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 476 | 557 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -480,7 +561,9 @@ discard block |
||
| 480 | 561 | if (!$found) { |
| 481 | 562 | $n = sscanf($message,'MET01%4c',$airport); |
| 482 | 563 | if ($n == 1) { |
| 483 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
| 564 | + if ($globalDebug) { |
|
| 565 | + echo 'airport name : '.$airport; |
|
| 566 | + } |
|
| 484 | 567 | $decode = array('Airport/Waypoint name' => $airport); |
| 485 | 568 | $found = true; |
| 486 | 569 | } |
@@ -488,184 +571,126 @@ discard block |
||
| 488 | 571 | if ($label == 'H1') { |
| 489 | 572 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
| 490 | 573 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
| 491 | - } |
|
| 492 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 574 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 493 | 575 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
| 494 | - } |
|
| 495 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 576 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 496 | 577 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
| 497 | - } |
|
| 498 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 578 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 499 | 579 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
| 500 | - } |
|
| 501 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 580 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 502 | 581 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
| 503 | - } |
|
| 504 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 582 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 505 | 583 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
| 506 | - } |
|
| 507 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 584 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 508 | 585 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
| 509 | - } |
|
| 510 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 586 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 511 | 587 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
| 512 | - } |
|
| 513 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 588 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 514 | 589 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
| 515 | - } |
|
| 516 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 590 | + } elseif (preg_match(':^#CF:',$message)) { |
|
| 517 | 591 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
| 518 | - } |
|
| 519 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 592 | + } elseif (preg_match(':^#DF:',$message)) { |
|
| 520 | 593 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
| 521 | - } |
|
| 522 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 594 | + } elseif (preg_match(':^#EC:',$message)) { |
|
| 523 | 595 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
| 524 | - } |
|
| 525 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 596 | + } elseif (preg_match(':^#EI:',$message)) { |
|
| 526 | 597 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
| 527 | - } |
|
| 528 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 598 | + } elseif (preg_match(':^#H1:',$message)) { |
|
| 529 | 599 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
| 530 | - } |
|
| 531 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 600 | + } elseif (preg_match(':^#H2:',$message)) { |
|
| 532 | 601 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
| 533 | - } |
|
| 534 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 602 | + } elseif (preg_match(':^#HD:',$message)) { |
|
| 535 | 603 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
| 536 | - } |
|
| 537 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 604 | + } elseif (preg_match(':^#M1:',$message)) { |
|
| 538 | 605 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
| 539 | - } |
|
| 540 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 606 | + } elseif (preg_match(':^#M2:',$message)) { |
|
| 541 | 607 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
| 542 | - } |
|
| 543 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 608 | + } elseif (preg_match(':^#M3:',$message)) { |
|
| 544 | 609 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
| 545 | - } |
|
| 546 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 610 | + } elseif (preg_match(':^#MD:',$message)) { |
|
| 547 | 611 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
| 548 | - } |
|
| 549 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 612 | + } elseif (preg_match(':^#PS:',$message)) { |
|
| 550 | 613 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
| 551 | - } |
|
| 552 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 614 | + } elseif (preg_match(':^#S1:',$message)) { |
|
| 553 | 615 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
| 554 | - } |
|
| 555 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 616 | + } elseif (preg_match(':^#S2:',$message)) { |
|
| 556 | 617 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
| 557 | - } |
|
| 558 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 618 | + } elseif (preg_match(':^#SD:',$message)) { |
|
| 559 | 619 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
| 560 | - } |
|
| 561 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 620 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 562 | 621 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
| 563 | - } |
|
| 564 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 622 | + } elseif (preg_match(':^#WO:',$message)) { |
|
| 565 | 623 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
| 566 | - } |
|
| 567 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 624 | + } elseif (preg_match(':^#A1:',$message)) { |
|
| 568 | 625 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
| 569 | - } |
|
| 570 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 626 | + } elseif (preg_match(':^#A3:',$message)) { |
|
| 571 | 627 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
| 572 | - } |
|
| 573 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 628 | + } elseif (preg_match(':^#A4:',$message)) { |
|
| 574 | 629 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
| 575 | - } |
|
| 576 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 630 | + } elseif (preg_match(':^#A6:',$message)) { |
|
| 577 | 631 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
| 578 | - } |
|
| 579 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 632 | + } elseif (preg_match(':^#A8:',$message)) { |
|
| 580 | 633 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
| 581 | - } |
|
| 582 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 634 | + } elseif (preg_match(':^#A9:',$message)) { |
|
| 583 | 635 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
| 584 | - } |
|
| 585 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 636 | + } elseif (preg_match(':^#A0:',$message)) { |
|
| 586 | 637 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
| 587 | - } |
|
| 588 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 638 | + } elseif (preg_match(':^#AA:',$message)) { |
|
| 589 | 639 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 590 | - } |
|
| 591 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 640 | + } elseif (preg_match(':^#AB:',$message)) { |
|
| 592 | 641 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
| 593 | - } |
|
| 594 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 642 | + } elseif (preg_match(':^#AC:',$message)) { |
|
| 595 | 643 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
| 596 | - } |
|
| 597 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 644 | + } elseif (preg_match(':^#AD:',$message)) { |
|
| 598 | 645 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
| 599 | - } |
|
| 600 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 646 | + } elseif (preg_match(':^#AF:',$message)) { |
|
| 601 | 647 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
| 602 | - } |
|
| 603 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 648 | + } elseif (preg_match(':^#B1:',$message)) { |
|
| 604 | 649 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
| 605 | - } |
|
| 606 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 650 | + } elseif (preg_match(':^#B2:',$message)) { |
|
| 607 | 651 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
| 608 | - } |
|
| 609 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 652 | + } elseif (preg_match(':^#B3:',$message)) { |
|
| 610 | 653 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
| 611 | - } |
|
| 612 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 654 | + } elseif (preg_match(':^#B4:',$message)) { |
|
| 613 | 655 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
| 614 | - } |
|
| 615 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 656 | + } elseif (preg_match(':^#B6:',$message)) { |
|
| 616 | 657 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
| 617 | - } |
|
| 618 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 658 | + } elseif (preg_match(':^#B8:',$message)) { |
|
| 619 | 659 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
| 620 | - } |
|
| 621 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 660 | + } elseif (preg_match(':^#B9:',$message)) { |
|
| 622 | 661 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
| 623 | - } |
|
| 624 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 662 | + } elseif (preg_match(':^#B0:',$message)) { |
|
| 625 | 663 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
| 626 | - } |
|
| 627 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 664 | + } elseif (preg_match(':^#BA:',$message)) { |
|
| 628 | 665 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 629 | - } |
|
| 630 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 666 | + } elseif (preg_match(':^#BB:',$message)) { |
|
| 631 | 667 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
| 632 | - } |
|
| 633 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 668 | + } elseif (preg_match(':^#BC:',$message)) { |
|
| 634 | 669 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
| 635 | - } |
|
| 636 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 670 | + } elseif (preg_match(':^#BD:',$message)) { |
|
| 637 | 671 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
| 638 | - } |
|
| 639 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 672 | + } elseif (preg_match(':^#BE:',$message)) { |
|
| 640 | 673 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
| 641 | - } |
|
| 642 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 674 | + } elseif (preg_match(':^#BF:',$message)) { |
|
| 643 | 675 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
| 644 | - } |
|
| 645 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 676 | + } elseif (preg_match(':^#H3:',$message)) { |
|
| 646 | 677 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
| 647 | 678 | } |
| 648 | 679 | } |
| 649 | 680 | if ($label == '10') { |
| 650 | 681 | if (preg_match(':^DTO01:',$message)) { |
| 651 | 682 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
| 652 | - } |
|
| 653 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 683 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
| 654 | 684 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
| 655 | - } |
|
| 656 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 685 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
| 657 | 686 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
| 658 | - } |
|
| 659 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 687 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
| 660 | 688 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
| 661 | - } |
|
| 662 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 689 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
| 663 | 690 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
| 664 | - } |
|
| 665 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 691 | + } elseif (preg_match(':^MET01:',$message)) { |
|
| 666 | 692 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
| 667 | - } |
|
| 668 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 693 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
| 669 | 694 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
| 670 | 695 | } |
| 671 | 696 | } |
@@ -680,38 +705,28 @@ discard block |
||
| 680 | 705 | $vsta = array('Version' => $version); |
| 681 | 706 | if ($state == 'E') { |
| 682 | 707 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
| 683 | - } |
|
| 684 | - elseif ($state == 'L') { |
|
| 708 | + } elseif ($state == 'L') { |
|
| 685 | 709 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
| 686 | - } |
|
| 687 | - else { |
|
| 710 | + } else { |
|
| 688 | 711 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
| 689 | 712 | } |
| 690 | 713 | if ($type == 'V') { |
| 691 | 714 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
| 692 | - } |
|
| 693 | - elseif ($type == 'S') { |
|
| 715 | + } elseif ($type == 'S') { |
|
| 694 | 716 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
| 695 | - } |
|
| 696 | - elseif ($type == 'H') { |
|
| 717 | + } elseif ($type == 'H') { |
|
| 697 | 718 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
| 698 | - } |
|
| 699 | - elseif ($type == 'G') { |
|
| 719 | + } elseif ($type == 'G') { |
|
| 700 | 720 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
| 701 | - } |
|
| 702 | - elseif ($type == 'C') { |
|
| 721 | + } elseif ($type == 'C') { |
|
| 703 | 722 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
| 704 | - } |
|
| 705 | - elseif ($type == '2') { |
|
| 723 | + } elseif ($type == '2') { |
|
| 706 | 724 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
| 707 | - } |
|
| 708 | - elseif ($type == 'X') { |
|
| 725 | + } elseif ($type == 'X') { |
|
| 709 | 726 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
| 710 | - } |
|
| 711 | - elseif ($type == 'I') { |
|
| 727 | + } elseif ($type == 'I') { |
|
| 712 | 728 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
| 713 | - } |
|
| 714 | - else { |
|
| 729 | + } else { |
|
| 715 | 730 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
| 716 | 731 | } |
| 717 | 732 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -720,7 +735,9 @@ discard block |
||
| 720 | 735 | } |
| 721 | 736 | |
| 722 | 737 | $title = $this->getTitlefromLabel($label); |
| 723 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 738 | + if ($title != '') { |
|
| 739 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
| 740 | + } |
|
| 724 | 741 | /* |
| 725 | 742 | // Business jets always use GS0001 |
| 726 | 743 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -755,31 +772,54 @@ discard block |
||
| 755 | 772 | $msg = $message['message']; |
| 756 | 773 | $decode = $message['decode']; |
| 757 | 774 | $registration = (string)$message['registration']; |
| 758 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
| 759 | - else $latitude = ''; |
|
| 760 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
| 761 | - else $longitude = ''; |
|
| 762 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
| 763 | - else $airicao = ''; |
|
| 764 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
| 765 | - else $icao = $Translation->checkTranslation($ident); |
|
| 775 | + if (isset($decode['latitude'])) { |
|
| 776 | + $latitude = $decode['latitude']; |
|
| 777 | + } else { |
|
| 778 | + $latitude = ''; |
|
| 779 | + } |
|
| 780 | + if (isset($decode['longitude'])) { |
|
| 781 | + $longitude = $decode['longitude']; |
|
| 782 | + } else { |
|
| 783 | + $longitude = ''; |
|
| 784 | + } |
|
| 785 | + if (isset($decode['airicao'])) { |
|
| 786 | + $airicao = $decode['airicao']; |
|
| 787 | + } else { |
|
| 788 | + $airicao = ''; |
|
| 789 | + } |
|
| 790 | + if (isset($decode['icao'])) { |
|
| 791 | + $icao = $decode['icao']; |
|
| 792 | + } else { |
|
| 793 | + $icao = $Translation->checkTranslation($ident); |
|
| 794 | + } |
|
| 766 | 795 | $image_array = $Image->getSpotterImage($registration); |
| 767 | 796 | if (!isset($image_array[0]['registration'])) { |
| 768 | 797 | $Image->addSpotterImage($registration); |
| 769 | 798 | } |
| 770 | 799 | // Business jets always use GS0001 |
| 771 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 772 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
| 773 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
| 774 | - else $decode_json = ''; |
|
| 800 | + if ($ident != 'GS0001') { |
|
| 801 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 802 | + } |
|
| 803 | + if ($globalDebug && isset($info) && $info != '') { |
|
| 804 | + echo $info; |
|
| 805 | + } |
|
| 806 | + if (count($decode) > 0) { |
|
| 807 | + $decode_json = json_encode($decode); |
|
| 808 | + } else { |
|
| 809 | + $decode_json = ''; |
|
| 810 | + } |
|
| 775 | 811 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 776 | 812 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
| 777 | 813 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 778 | 814 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
| 779 | 815 | } |
| 780 | 816 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
| 781 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 782 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 817 | + if (!isset($globalACARSArchive)) { |
|
| 818 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 819 | + } |
|
| 820 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
| 821 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 822 | + } |
|
| 783 | 823 | if ($globalDebug && count($decode) > 0) { |
| 784 | 824 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
| 785 | 825 | } |
@@ -804,7 +844,9 @@ discard block |
||
| 804 | 844 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
| 805 | 845 | $Connection = new Connection($this->db); |
| 806 | 846 | $this->db = $Connection->db; |
| 807 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
| 847 | + if ($globalDebug) { |
|
| 848 | + echo "Test if not already in Live ACARS table..."; |
|
| 849 | + } |
|
| 808 | 850 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 809 | 851 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
| 810 | 852 | try { |
@@ -815,7 +857,9 @@ discard block |
||
| 815 | 857 | return false; |
| 816 | 858 | } |
| 817 | 859 | if ($stht->fetchColumn() == 0) { |
| 818 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 860 | + if ($globalDebug) { |
|
| 861 | + echo "Add Live ACARS data..."; |
|
| 862 | + } |
|
| 819 | 863 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
| 820 | 864 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
| 821 | 865 | try { |
@@ -826,10 +870,14 @@ discard block |
||
| 826 | 870 | return false; |
| 827 | 871 | } |
| 828 | 872 | } else { |
| 829 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
| 873 | + if ($globalDebug) { |
|
| 874 | + echo "Data already in DB...\n"; |
|
| 875 | + } |
|
| 830 | 876 | return false; |
| 831 | 877 | } |
| 832 | - if ($globalDebug) echo "Done\n"; |
|
| 878 | + if ($globalDebug) { |
|
| 879 | + echo "Done\n"; |
|
| 880 | + } |
|
| 833 | 881 | return true; |
| 834 | 882 | } |
| 835 | 883 | return false; |
@@ -863,7 +911,9 @@ discard block |
||
| 863 | 911 | } |
| 864 | 912 | if ($stht->fetchColumn() == 0) { |
| 865 | 913 | */ |
| 866 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 914 | + if ($globalDebug) { |
|
| 915 | + echo "Add Live ACARS data..."; |
|
| 916 | + } |
|
| 867 | 917 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 868 | 918 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
| 869 | 919 | try { |
@@ -872,7 +922,9 @@ discard block |
||
| 872 | 922 | } catch(PDOException $e) { |
| 873 | 923 | return "error : ".$e->getMessage(); |
| 874 | 924 | } |
| 875 | - if ($globalDebug) echo "Done\n"; |
|
| 925 | + if ($globalDebug) { |
|
| 926 | + echo "Done\n"; |
|
| 927 | + } |
|
| 876 | 928 | } |
| 877 | 929 | return ''; |
| 878 | 930 | } |
@@ -896,8 +948,11 @@ discard block |
||
| 896 | 948 | return ''; |
| 897 | 949 | } |
| 898 | 950 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 899 | - if (count($row) > 0) return $row[0]['title']; |
|
| 900 | - else return ''; |
|
| 951 | + if (count($row) > 0) { |
|
| 952 | + return $row[0]['title']; |
|
| 953 | + } else { |
|
| 954 | + return ''; |
|
| 955 | + } |
|
| 901 | 956 | } |
| 902 | 957 | |
| 903 | 958 | /** |
@@ -916,8 +971,11 @@ discard block |
||
| 916 | 971 | return array(); |
| 917 | 972 | } |
| 918 | 973 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 919 | - if (count($row) > 0) return $row; |
|
| 920 | - else return array(); |
|
| 974 | + if (count($row) > 0) { |
|
| 975 | + return $row; |
|
| 976 | + } else { |
|
| 977 | + return array(); |
|
| 978 | + } |
|
| 921 | 979 | } |
| 922 | 980 | |
| 923 | 981 | /** |
@@ -937,8 +995,11 @@ discard block |
||
| 937 | 995 | return array(); |
| 938 | 996 | } |
| 939 | 997 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 940 | - if (count($row) > 0) return $row[0]; |
|
| 941 | - else return array(); |
|
| 998 | + if (count($row) > 0) { |
|
| 999 | + return $row[0]; |
|
| 1000 | + } else { |
|
| 1001 | + return array(); |
|
| 1002 | + } |
|
| 942 | 1003 | } |
| 943 | 1004 | |
| 944 | 1005 | /** |
@@ -986,19 +1047,35 @@ discard block |
||
| 986 | 1047 | if ($row['registration'] != '') { |
| 987 | 1048 | $row['registration'] = str_replace('.','',$row['registration']); |
| 988 | 1049 | $image_array = $Image->getSpotterImage($row['registration']); |
| 989 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 990 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 991 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 992 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 993 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1050 | + if (count($image_array) > 0) { |
|
| 1051 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1052 | + } else { |
|
| 1053 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1054 | + } |
|
| 1055 | + } else { |
|
| 1056 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1057 | + } |
|
| 1058 | + if ($row['registration'] == '') { |
|
| 1059 | + $row['registration'] = 'NA'; |
|
| 1060 | + } |
|
| 1061 | + if ($row['ident'] == '') { |
|
| 1062 | + $row['ident'] = 'NA'; |
|
| 1063 | + } |
|
| 994 | 1064 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 995 | 1065 | if (isset($identicao[0])) { |
| 996 | 1066 | if (substr($row['ident'],0,2) == 'AF') { |
| 997 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 998 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 999 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1067 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1068 | + $icao = $row['ident']; |
|
| 1069 | + } else { |
|
| 1070 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1071 | + } |
|
| 1072 | + } else { |
|
| 1073 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1074 | + } |
|
| 1000 | 1075 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1001 | - } else $icao = $row['ident']; |
|
| 1076 | + } else { |
|
| 1077 | + $icao = $row['ident']; |
|
| 1078 | + } |
|
| 1002 | 1079 | $icao = $Translation->checkTranslation($icao,false); |
| 1003 | 1080 | $decode = json_decode($row['decode'],true); |
| 1004 | 1081 | $found = false; |
@@ -1023,7 +1100,9 @@ discard block |
||
| 1023 | 1100 | $found = true; |
| 1024 | 1101 | } |
| 1025 | 1102 | } |
| 1026 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1103 | + if ($found) { |
|
| 1104 | + $row['decode'] = json_encode($decode); |
|
| 1105 | + } |
|
| 1027 | 1106 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1028 | 1107 | $result[] = $data; |
| 1029 | 1108 | $i++; |
@@ -1031,8 +1110,9 @@ discard block |
||
| 1031 | 1110 | if (isset($result)) { |
| 1032 | 1111 | $result[0]['query_number_rows'] = $i; |
| 1033 | 1112 | return $result; |
| 1113 | + } else { |
|
| 1114 | + return array(); |
|
| 1034 | 1115 | } |
| 1035 | - else return array(); |
|
| 1036 | 1116 | } |
| 1037 | 1117 | |
| 1038 | 1118 | /** |
@@ -1085,31 +1165,51 @@ discard block |
||
| 1085 | 1165 | if ($row['registration'] != '') { |
| 1086 | 1166 | $row['registration'] = str_replace('.','',$row['registration']); |
| 1087 | 1167 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1088 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1089 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1090 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1168 | + if (count($image_array) > 0) { |
|
| 1169 | + $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1170 | + } else { |
|
| 1171 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1172 | + } |
|
| 1173 | + } else { |
|
| 1174 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1175 | + } |
|
| 1091 | 1176 | $icao = ''; |
| 1092 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 1093 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1177 | + if ($row['registration'] == '') { |
|
| 1178 | + $row['registration'] = 'NA'; |
|
| 1179 | + } |
|
| 1180 | + if ($row['ident'] == '') { |
|
| 1181 | + $row['ident'] = 'NA'; |
|
| 1182 | + } |
|
| 1094 | 1183 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 1095 | 1184 | if (isset($identicao[0])) { |
| 1096 | 1185 | if (substr($row['ident'],0,2) == 'AF') { |
| 1097 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1098 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1099 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1186 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1187 | + $icao = $row['ident']; |
|
| 1188 | + } else { |
|
| 1189 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1190 | + } |
|
| 1191 | + } else { |
|
| 1192 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1193 | + } |
|
| 1100 | 1194 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1101 | - } else $icao = $row['ident']; |
|
| 1195 | + } else { |
|
| 1196 | + $icao = $row['ident']; |
|
| 1197 | + } |
|
| 1102 | 1198 | $icao = $Translation->checkTranslation($icao); |
| 1103 | 1199 | $decode = json_decode($row['decode'],true); |
| 1104 | 1200 | $found = false; |
| 1105 | 1201 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
| 1106 | 1202 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1107 | - if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1203 | + if (isset($airport_info[0]['icao'])) { |
|
| 1204 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1205 | + } |
|
| 1108 | 1206 | $found = true; |
| 1109 | 1207 | } |
| 1110 | 1208 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
| 1111 | 1209 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1112 | - if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1210 | + if (isset($airport_info[0]['icao'])) { |
|
| 1211 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1212 | + } |
|
| 1113 | 1213 | $found = true; |
| 1114 | 1214 | } |
| 1115 | 1215 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1119,7 +1219,9 @@ discard block |
||
| 1119 | 1219 | $found = true; |
| 1120 | 1220 | } |
| 1121 | 1221 | } |
| 1122 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1222 | + if ($found) { |
|
| 1223 | + $row['decode'] = json_encode($decode); |
|
| 1224 | + } |
|
| 1123 | 1225 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1124 | 1226 | $result[] = $data; |
| 1125 | 1227 | $i++; |
@@ -1127,7 +1229,9 @@ discard block |
||
| 1127 | 1229 | if (!empty($result)) { |
| 1128 | 1230 | $result[0]['query_number_rows'] = $i; |
| 1129 | 1231 | return $result; |
| 1130 | - } else return array(); |
|
| 1232 | + } else { |
|
| 1233 | + return array(); |
|
| 1234 | + } |
|
| 1131 | 1235 | } |
| 1132 | 1236 | |
| 1133 | 1237 | /** |
@@ -1146,25 +1250,37 @@ discard block |
||
| 1146 | 1250 | $ident = trim($ident); |
| 1147 | 1251 | $Translation = new Translation($this->db); |
| 1148 | 1252 | $Spotter = new Spotter($this->db); |
| 1149 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
| 1253 | + if ($globalDebug) { |
|
| 1254 | + echo "Test if we add ModeS data..."; |
|
| 1255 | + } |
|
| 1150 | 1256 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
| 1151 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
| 1152 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
| 1257 | + if ($icao == '') { |
|
| 1258 | + $icao = $Translation->checkTranslation($ident); |
|
| 1259 | + } |
|
| 1260 | + if ($globalDebug) { |
|
| 1261 | + echo '- Ident : '.$icao.' - '; |
|
| 1262 | + } |
|
| 1153 | 1263 | if ($ident == '' || $registration == '') { |
| 1154 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
| 1264 | + if ($globalDebug) { |
|
| 1265 | + echo "Ident or registration null, exit\n"; |
|
| 1266 | + } |
|
| 1155 | 1267 | return ''; |
| 1156 | 1268 | } |
| 1157 | 1269 | $registration = str_replace('.','',$registration); |
| 1158 | 1270 | $ident = $Translation->ident2icao($ident); |
| 1159 | 1271 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1160 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
| 1272 | + if ($globalDebug) { |
|
| 1273 | + echo "Check if needed to add translation ".$ident.'... '; |
|
| 1274 | + } |
|
| 1161 | 1275 | $querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1"; |
| 1162 | 1276 | $querysi_values = array(':registration' => $registration); |
| 1163 | 1277 | try { |
| 1164 | 1278 | $sthsi = $this->db->prepare($querysi); |
| 1165 | 1279 | $sthsi->execute($querysi_values); |
| 1166 | 1280 | } catch(PDOException $e) { |
| 1167 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1281 | + if ($globalDebug) { |
|
| 1282 | + echo $e->getMessage(); |
|
| 1283 | + } |
|
| 1168 | 1284 | return "error : ".$e->getMessage(); |
| 1169 | 1285 | } |
| 1170 | 1286 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1172,9 +1288,14 @@ discard block |
||
| 1172 | 1288 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
| 1173 | 1289 | $Translation = new Translation($this->db); |
| 1174 | 1290 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1175 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1176 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1177 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1291 | + if ($globalDebug) { |
|
| 1292 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1293 | + } |
|
| 1294 | + if ($ident != $trans_ident) { |
|
| 1295 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1296 | + } elseif ($trans_ident == $ident) { |
|
| 1297 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1298 | + } |
|
| 1178 | 1299 | } else { |
| 1179 | 1300 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1180 | 1301 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1183,32 +1304,46 @@ discard block |
||
| 1183 | 1304 | $sth = $this->db->prepare($query); |
| 1184 | 1305 | $sth->execute($query_values); |
| 1185 | 1306 | } catch(PDOException $e) { |
| 1186 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1307 | + if ($globalDebug) { |
|
| 1308 | + echo $e->getMessage(); |
|
| 1309 | + } |
|
| 1187 | 1310 | return "error : ".$e->getMessage(); |
| 1188 | 1311 | } |
| 1189 | 1312 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1190 | 1313 | $sth->closeCursor(); |
| 1191 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
| 1192 | - else $hex = ''; |
|
| 1314 | + if (isset($result['modes'])) { |
|
| 1315 | + $hex = $result['modes']; |
|
| 1316 | + } else { |
|
| 1317 | + $hex = ''; |
|
| 1318 | + } |
|
| 1193 | 1319 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
| 1194 | - if ($this->fromACARSscript) $this->SI->add($SI_data); |
|
| 1320 | + if ($this->fromACARSscript) { |
|
| 1321 | + $this->SI->add($SI_data); |
|
| 1322 | + } |
|
| 1195 | 1323 | } |
| 1196 | 1324 | } |
| 1197 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1325 | + if ($globalDebug) { |
|
| 1326 | + echo 'Done'."\n"; |
|
| 1327 | + } |
|
| 1198 | 1328 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
| 1199 | 1329 | $query_values = array(':ident' => $icao); |
| 1200 | 1330 | try { |
| 1201 | 1331 | $sth = $this->db->prepare($query); |
| 1202 | 1332 | $sth->execute($query_values); |
| 1203 | 1333 | } catch(PDOException $e) { |
| 1204 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1334 | + if ($globalDebug) { |
|
| 1335 | + echo $e->getMessage(); |
|
| 1336 | + } |
|
| 1205 | 1337 | return "error : ".$e->getMessage(); |
| 1206 | 1338 | } |
| 1207 | 1339 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1208 | 1340 | $sth->closeCursor(); |
| 1209 | 1341 | if (isset($result['flightaware_id'])) { |
| 1210 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
| 1211 | - else $ModeS = ''; |
|
| 1342 | + if (isset($result['ModeS'])) { |
|
| 1343 | + $ModeS = $result['ModeS']; |
|
| 1344 | + } else { |
|
| 1345 | + $ModeS = ''; |
|
| 1346 | + } |
|
| 1212 | 1347 | if ($ModeS == '') { |
| 1213 | 1348 | $id = explode('-',$result['flightaware_id']); |
| 1214 | 1349 | $ModeS = $id[0]; |
@@ -1221,24 +1356,32 @@ discard block |
||
| 1221 | 1356 | $sthc = $this->db->prepare($queryc); |
| 1222 | 1357 | $sthc->execute($queryc_values); |
| 1223 | 1358 | } catch(PDOException $e) { |
| 1224 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1359 | + if ($globalDebug) { |
|
| 1360 | + echo $e->getMessage(); |
|
| 1361 | + } |
|
| 1225 | 1362 | return "error : ".$e->getMessage(); |
| 1226 | 1363 | } |
| 1227 | 1364 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1228 | 1365 | $sthc->closeCursor(); |
| 1229 | 1366 | if (count($row) == 0) { |
| 1230 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
| 1367 | + if ($globalDebug) { |
|
| 1368 | + echo " Add to ModeS table - "; |
|
| 1369 | + } |
|
| 1231 | 1370 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1232 | 1371 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
| 1233 | 1372 | try { |
| 1234 | 1373 | $sthi = $this->db->prepare($queryi); |
| 1235 | 1374 | $sthi->execute($queryi_values); |
| 1236 | 1375 | } catch(PDOException $e) { |
| 1237 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1376 | + if ($globalDebug) { |
|
| 1377 | + echo $e->getMessage(); |
|
| 1378 | + } |
|
| 1238 | 1379 | return "error : ".$e->getMessage(); |
| 1239 | 1380 | } |
| 1240 | 1381 | } else { |
| 1241 | - if ($globalDebug) echo " Update ModeS table - "; |
|
| 1382 | + if ($globalDebug) { |
|
| 1383 | + echo " Update ModeS table - "; |
|
| 1384 | + } |
|
| 1242 | 1385 | if ($ICAOTypeCode != '') { |
| 1243 | 1386 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1244 | 1387 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1250,7 +1393,9 @@ discard block |
||
| 1250 | 1393 | $sthi = $this->db->prepare($queryi); |
| 1251 | 1394 | $sthi->execute($queryi_values); |
| 1252 | 1395 | } catch(PDOException $e) { |
| 1253 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1396 | + if ($globalDebug) { |
|
| 1397 | + echo $e->getMessage(); |
|
| 1398 | + } |
|
| 1254 | 1399 | return "error : ".$e->getMessage(); |
| 1255 | 1400 | } |
| 1256 | 1401 | } |
@@ -1271,7 +1416,9 @@ discard block |
||
| 1271 | 1416 | return "error : ".$e->getMessage(); |
| 1272 | 1417 | } |
| 1273 | 1418 | */ |
| 1274 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
| 1419 | + if ($globalDebug) { |
|
| 1420 | + echo " Update Spotter_output table - "; |
|
| 1421 | + } |
|
| 1275 | 1422 | if ($ICAOTypeCode != '') { |
| 1276 | 1423 | if ($globalDBdriver == 'mysql') { |
| 1277 | 1424 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1282,8 +1429,7 @@ discard block |
||
| 1282 | 1429 | } else { |
| 1283 | 1430 | if ($globalDBdriver == 'mysql') { |
| 1284 | 1431 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
| 1285 | - } |
|
| 1286 | - elseif ($globalDBdriver == 'pgsql') { |
|
| 1432 | + } elseif ($globalDBdriver == 'pgsql') { |
|
| 1287 | 1433 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1288 | 1434 | } |
| 1289 | 1435 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1292,14 +1438,20 @@ discard block |
||
| 1292 | 1438 | $sthi = $this->db->prepare($queryi); |
| 1293 | 1439 | $sthi->execute($queryi_values); |
| 1294 | 1440 | } catch(PDOException $e) { |
| 1295 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1441 | + if ($globalDebug) { |
|
| 1442 | + echo $e->getMessage(); |
|
| 1443 | + } |
|
| 1296 | 1444 | return "error : ".$e->getMessage(); |
| 1297 | 1445 | } |
| 1298 | 1446 | } |
| 1299 | 1447 | } else { |
| 1300 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
| 1448 | + if ($globalDebug) { |
|
| 1449 | + echo " Can't find ModeS in spotter_output - "; |
|
| 1450 | + } |
|
| 1451 | + } |
|
| 1452 | + if ($globalDebug) { |
|
| 1453 | + echo "Done\n"; |
|
| 1301 | 1454 | } |
| 1302 | - if ($globalDebug) echo "Done\n"; |
|
| 1303 | 1455 | return ''; |
| 1304 | 1456 | } |
| 1305 | 1457 | } |