@@ -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; |
@@ -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); |
@@ -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) { |
@@ -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) { |
@@ -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); |
@@ -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 | } |
@@ -13,7 +13,9 @@ discard block |
||
| 13 | 13 | public function __construct($dbc = null) { |
| 14 | 14 | $Connection = new Connection($dbc); |
| 15 | 15 | $this->db = $Connection->db; |
| 16 | - if ($this->db === null) die('Error: No DB connection. (TrackerArchive)'); |
|
| 16 | + if ($this->db === null) { |
|
| 17 | + die('Error: No DB connection. (TrackerArchive)'); |
|
| 18 | + } |
|
| 17 | 19 | } |
| 18 | 20 | |
| 19 | 21 | /** |
@@ -36,7 +38,9 @@ discard block |
||
| 36 | 38 | if (isset($filter[0]['source'])) { |
| 37 | 39 | $filters = array_merge($filters,$filter); |
| 38 | 40 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 41 | + if (is_array($globalFilter)) { |
|
| 42 | + $filter = array_merge($filter,$globalFilter); |
|
| 43 | + } |
|
| 40 | 44 | $filter_query_join = ''; |
| 41 | 45 | $filter_query_where = ''; |
| 42 | 46 | foreach($filters as $flt) { |
@@ -82,8 +86,11 @@ discard block |
||
| 82 | 86 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | 87 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 84 | 88 | } |
| 85 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 86 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 89 | + if ($filter_query_where == '' && $where) { |
|
| 90 | + $filter_query_where = ' WHERE'; |
|
| 91 | + } elseif ($filter_query_where != '' && $and) { |
|
| 92 | + $filter_query_where .= ' AND'; |
|
| 93 | + } |
|
| 87 | 94 | if ($filter_query_where != '') { |
| 88 | 95 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 89 | 96 | } |
@@ -116,9 +123,14 @@ discard block |
||
| 116 | 123 | if ($over_country == '') { |
| 117 | 124 | $Tracker = new Tracker($this->db); |
| 118 | 125 | $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 119 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 120 | - else $country = ''; |
|
| 121 | - } else $country = $over_country; |
|
| 126 | + if (!empty($data_country)) { |
|
| 127 | + $country = $data_country['iso2']; |
|
| 128 | + } else { |
|
| 129 | + $country = ''; |
|
| 130 | + } |
|
| 131 | + } else { |
|
| 132 | + $country = $over_country; |
|
| 133 | + } |
|
| 122 | 134 | // Route is not added in tracker_archive |
| 123 | 135 | $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 124 | 136 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -193,8 +205,11 @@ discard block |
||
| 193 | 205 | { |
| 194 | 206 | date_default_timezone_set('UTC'); |
| 195 | 207 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 196 | - if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 197 | - else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 208 | + if ($date == '') { |
|
| 209 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 210 | + } else { |
|
| 211 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 212 | + } |
|
| 198 | 213 | |
| 199 | 214 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 200 | 215 | |
@@ -649,7 +664,9 @@ discard block |
||
| 649 | 664 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 650 | 665 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
| 651 | 666 | $translate = $Translation->ident2icao($q_item); |
| 652 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 667 | + if ($translate != $q_item) { |
|
| 668 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 669 | + } |
|
| 653 | 670 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
| 654 | 671 | $additional_query .= ")"; |
| 655 | 672 | } |
@@ -867,7 +884,9 @@ discard block |
||
| 867 | 884 | date_default_timezone_set($globalTimezone); |
| 868 | 885 | $datetime = new DateTime(); |
| 869 | 886 | $offset = $datetime->format('P'); |
| 870 | - } else $offset = '+00:00'; |
|
| 887 | + } else { |
|
| 888 | + $offset = '+00:00'; |
|
| 889 | + } |
|
| 871 | 890 | |
| 872 | 891 | |
| 873 | 892 | if ($date_array[1] != "") |
@@ -1154,9 +1173,13 @@ discard block |
||
| 1154 | 1173 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1155 | 1174 | } |
| 1156 | 1175 | } |
| 1157 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1176 | + if ($sincedate != '') { |
|
| 1177 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1178 | + } |
|
| 1158 | 1179 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1159 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1180 | + if ($limit) { |
|
| 1181 | + $query .= " LIMIT 0,10"; |
|
| 1182 | + } |
|
| 1160 | 1183 | |
| 1161 | 1184 | |
| 1162 | 1185 | $sth = $this->db->prepare($query); |
@@ -1202,9 +1225,13 @@ discard block |
||
| 1202 | 1225 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1203 | 1226 | } |
| 1204 | 1227 | } |
| 1205 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1228 | + if ($sincedate != '') { |
|
| 1229 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1230 | + } |
|
| 1206 | 1231 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1207 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1232 | + if ($limit) { |
|
| 1233 | + $query .= " LIMIT 0,10"; |
|
| 1234 | + } |
|
| 1208 | 1235 | |
| 1209 | 1236 | |
| 1210 | 1237 | $sth = $this->db->prepare($query); |
@@ -46,7 +46,9 @@ discard block |
||
| 46 | 46 | $gpx .= '<trkseg>'; |
| 47 | 47 | foreach($spotter_history_array as $spotter_data) { |
| 48 | 48 | $gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">'; |
| 49 | - if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>'; |
|
| 49 | + if (isset($spotter_data['altitude'])) { |
|
| 50 | + $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>'; |
|
| 51 | + } |
|
| 50 | 52 | $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>'; |
| 51 | 53 | $gpx .= '</trkpt>'; |
| 52 | 54 | } |
@@ -82,9 +84,15 @@ discard block |
||
| 82 | 84 | |
| 83 | 85 | public function TrackMatching($spotter_history_array) { |
| 84 | 86 | global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId; |
| 85 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 86 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 87 | - if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
| 87 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 88 | + $globalMapMatchingMaxPts = 100; |
|
| 89 | + } |
|
| 90 | + if (count($spotter_history_array) < 2) { |
|
| 91 | + return $spotter_history_array; |
|
| 92 | + } |
|
| 93 | + if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
| 94 | + $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
| 95 | + } |
|
| 88 | 96 | $data = $this->create_gpx($spotter_history_array); |
| 89 | 97 | $url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true'; |
| 90 | 98 | $Common = new Common(); |
@@ -111,8 +119,12 @@ discard block |
||
| 111 | 119 | */ |
| 112 | 120 | public function GraphHopper($spotter_history_array) { |
| 113 | 121 | global $globalMapMatchingMaxPts, $globalGraphHopperKey; |
| 114 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 115 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 122 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 123 | + $globalMapMatchingMaxPts = 100; |
|
| 124 | + } |
|
| 125 | + if (count($spotter_history_array) < 2) { |
|
| 126 | + return $spotter_history_array; |
|
| 127 | + } |
|
| 116 | 128 | $spotter_history_initial_array = array(); |
| 117 | 129 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 118 | 130 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -142,8 +154,12 @@ discard block |
||
| 142 | 154 | */ |
| 143 | 155 | public function FAMMapMatching($spotter_history_array) { |
| 144 | 156 | global $globalMapMatchingMaxPts; |
| 145 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 146 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 157 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 158 | + $globalMapMatchingMaxPts = 100; |
|
| 159 | + } |
|
| 160 | + if (count($spotter_history_array) < 2) { |
|
| 161 | + return $spotter_history_array; |
|
| 162 | + } |
|
| 147 | 163 | $spotter_history_initial_array = array(); |
| 148 | 164 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 149 | 165 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -174,8 +190,12 @@ discard block |
||
| 174 | 190 | */ |
| 175 | 191 | public function osmr($spotter_history_array) { |
| 176 | 192 | global $globalMapMatchingMaxPts; |
| 177 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50; |
|
| 178 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 193 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 194 | + $globalMapMatchingMaxPts = 50; |
|
| 195 | + } |
|
| 196 | + if (count($spotter_history_array) < 2) { |
|
| 197 | + return $spotter_history_array; |
|
| 198 | + } |
|
| 179 | 199 | $spotter_history_initial_array = array(); |
| 180 | 200 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 181 | 201 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -185,11 +205,17 @@ discard block |
||
| 185 | 205 | $ts = ''; |
| 186 | 206 | $rd = ''; |
| 187 | 207 | foreach ($spotter_history_array as $spotter_data) { |
| 188 | - if ($coord != '') $coord .= ';'; |
|
| 208 | + if ($coord != '') { |
|
| 209 | + $coord .= ';'; |
|
| 210 | + } |
|
| 189 | 211 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
| 190 | - if ($ts != '') $ts .= ';'; |
|
| 212 | + if ($ts != '') { |
|
| 213 | + $ts .= ';'; |
|
| 214 | + } |
|
| 191 | 215 | $ts .= strtotime($spotter_data['date']); |
| 192 | - if ($rd != '') $rd .= ';'; |
|
| 216 | + if ($rd != '') { |
|
| 217 | + $rd .= ';'; |
|
| 218 | + } |
|
| 193 | 219 | $rd .= '20'; |
| 194 | 220 | } |
| 195 | 221 | $url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore'; |
@@ -215,8 +241,12 @@ discard block |
||
| 215 | 241 | */ |
| 216 | 242 | public function mapbox($spotter_history_array) { |
| 217 | 243 | global $globalMapMatchingMaxPts, $globalMapboxToken; |
| 218 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60; |
|
| 219 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 244 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 245 | + $globalMapMatchingMaxPts = 60; |
|
| 246 | + } |
|
| 247 | + if (count($spotter_history_array) < 2) { |
|
| 248 | + return $spotter_history_array; |
|
| 249 | + } |
|
| 220 | 250 | $spotter_history_initial_array = array(); |
| 221 | 251 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 222 | 252 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -226,11 +256,17 @@ discard block |
||
| 226 | 256 | $ts = ''; |
| 227 | 257 | $rd = ''; |
| 228 | 258 | foreach ($spotter_history_array as $spotter_data) { |
| 229 | - if ($coord != '') $coord .= ';'; |
|
| 259 | + if ($coord != '') { |
|
| 260 | + $coord .= ';'; |
|
| 261 | + } |
|
| 230 | 262 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
| 231 | - if ($ts != '') $ts .= ';'; |
|
| 263 | + if ($ts != '') { |
|
| 264 | + $ts .= ';'; |
|
| 265 | + } |
|
| 232 | 266 | $ts .= strtotime($spotter_data['date']); |
| 233 | - if ($rd != '') $rd .= ';'; |
|
| 267 | + if ($rd != '') { |
|
| 268 | + $rd .= ';'; |
|
| 269 | + } |
|
| 234 | 270 | $rd .= '20'; |
| 235 | 271 | } |
| 236 | 272 | //$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'×tamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd; |
@@ -24,7 +24,9 @@ discard block |
||
| 24 | 24 | public function __construct($dbc = null) { |
| 25 | 25 | $Connection = new Connection($dbc); |
| 26 | 26 | $this->db = $Connection->db(); |
| 27 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 27 | + if ($this->db === null) { |
|
| 28 | + die('Error: No DB connection.'); |
|
| 29 | + } |
|
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | /** |
@@ -141,7 +143,9 @@ discard block |
||
| 141 | 143 | $sth->closeCursor(); |
| 142 | 144 | if (is_array($row) && count($row) > 0) { |
| 143 | 145 | return $row; |
| 144 | - } else return array(); |
|
| 146 | + } else { |
|
| 147 | + return array(); |
|
| 148 | + } |
|
| 145 | 149 | } |
| 146 | 150 | |
| 147 | 151 | /* |
@@ -182,7 +186,9 @@ discard block |
||
| 182 | 186 | $Common = new Common(); |
| 183 | 187 | $check_date = new Datetime($date); |
| 184 | 188 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 185 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 189 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 190 | + return array(); |
|
| 191 | + } |
|
| 186 | 192 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
| 187 | 193 | $json = $Common->getData($url); |
| 188 | 194 | var_dump($json); |
@@ -209,7 +215,9 @@ discard block |
||
| 209 | 215 | */ |
| 210 | 216 | |
| 211 | 217 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
| 212 | - } else return array(); |
|
| 218 | + } else { |
|
| 219 | + return array(); |
|
| 220 | + } |
|
| 213 | 221 | } |
| 214 | 222 | |
| 215 | 223 | /** |
@@ -224,7 +232,9 @@ discard block |
||
| 224 | 232 | date_default_timezone_set($globalTimezone); |
| 225 | 233 | $check_date = new Datetime($date); |
| 226 | 234 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 227 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 235 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 236 | + return array(); |
|
| 237 | + } |
|
| 228 | 238 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 229 | 239 | $json = $Common->getData($url); |
| 230 | 240 | $parsed_json = json_decode($json); |
@@ -237,7 +247,9 @@ discard block |
||
| 237 | 247 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 238 | 248 | |
| 239 | 249 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
| 240 | - } else return array(); |
|
| 250 | + } else { |
|
| 251 | + return array(); |
|
| 252 | + } |
|
| 241 | 253 | } |
| 242 | 254 | |
| 243 | 255 | /** |
@@ -248,7 +260,9 @@ discard block |
||
| 248 | 260 | private function getRyanair($callsign) { |
| 249 | 261 | $Common = new Common(); |
| 250 | 262 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 251 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 263 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 264 | + return array(); |
|
| 265 | + } |
|
| 252 | 266 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 253 | 267 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 254 | 268 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -262,8 +276,12 @@ discard block |
||
| 262 | 276 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 263 | 277 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 264 | 278 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
| 265 | - } else return array(); |
|
| 266 | - } else return array(); |
|
| 279 | + } else { |
|
| 280 | + return array(); |
|
| 281 | + } |
|
| 282 | + } else { |
|
| 283 | + return array(); |
|
| 284 | + } |
|
| 267 | 285 | } |
| 268 | 286 | |
| 269 | 287 | /** |
@@ -274,7 +292,9 @@ discard block |
||
| 274 | 292 | private function getSwiss($callsign) { |
| 275 | 293 | $Common = new Common(); |
| 276 | 294 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 277 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 295 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 296 | + return array(); |
|
| 297 | + } |
|
| 278 | 298 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 279 | 299 | $json = $Common->getData($url); |
| 280 | 300 | $parsed_json = json_decode($json); |
@@ -294,8 +314,12 @@ discard block |
||
| 294 | 314 | } |
| 295 | 315 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 296 | 316 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
| 297 | - } else return array(); |
|
| 298 | - } else return array(); |
|
| 317 | + } else { |
|
| 318 | + return array(); |
|
| 319 | + } |
|
| 320 | + } else { |
|
| 321 | + return array(); |
|
| 322 | + } |
|
| 299 | 323 | } |
| 300 | 324 | |
| 301 | 325 | /** |
@@ -309,12 +333,18 @@ discard block |
||
| 309 | 333 | $Common = new Common(); |
| 310 | 334 | $check_date = new Datetime($date); |
| 311 | 335 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 312 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 313 | - if ($globalBritishAirwaysKey == '') return array(); |
|
| 336 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 337 | + return array(); |
|
| 338 | + } |
|
| 339 | + if ($globalBritishAirwaysKey == '') { |
|
| 340 | + return array(); |
|
| 341 | + } |
|
| 314 | 342 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 315 | 343 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 316 | 344 | $json = $Common->getData($url,'get','',$headers); |
| 317 | - if ($json == '') return array(); |
|
| 345 | + if ($json == '') { |
|
| 346 | + return array(); |
|
| 347 | + } |
|
| 318 | 348 | $parsed_json = json_decode($json); |
| 319 | 349 | $flights = $parsed_json->{'FlightsResponse'}; |
| 320 | 350 | if (count($flights) > 0) { |
@@ -323,7 +353,9 @@ discard block |
||
| 323 | 353 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
| 324 | 354 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
| 325 | 355 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
| 326 | - } else return array(); |
|
| 356 | + } else { |
|
| 357 | + return array(); |
|
| 358 | + } |
|
| 327 | 359 | } |
| 328 | 360 | |
| 329 | 361 | /** |
@@ -337,19 +369,27 @@ discard block |
||
| 337 | 369 | $Common = new Common(); |
| 338 | 370 | $check_date = new Datetime($date); |
| 339 | 371 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 340 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 341 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
| 372 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 373 | + return array(); |
|
| 374 | + } |
|
| 375 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
| 376 | + return array(); |
|
| 377 | + } |
|
| 342 | 378 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 343 | 379 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
| 344 | 380 | $data = $Common->getData($url,'post',$post); |
| 345 | 381 | $parsed_data = json_decode($data); |
| 346 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
| 382 | + if (!isset($parsed_data->{'access_token'})) { |
|
| 383 | + return array(); |
|
| 384 | + } |
|
| 347 | 385 | $token = $parsed_data->{'access_token'}; |
| 348 | 386 | |
| 349 | 387 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 350 | 388 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
| 351 | 389 | $json = $Common->getData($url,'get','',$headers); |
| 352 | - if ($json == '') return array(); |
|
| 390 | + if ($json == '') { |
|
| 391 | + return array(); |
|
| 392 | + } |
|
| 353 | 393 | $parsed_json = json_decode($json); |
| 354 | 394 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 355 | 395 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -357,7 +397,9 @@ discard block |
||
| 357 | 397 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 358 | 398 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
| 359 | 399 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
| 360 | - } else return array(); |
|
| 400 | + } else { |
|
| 401 | + return array(); |
|
| 402 | + } |
|
| 361 | 403 | } |
| 362 | 404 | |
| 363 | 405 | /** |
@@ -371,14 +413,20 @@ discard block |
||
| 371 | 413 | $Common = new Common(); |
| 372 | 414 | $check_date = new Datetime($date); |
| 373 | 415 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 374 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 375 | - if ($globalTransaviaKey == '') return array(); |
|
| 416 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 417 | + return array(); |
|
| 418 | + } |
|
| 419 | + if ($globalTransaviaKey == '') { |
|
| 420 | + return array(); |
|
| 421 | + } |
|
| 376 | 422 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 377 | 423 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 378 | 424 | $headers = array('apikey: '.$globalTransaviaKey); |
| 379 | 425 | $json = $Common->getData($url,'get','',$headers); |
| 380 | 426 | //echo 'result : '.$json; |
| 381 | - if ($json == '') return array(); |
|
| 427 | + if ($json == '') { |
|
| 428 | + return array(); |
|
| 429 | + } |
|
| 382 | 430 | $parsed_json = json_decode($json); |
| 383 | 431 | |
| 384 | 432 | if (isset($parsed_json->{'data'}[0])) { |
@@ -387,7 +435,9 @@ discard block |
||
| 387 | 435 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 388 | 436 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
| 389 | 437 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
| 390 | - } else return array(); |
|
| 438 | + } else { |
|
| 439 | + return array(); |
|
| 440 | + } |
|
| 391 | 441 | } |
| 392 | 442 | |
| 393 | 443 | /** |
@@ -398,7 +448,9 @@ discard block |
||
| 398 | 448 | public function getTunisair($callsign) { |
| 399 | 449 | $Common = new Common(); |
| 400 | 450 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 401 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 451 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 452 | + return array(); |
|
| 453 | + } |
|
| 402 | 454 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 403 | 455 | $data = $Common->getData($url); |
| 404 | 456 | $table = $Common->table2array($data); |
@@ -420,7 +472,9 @@ discard block |
||
| 420 | 472 | $Common = new Common(); |
| 421 | 473 | $check_date = new Datetime($date); |
| 422 | 474 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 423 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 475 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 476 | + return array(); |
|
| 477 | + } |
|
| 424 | 478 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
| 425 | 479 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 426 | 480 | $data = $Common->getData($url); |
@@ -430,8 +484,11 @@ discard block |
||
| 430 | 484 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
| 431 | 485 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
| 432 | 486 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
| 433 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 434 | - else return array(); |
|
| 487 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
| 488 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 489 | + } else { |
|
| 490 | + return array(); |
|
| 491 | + } |
|
| 435 | 492 | } |
| 436 | 493 | return array(); |
| 437 | 494 | } |
@@ -446,7 +503,9 @@ discard block |
||
| 446 | 503 | $Common = new Common(); |
| 447 | 504 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 448 | 505 | $check_date = new Datetime($date); |
| 449 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 506 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 507 | + return array(); |
|
| 508 | + } |
|
| 450 | 509 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 451 | 510 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
| 452 | 511 | $data = $Common->getData($url,'post',$post); |
@@ -463,7 +522,9 @@ discard block |
||
| 463 | 522 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
| 464 | 523 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 465 | 524 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
| 466 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 525 | + } else { |
|
| 526 | + $arrivalTime = substr($arrivalTime,0,5); |
|
| 527 | + } |
|
| 467 | 528 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
| 468 | 529 | } |
| 469 | 530 | } |
@@ -482,7 +543,9 @@ discard block |
||
| 482 | 543 | $Common = new Common(); |
| 483 | 544 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 484 | 545 | $check_date = new Datetime($date); |
| 485 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 546 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 547 | + return array(); |
|
| 548 | + } |
|
| 486 | 549 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
| 487 | 550 | $data = $Common->getData($url); |
| 488 | 551 | if ($data != '') { |
@@ -498,7 +561,9 @@ discard block |
||
| 498 | 561 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
| 499 | 562 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
| 500 | 563 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
| 501 | - } else return array(); |
|
| 564 | + } else { |
|
| 565 | + return array(); |
|
| 566 | + } |
|
| 502 | 567 | } |
| 503 | 568 | |
| 504 | 569 | |
@@ -518,7 +583,9 @@ discard block |
||
| 518 | 583 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 519 | 584 | $check_date = new Datetime($date); |
| 520 | 585 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
| 521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 586 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 587 | + return array(); |
|
| 588 | + } |
|
| 522 | 589 | $data = $Common->getData($url); |
| 523 | 590 | if ($data != '') { |
| 524 | 591 | $table = $Common->text2array($data); |
@@ -543,7 +610,9 @@ discard block |
||
| 543 | 610 | $check_date = new Datetime($date); |
| 544 | 611 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
| 545 | 612 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
| 546 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 613 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 614 | + return array(); |
|
| 615 | + } |
|
| 547 | 616 | $data = $Common->getData($url); |
| 548 | 617 | if ($data != '') { |
| 549 | 618 | //echo $data; |
@@ -634,7 +703,9 @@ discard block |
||
| 634 | 703 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 635 | 704 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
| 636 | 705 | //$check_date = new Datetime($date); |
| 637 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 706 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 707 | + return array(); |
|
| 708 | + } |
|
| 638 | 709 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
| 639 | 710 | $data = $Common->getData($url,'post',$post); |
| 640 | 711 | if ($data != '') { |
@@ -666,11 +737,15 @@ discard block |
||
| 666 | 737 | $airline_icao = substr($callsign, 0, 3); |
| 667 | 738 | } |
| 668 | 739 | } |
| 669 | - if ($airline_icao == '') return array(); |
|
| 740 | + if ($airline_icao == '') { |
|
| 741 | + return array(); |
|
| 742 | + } |
|
| 670 | 743 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 671 | 744 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
| 672 | 745 | //$check_date = new Datetime($date); |
| 673 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 746 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 747 | + return array(); |
|
| 748 | + } |
|
| 674 | 749 | $data = $Common->getData($url); |
| 675 | 750 | if ($data != '') { |
| 676 | 751 | $table = $Common->table2array($data); |
@@ -763,10 +838,16 @@ discard block |
||
| 763 | 838 | if ($data != '') { |
| 764 | 839 | $table = $Common->table2array($data); |
| 765 | 840 | if (isset($table[11][1])) { |
| 766 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
| 767 | - else $departureTime = ''; |
|
| 768 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
| 769 | - else $arrivalTime = ''; |
|
| 841 | + if (is_numeric(substr($table[11][1],0,1))) { |
|
| 842 | + $departureTime = substr($table[11][1],0,5); |
|
| 843 | + } else { |
|
| 844 | + $departureTime = ''; |
|
| 845 | + } |
|
| 846 | + if (is_numeric(substr($table[17][1],0,1))) { |
|
| 847 | + $arrivalTime = substr($table[17][1],0,5); |
|
| 848 | + } else { |
|
| 849 | + $arrivalTime = ''; |
|
| 850 | + } |
|
| 770 | 851 | $DepartureAirportIata = substr($table[13][1],0,3); |
| 771 | 852 | $ArrivalAirportIata = substr($table[15][1],0,3); |
| 772 | 853 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
@@ -783,16 +864,22 @@ discard block |
||
| 783 | 864 | */ |
| 784 | 865 | private function getAirCanada($callsign,$date = 'NOW') { |
| 785 | 866 | $Common = new Common(); |
| 786 | - if (class_exists("DomDocument") === FALSE) return array(); |
|
| 867 | + if (class_exists("DomDocument") === FALSE) { |
|
| 868 | + return array(); |
|
| 869 | + } |
|
| 787 | 870 | date_default_timezone_set('UTC'); |
| 788 | 871 | $check_date = new Datetime($date); |
| 789 | 872 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 790 | 873 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
| 791 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 874 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 875 | + return array(); |
|
| 876 | + } |
|
| 792 | 877 | $data = $Common->getData($url); |
| 793 | 878 | $dom = new DomDocument(); |
| 794 | 879 | $dom->loadXML($data); |
| 795 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
| 880 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
| 881 | + return array(); |
|
| 882 | + } |
|
| 796 | 883 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 797 | 884 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 798 | 885 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -801,7 +888,9 @@ discard block |
||
| 801 | 888 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 802 | 889 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
| 803 | 890 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
| 804 | - } else return array(); |
|
| 891 | + } else { |
|
| 892 | + return array(); |
|
| 893 | + } |
|
| 805 | 894 | } |
| 806 | 895 | |
| 807 | 896 | /** |
@@ -815,7 +904,9 @@ discard block |
||
| 815 | 904 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 816 | 905 | $check_date = new Datetime($date); |
| 817 | 906 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
| 818 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 907 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 908 | + return array(); |
|
| 909 | + } |
|
| 819 | 910 | $data = $Common->getData($url); |
| 820 | 911 | if ($data != '') { |
| 821 | 912 | $table = $Common->table2array($data); |
@@ -845,7 +936,9 @@ discard block |
||
| 845 | 936 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 846 | 937 | $check_date = new Datetime($date); |
| 847 | 938 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
| 848 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 939 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 940 | + return array(); |
|
| 941 | + } |
|
| 849 | 942 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
| 850 | 943 | $data = $Common->getData($url,'post',$post); |
| 851 | 944 | //echo $data; |
@@ -855,11 +948,19 @@ discard block |
||
| 855 | 948 | if ($data != '') { |
| 856 | 949 | $table = $Common->table2array($data); |
| 857 | 950 | $flight = $table; |
| 858 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
| 859 | - else $departureTime = ''; |
|
| 860 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
| 861 | - else $departureAirport = ''; |
|
| 862 | - } else return array(); |
|
| 951 | + if (isset($flight[5][4])) { |
|
| 952 | + $departureTime = $flight[5][4]; |
|
| 953 | + } else { |
|
| 954 | + $departureTime = ''; |
|
| 955 | + } |
|
| 956 | + if (isset($flight[5][2])) { |
|
| 957 | + $departureAirport = $flight[5][2]; |
|
| 958 | + } else { |
|
| 959 | + $departureAirport = ''; |
|
| 960 | + } |
|
| 961 | + } else { |
|
| 962 | + return array(); |
|
| 963 | + } |
|
| 863 | 964 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
| 864 | 965 | $data = $Common->getData($url,'post',$post); |
| 865 | 966 | if ($data != '') { |
@@ -872,10 +973,14 @@ discard block |
||
| 872 | 973 | $arrivalTime = ''; |
| 873 | 974 | $arrivalAirport = ''; |
| 874 | 975 | } |
| 875 | - } else return array(); |
|
| 976 | + } else { |
|
| 977 | + return array(); |
|
| 978 | + } |
|
| 876 | 979 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
| 877 | 980 | $json = $Common->getData($url); |
| 878 | - if ($json == '') return array(); |
|
| 981 | + if ($json == '') { |
|
| 982 | + return array(); |
|
| 983 | + } |
|
| 879 | 984 | $parsed_json = json_decode($json); |
| 880 | 985 | $airports = $parsed_json->{'suggestList'}; |
| 881 | 986 | if (count($airports) > 0) { |
@@ -890,7 +995,9 @@ discard block |
||
| 890 | 995 | } |
| 891 | 996 | if (isset($DepartureAirportIata)) { |
| 892 | 997 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
| 893 | - } else return array(); |
|
| 998 | + } else { |
|
| 999 | + return array(); |
|
| 1000 | + } |
|
| 894 | 1001 | } |
| 895 | 1002 | |
| 896 | 1003 | /* |
@@ -902,7 +1009,9 @@ discard block |
||
| 902 | 1009 | public function fetchSchedule($ident,$date = 'NOW') { |
| 903 | 1010 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername; |
| 904 | 1011 | //$Common = new Common(); |
| 905 | - if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
|
| 1012 | + if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
| 1013 | + return array(); |
|
| 1014 | + } |
|
| 906 | 1015 | $airline_icao = ''; |
| 907 | 1016 | if (!is_numeric(substr($ident, 0, 3))) |
| 908 | 1017 | { |
@@ -1137,18 +1246,27 @@ discard block |
||
| 1137 | 1246 | if (strlen($airline_icao) == 3) { |
| 1138 | 1247 | $Spotter = new Spotter($this->db); |
| 1139 | 1248 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
| 1140 | - if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata']; |
|
| 1249 | + if (isset($airline_info[0]['iata'])) { |
|
| 1250 | + $airline_icao = $airline_info[0]['iata']; |
|
| 1251 | + } |
|
| 1141 | 1252 | } |
| 1142 | 1253 | // Randomly use a generic function to get hours |
| 1143 | 1254 | if (strlen($airline_icao) == 2) { |
| 1144 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware'); |
|
| 1255 | + if (!isset($globalSchedulesSources)) { |
|
| 1256 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightaware'); |
|
| 1257 | + } |
|
| 1145 | 1258 | if (count($globalSchedulesSources) > 0) { |
| 1146 | 1259 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
| 1147 | 1260 | $source = $globalSchedulesSources[$rand]; |
| 1148 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
| 1149 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
| 1261 | + if ($source == 'flightmapper') { |
|
| 1262 | + return $this->getFlightMapper($ident); |
|
| 1263 | + } elseif ($source == 'costtotravel') { |
|
| 1264 | + return $this->getCostToTravel($ident); |
|
| 1265 | + } |
|
| 1150 | 1266 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
| 1151 | - elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident); |
|
| 1267 | + elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') { |
|
| 1268 | + return $this->getFlightAware($ident); |
|
| 1269 | + } |
|
| 1152 | 1270 | } |
| 1153 | 1271 | } |
| 1154 | 1272 | } |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | public function __construct($dbc = null) { |
| 18 | 18 | $Connection = new Connection($dbc); |
| 19 | 19 | $this->db = $Connection->db(); |
| 20 | - if ($this->db === null) die('Error: No DB connection. (Tracker)'); |
|
| 20 | + if ($this->db === null) { |
|
| 21 | + die('Error: No DB connection. (Tracker)'); |
|
| 22 | + } |
|
| 21 | 23 | } |
| 22 | 24 | |
| 23 | 25 | /** |
@@ -41,7 +43,9 @@ discard block |
||
| 41 | 43 | if (isset($filter[0]['source'])) { |
| 42 | 44 | $filters = array_merge($filters,$filter); |
| 43 | 45 | } |
| 44 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 46 | + if (is_array($globalFilter)) { |
|
| 47 | + $filter = array_merge($filter,$globalFilter); |
|
| 48 | + } |
|
| 45 | 49 | $filter_query_join = ''; |
| 46 | 50 | $filter_query_where = ''; |
| 47 | 51 | foreach($filters as $flt) { |
@@ -83,8 +87,11 @@ discard block |
||
| 83 | 87 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 84 | 88 | } |
| 85 | 89 | } |
| 86 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 87 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 90 | + if ($filter_query_where == '' && $where) { |
|
| 91 | + $filter_query_where = ' WHERE'; |
|
| 92 | + } elseif ($filter_query_where != '' && $and) { |
|
| 93 | + $filter_query_where .= ' AND'; |
|
| 94 | + } |
|
| 88 | 95 | if ($filter_query_where != '') { |
| 89 | 96 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 90 | 97 | } |
@@ -138,26 +145,43 @@ discard block |
||
| 138 | 145 | $temp_array['tracker_id'] = $row['tracker_archive_id']; |
| 139 | 146 | } elseif (isset($row['tracker_archive_output_id'])) { |
| 140 | 147 | $temp_array['tracker_id'] = $row['tracker_archive_output_id']; |
| 141 | - */} |
|
| 142 | - elseif (isset($row['trackerid'])) { |
|
| 148 | + */} elseif (isset($row['trackerid'])) { |
|
| 143 | 149 | $temp_array['trackerid'] = $row['trackerid']; |
| 144 | 150 | } else { |
| 145 | 151 | $temp_array['trackerid'] = ''; |
| 146 | 152 | } |
| 147 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
| 148 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 149 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
| 153 | + if (isset($row['famtrackid'])) { |
|
| 154 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
| 155 | + } |
|
| 156 | + if (isset($row['type'])) { |
|
| 157 | + $temp_array['type'] = $row['type']; |
|
| 158 | + } |
|
| 159 | + if (isset($row['comment'])) { |
|
| 160 | + $temp_array['comment'] = $row['comment']; |
|
| 161 | + } |
|
| 150 | 162 | $temp_array['ident'] = $row['ident']; |
| 151 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 152 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 153 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 154 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
| 163 | + if (isset($row['latitude'])) { |
|
| 164 | + $temp_array['latitude'] = $row['latitude']; |
|
| 165 | + } |
|
| 166 | + if (isset($row['longitude'])) { |
|
| 167 | + $temp_array['longitude'] = $row['longitude']; |
|
| 168 | + } |
|
| 169 | + if (isset($row['format_source'])) { |
|
| 170 | + $temp_array['format_source'] = $row['format_source']; |
|
| 171 | + } |
|
| 172 | + if (isset($row['altitude'])) { |
|
| 173 | + $temp_array['altitude'] = $row['altitude']; |
|
| 174 | + } |
|
| 155 | 175 | if (isset($row['heading'])) { |
| 156 | 176 | $temp_array['heading'] = $row['heading']; |
| 157 | 177 | $heading_direction = $this->parseDirection($row['heading']); |
| 158 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 178 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 179 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + if (isset($row['ground_speed'])) { |
|
| 183 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 159 | 184 | } |
| 160 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 161 | 185 | |
| 162 | 186 | if (isset($row['date'])) { |
| 163 | 187 | $dateArray = $this->parseDateString($row['date']); |
@@ -200,13 +224,21 @@ discard block |
||
| 200 | 224 | } |
| 201 | 225 | |
| 202 | 226 | $fromsource = NULL; |
| 203 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 204 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 205 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 227 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 228 | + $temp_array['source_name'] = $row['source_name']; |
|
| 229 | + } |
|
| 230 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 231 | + $temp_array['over_country'] = $row['over_country']; |
|
| 232 | + } |
|
| 233 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 234 | + $temp_array['distance'] = $row['distance']; |
|
| 235 | + } |
|
| 206 | 236 | $temp_array['query_number_rows'] = $num_rows; |
| 207 | 237 | $tracker_array[] = $temp_array; |
| 208 | 238 | } |
| 209 | - if ($num_rows == 0) return array(); |
|
| 239 | + if ($num_rows == 0) { |
|
| 240 | + return array(); |
|
| 241 | + } |
|
| 210 | 242 | $tracker_array[0]['query_number_rows'] = $num_rows; |
| 211 | 243 | return $tracker_array; |
| 212 | 244 | } |
@@ -239,8 +271,12 @@ discard block |
||
| 239 | 271 | { |
| 240 | 272 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 241 | 273 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 242 | - } else $limit_query = ""; |
|
| 243 | - } else $limit_query = ""; |
|
| 274 | + } else { |
|
| 275 | + $limit_query = ""; |
|
| 276 | + } |
|
| 277 | + } else { |
|
| 278 | + $limit_query = ""; |
|
| 279 | + } |
|
| 244 | 280 | |
| 245 | 281 | if ($sort != "") |
| 246 | 282 | { |
@@ -268,7 +304,9 @@ discard block |
||
| 268 | 304 | global $global_tracker_query; |
| 269 | 305 | |
| 270 | 306 | date_default_timezone_set('UTC'); |
| 271 | - if ($id == '') return array(); |
|
| 307 | + if ($id == '') { |
|
| 308 | + return array(); |
|
| 309 | + } |
|
| 272 | 310 | $additional_query = "tracker_output.famtrackid = :id"; |
| 273 | 311 | $query_values = array(':id' => $id); |
| 274 | 312 | $query = $global_tracker_query." WHERE ".$additional_query." "; |
@@ -413,8 +451,11 @@ discard block |
||
| 413 | 451 | $query .= " ORDER BY tracker_output.source_name ASC"; |
| 414 | 452 | |
| 415 | 453 | $sth = $this->db->prepare($query); |
| 416 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 417 | - else $sth->execute(); |
|
| 454 | + if (!empty($query_values)) { |
|
| 455 | + $sth->execute($query_values); |
|
| 456 | + } else { |
|
| 457 | + $sth->execute(); |
|
| 458 | + } |
|
| 418 | 459 | |
| 419 | 460 | $source_array = array(); |
| 420 | 461 | $temp_array = array(); |
@@ -469,7 +510,9 @@ discard block |
||
| 469 | 510 | date_default_timezone_set($globalTimezone); |
| 470 | 511 | $datetime = new DateTime(); |
| 471 | 512 | $offset = $datetime->format('P'); |
| 472 | - } else $offset = '+00:00'; |
|
| 513 | + } else { |
|
| 514 | + $offset = '+00:00'; |
|
| 515 | + } |
|
| 473 | 516 | |
| 474 | 517 | if ($globalDBdriver == 'mysql') { |
| 475 | 518 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -617,7 +660,9 @@ discard block |
||
| 617 | 660 | { |
| 618 | 661 | return false; |
| 619 | 662 | } |
| 620 | - } else $altitude = 0; |
|
| 663 | + } else { |
|
| 664 | + $altitude = 0; |
|
| 665 | + } |
|
| 621 | 666 | |
| 622 | 667 | if ($heading != "") |
| 623 | 668 | { |
@@ -656,8 +701,12 @@ discard block |
||
| 656 | 701 | $latitude = 0; |
| 657 | 702 | $longitude = 0; |
| 658 | 703 | } |
| 659 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 660 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 704 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 705 | + $heading = 0; |
|
| 706 | + } |
|
| 707 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 708 | + $groundspeed = 0; |
|
| 709 | + } |
|
| 661 | 710 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
| 662 | 711 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
| 663 | 712 | |
@@ -764,7 +813,9 @@ discard block |
||
| 764 | 813 | global $globalDBdriver, $globalArchive; |
| 765 | 814 | //$filter_query = $this->getFilter($filters,true,true); |
| 766 | 815 | $Connection= new Connection($this->db); |
| 767 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 816 | + if (!$Connection->tableExists('countries')) { |
|
| 817 | + return array(); |
|
| 818 | + } |
|
| 768 | 819 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 769 | 820 | require_once('class.TrackerLive.php'); |
| 770 | 821 | $TrackerLive = new TrackerLive($this->db); |
@@ -807,7 +858,9 @@ discard block |
||
| 807 | 858 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 808 | 859 | } |
| 809 | 860 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 810 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 861 | + if ($limit) { |
|
| 862 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 863 | + } |
|
| 811 | 864 | |
| 812 | 865 | |
| 813 | 866 | $sth = $this->db->prepare($query); |
@@ -846,12 +899,18 @@ discard block |
||
| 846 | 899 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
| 847 | 900 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
| 848 | 901 | if ($olderthanmonths > 0) { |
| 849 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 850 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 902 | + if ($globalDBdriver == 'mysql') { |
|
| 903 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 904 | + } else { |
|
| 905 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 906 | + } |
|
| 851 | 907 | } |
| 852 | 908 | if ($sincedate != '') { |
| 853 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
| 854 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 909 | + if ($globalDBdriver == 'mysql') { |
|
| 910 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
| 911 | + } else { |
|
| 912 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 913 | + } |
|
| 855 | 914 | } |
| 856 | 915 | $query_values = array(); |
| 857 | 916 | if ($year != '') { |
@@ -882,7 +941,9 @@ discard block |
||
| 882 | 941 | } |
| 883 | 942 | } |
| 884 | 943 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
| 885 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 944 | + if ($limit) { |
|
| 945 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 946 | + } |
|
| 886 | 947 | |
| 887 | 948 | $sth = $this->db->prepare($query); |
| 888 | 949 | $sth->execute($query_values); |
@@ -917,7 +978,9 @@ discard block |
||
| 917 | 978 | date_default_timezone_set($globalTimezone); |
| 918 | 979 | $datetime = new DateTime(); |
| 919 | 980 | $offset = $datetime->format('P'); |
| 920 | - } else $offset = '+00:00'; |
|
| 981 | + } else { |
|
| 982 | + $offset = '+00:00'; |
|
| 983 | + } |
|
| 921 | 984 | |
| 922 | 985 | if ($globalDBdriver == 'mysql') { |
| 923 | 986 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -967,7 +1030,9 @@ discard block |
||
| 967 | 1030 | date_default_timezone_set($globalTimezone); |
| 968 | 1031 | $datetime = new DateTime(); |
| 969 | 1032 | $offset = $datetime->format('P'); |
| 970 | - } else $offset = '+00:00'; |
|
| 1033 | + } else { |
|
| 1034 | + $offset = '+00:00'; |
|
| 1035 | + } |
|
| 971 | 1036 | $filter_query = $this->getFilter($filters,true,true); |
| 972 | 1037 | if ($globalDBdriver == 'mysql') { |
| 973 | 1038 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1013,7 +1078,9 @@ discard block |
||
| 1013 | 1078 | date_default_timezone_set($globalTimezone); |
| 1014 | 1079 | $datetime = new DateTime(); |
| 1015 | 1080 | $offset = $datetime->format('P'); |
| 1016 | - } else $offset = '+00:00'; |
|
| 1081 | + } else { |
|
| 1082 | + $offset = '+00:00'; |
|
| 1083 | + } |
|
| 1017 | 1084 | $filter_query = $this->getFilter($filters,true,true); |
| 1018 | 1085 | if ($globalDBdriver == 'mysql') { |
| 1019 | 1086 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1060,7 +1127,9 @@ discard block |
||
| 1060 | 1127 | date_default_timezone_set($globalTimezone); |
| 1061 | 1128 | $datetime = new DateTime(); |
| 1062 | 1129 | $offset = $datetime->format('P'); |
| 1063 | - } else $offset = '+00:00'; |
|
| 1130 | + } else { |
|
| 1131 | + $offset = '+00:00'; |
|
| 1132 | + } |
|
| 1064 | 1133 | |
| 1065 | 1134 | if ($globalDBdriver == 'mysql') { |
| 1066 | 1135 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1107,7 +1176,9 @@ discard block |
||
| 1107 | 1176 | date_default_timezone_set($globalTimezone); |
| 1108 | 1177 | $datetime = new DateTime(); |
| 1109 | 1178 | $offset = $datetime->format('P'); |
| 1110 | - } else $offset = '+00:00'; |
|
| 1179 | + } else { |
|
| 1180 | + $offset = '+00:00'; |
|
| 1181 | + } |
|
| 1111 | 1182 | $filter_query = $this->getFilter($filters,true,true); |
| 1112 | 1183 | if ($globalDBdriver == 'mysql') { |
| 1113 | 1184 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1156,7 +1227,9 @@ discard block |
||
| 1156 | 1227 | date_default_timezone_set($globalTimezone); |
| 1157 | 1228 | $datetime = new DateTime(); |
| 1158 | 1229 | $offset = $datetime->format('P'); |
| 1159 | - } else $offset = '+00:00'; |
|
| 1230 | + } else { |
|
| 1231 | + $offset = '+00:00'; |
|
| 1232 | + } |
|
| 1160 | 1233 | |
| 1161 | 1234 | $orderby_sql = ''; |
| 1162 | 1235 | if ($orderby == "hour") |
@@ -1225,7 +1298,9 @@ discard block |
||
| 1225 | 1298 | date_default_timezone_set($globalTimezone); |
| 1226 | 1299 | $datetime = new DateTime($date); |
| 1227 | 1300 | $offset = $datetime->format('P'); |
| 1228 | - } else $offset = '+00:00'; |
|
| 1301 | + } else { |
|
| 1302 | + $offset = '+00:00'; |
|
| 1303 | + } |
|
| 1229 | 1304 | |
| 1230 | 1305 | if ($globalDBdriver == 'mysql') { |
| 1231 | 1306 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1273,7 +1348,9 @@ discard block |
||
| 1273 | 1348 | date_default_timezone_set($globalTimezone); |
| 1274 | 1349 | $datetime = new DateTime(); |
| 1275 | 1350 | $offset = $datetime->format('P'); |
| 1276 | - } else $offset = '+00:00'; |
|
| 1351 | + } else { |
|
| 1352 | + $offset = '+00:00'; |
|
| 1353 | + } |
|
| 1277 | 1354 | |
| 1278 | 1355 | if ($globalDBdriver == 'mysql') { |
| 1279 | 1356 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1339,8 +1416,11 @@ discard block |
||
| 1339 | 1416 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1340 | 1417 | } |
| 1341 | 1418 | } |
| 1342 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1343 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1419 | + if (empty($query_values)) { |
|
| 1420 | + $queryi .= $this->getFilter($filters); |
|
| 1421 | + } else { |
|
| 1422 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1423 | + } |
|
| 1344 | 1424 | |
| 1345 | 1425 | $sth = $this->db->prepare($queryi); |
| 1346 | 1426 | $sth->execute($query_values); |
@@ -1379,8 +1459,11 @@ discard block |
||
| 1379 | 1459 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1380 | 1460 | } |
| 1381 | 1461 | } |
| 1382 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1383 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1462 | + if (empty($query_values)) { |
|
| 1463 | + $queryi .= $this->getFilter($filters); |
|
| 1464 | + } else { |
|
| 1465 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1466 | + } |
|
| 1384 | 1467 | |
| 1385 | 1468 | $sth = $this->db->prepare($queryi); |
| 1386 | 1469 | $sth->execute($query_values); |
@@ -1402,7 +1485,9 @@ discard block |
||
| 1402 | 1485 | date_default_timezone_set($globalTimezone); |
| 1403 | 1486 | $datetime = new DateTime(); |
| 1404 | 1487 | $offset = $datetime->format('P'); |
| 1405 | - } else $offset = '+00:00'; |
|
| 1488 | + } else { |
|
| 1489 | + $offset = '+00:00'; |
|
| 1490 | + } |
|
| 1406 | 1491 | |
| 1407 | 1492 | if ($globalDBdriver == 'mysql') { |
| 1408 | 1493 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1506,7 +1591,9 @@ discard block |
||
| 1506 | 1591 | */ |
| 1507 | 1592 | public function parseDirection($direction = 0) |
| 1508 | 1593 | { |
| 1509 | - if ($direction == '') $direction = 0; |
|
| 1594 | + if ($direction == '') { |
|
| 1595 | + $direction = 0; |
|
| 1596 | + } |
|
| 1510 | 1597 | $direction_array = array(); |
| 1511 | 1598 | $temp_array = array(); |
| 1512 | 1599 | |
@@ -1595,7 +1682,9 @@ discard block |
||
| 1595 | 1682 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1596 | 1683 | |
| 1597 | 1684 | $Connection = new Connection($this->db); |
| 1598 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1685 | + if (!$Connection->tableExists('countries')) { |
|
| 1686 | + return ''; |
|
| 1687 | + } |
|
| 1599 | 1688 | |
| 1600 | 1689 | try { |
| 1601 | 1690 | $query = "SELECT name,iso2,iso3 FROM countries WHERE ST_Within(ST_GeomFromText('POINT(".$longitude." ".$latitude.")',4326), ogc_geom) LIMIT 1"; |
@@ -1606,9 +1695,13 @@ discard block |
||
| 1606 | 1695 | $sth->closeCursor(); |
| 1607 | 1696 | if (count($row) > 0) { |
| 1608 | 1697 | return $row; |
| 1609 | - } else return ''; |
|
| 1698 | + } else { |
|
| 1699 | + return ''; |
|
| 1700 | + } |
|
| 1610 | 1701 | } catch (PDOException $e) { |
| 1611 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1702 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1703 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1704 | + } |
|
| 1612 | 1705 | return ''; |
| 1613 | 1706 | } |
| 1614 | 1707 | |
@@ -1626,7 +1719,9 @@ discard block |
||
| 1626 | 1719 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1627 | 1720 | |
| 1628 | 1721 | $Connection = new Connection($this->db); |
| 1629 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1722 | + if (!$Connection->tableExists('countries')) { |
|
| 1723 | + return ''; |
|
| 1724 | + } |
|
| 1630 | 1725 | |
| 1631 | 1726 | try { |
| 1632 | 1727 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1638,9 +1733,13 @@ discard block |
||
| 1638 | 1733 | $sth->closeCursor(); |
| 1639 | 1734 | if (count($row) > 0) { |
| 1640 | 1735 | return $row; |
| 1641 | - } else return ''; |
|
| 1736 | + } else { |
|
| 1737 | + return ''; |
|
| 1738 | + } |
|
| 1642 | 1739 | } catch (PDOException $e) { |
| 1643 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1740 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1741 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1742 | + } |
|
| 1644 | 1743 | return ''; |
| 1645 | 1744 | } |
| 1646 | 1745 | |
@@ -1707,7 +1806,9 @@ discard block |
||
| 1707 | 1806 | } |
| 1708 | 1807 | } |
| 1709 | 1808 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
| 1710 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1809 | + if ($limit) { |
|
| 1810 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1811 | + } |
|
| 1711 | 1812 | $sth = $this->db->prepare($query); |
| 1712 | 1813 | $sth->execute($query_values); |
| 1713 | 1814 | $tracker_array = array(); |
@@ -1753,7 +1854,9 @@ discard block |
||
| 1753 | 1854 | foreach ($q_array as $q_item){ |
| 1754 | 1855 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 1755 | 1856 | $additional_query .= " AND ("; |
| 1756 | - if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
|
| 1857 | + if (is_int($q_item)) { |
|
| 1858 | + $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
|
| 1859 | + } |
|
| 1757 | 1860 | $additional_query .= "(tracker_output.ident like '%".$q_item."%') OR "; |
| 1758 | 1861 | $additional_query .= ")"; |
| 1759 | 1862 | } |
@@ -1779,7 +1882,9 @@ discard block |
||
| 1779 | 1882 | date_default_timezone_set($globalTimezone); |
| 1780 | 1883 | $datetime = new DateTime(); |
| 1781 | 1884 | $offset = $datetime->format('P'); |
| 1782 | - } else $offset = '+00:00'; |
|
| 1885 | + } else { |
|
| 1886 | + $offset = '+00:00'; |
|
| 1887 | + } |
|
| 1783 | 1888 | if ($date_array[1] != "") |
| 1784 | 1889 | { |
| 1785 | 1890 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1806,8 +1911,12 @@ discard block |
||
| 1806 | 1911 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1807 | 1912 | { |
| 1808 | 1913 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1809 | - } else $limit_query = ""; |
|
| 1810 | - } else $limit_query = ""; |
|
| 1914 | + } else { |
|
| 1915 | + $limit_query = ""; |
|
| 1916 | + } |
|
| 1917 | + } else { |
|
| 1918 | + $limit_query = ""; |
|
| 1919 | + } |
|
| 1811 | 1920 | if ($sort != "") |
| 1812 | 1921 | { |
| 1813 | 1922 | $search_orderby_array = $this->getOrderBy(); |
@@ -1850,7 +1959,9 @@ discard block |
||
| 1850 | 1959 | { |
| 1851 | 1960 | global $globalBitlyAccessToken; |
| 1852 | 1961 | |
| 1853 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1962 | + if ($globalBitlyAccessToken == '') { |
|
| 1963 | + return $url; |
|
| 1964 | + } |
|
| 1854 | 1965 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1855 | 1966 | $ch = curl_init(); |
| 1856 | 1967 | curl_setopt($ch, CURLOPT_HEADER, 0); |