@@ -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 | } |
@@ -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. (Accident)'); |
|
| 23 | + if ($this->db === null) { |
|
| 24 | + die('Error: No DB connection. (Accident)'); |
|
| 25 | + } |
|
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | /* |
@@ -126,8 +128,11 @@ discard block |
||
| 126 | 128 | $data = array(); |
| 127 | 129 | if ($row['registration'] != '') { |
| 128 | 130 | $image_array = $Image->getSpotterImage($row['registration']); |
| 129 | - 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'])); |
|
| 130 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 131 | + if (count($image_array) > 0) { |
|
| 132 | + $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'])); |
|
| 133 | + } else { |
|
| 134 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 135 | + } |
|
| 131 | 136 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 132 | 137 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 133 | 138 | if (!empty($aircraft_info)) { |
@@ -143,17 +148,30 @@ discard block |
||
| 143 | 148 | $data['aircraft_base'] = $owner_data['base']; |
| 144 | 149 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 145 | 150 | } |
| 146 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 147 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 148 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 151 | + } else { |
|
| 152 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 153 | + } |
|
| 154 | + if ($row['registration'] == '') { |
|
| 155 | + $row['registration'] = 'NA'; |
|
| 156 | + } |
|
| 157 | + if ($row['ident'] == '') { |
|
| 158 | + $row['ident'] = 'NA'; |
|
| 159 | + } |
|
| 149 | 160 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
| 150 | 161 | if (isset($identicao[0])) { |
| 151 | 162 | if (substr($row['ident'],0,2) == 'AF') { |
| 152 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 153 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 154 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 163 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 164 | + $icao = $row['ident']; |
|
| 165 | + } else { |
|
| 166 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 167 | + } |
|
| 168 | + } else { |
|
| 169 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 170 | + } |
|
| 155 | 171 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 156 | - } else $icao = $row['ident']; |
|
| 172 | + } else { |
|
| 173 | + $icao = $row['ident']; |
|
| 174 | + } |
|
| 157 | 175 | $icao = $Translation->checkTranslation($icao,false); |
| 158 | 176 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 159 | 177 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -168,10 +186,14 @@ discard block |
||
| 168 | 186 | //else echo 'No data...'."\n"; |
| 169 | 187 | } |
| 170 | 188 | $data = array_merge($row,$data); |
| 171 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
| 189 | + if ($data['ident'] == null) { |
|
| 190 | + $data['ident'] = $icao; |
|
| 191 | + } |
|
| 172 | 192 | if ($data['title'] == null) { |
| 173 | 193 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 174 | - } else $data['message'] = strtolower($data['title']); |
|
| 194 | + } else { |
|
| 195 | + $data['message'] = strtolower($data['title']); |
|
| 196 | + } |
|
| 175 | 197 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
| 176 | 198 | $date = $data['date']; |
| 177 | 199 | if (isset($ids[$date])) { |
@@ -190,8 +212,9 @@ discard block |
||
| 190 | 212 | if (isset($result)) { |
| 191 | 213 | $result[0]['query_number_rows'] = $i; |
| 192 | 214 | return $result; |
| 215 | + } else { |
|
| 216 | + return array(); |
|
| 193 | 217 | } |
| 194 | - else return array(); |
|
| 195 | 218 | } |
| 196 | 219 | |
| 197 | 220 | /* |
@@ -238,7 +261,9 @@ discard block |
||
| 238 | 261 | */ |
| 239 | 262 | public function import($file) { |
| 240 | 263 | global $globalDebug; |
| 241 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
| 264 | + if ($globalDebug) { |
|
| 265 | + echo 'Import '.$file."\n"; |
|
| 266 | + } |
|
| 242 | 267 | $result = array(); |
| 243 | 268 | if (file_exists($file)) { |
| 244 | 269 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -249,8 +274,11 @@ discard block |
||
| 249 | 274 | } |
| 250 | 275 | fclose($handle); |
| 251 | 276 | } |
| 252 | - if (!empty($result)) $this->add($result,true); |
|
| 253 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
| 277 | + if (!empty($result)) { |
|
| 278 | + $this->add($result,true); |
|
| 279 | + } elseif ($globalDebug) { |
|
| 280 | + echo 'Nothing to import'; |
|
| 281 | + } |
|
| 254 | 282 | } |
| 255 | 283 | } |
| 256 | 284 | |
@@ -286,14 +314,23 @@ discard block |
||
| 286 | 314 | } |
| 287 | 315 | } |
| 288 | 316 | fclose($handle); |
| 289 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 290 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 317 | + } elseif ($globalDebug) { |
|
| 318 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 319 | + } |
|
| 320 | + } elseif ($globalDebug) { |
|
| 321 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 322 | + } |
|
| 291 | 323 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
| 292 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
| 324 | + if (empty($result) && $globalDebug) { |
|
| 325 | + echo 'Nothing to update'; |
|
| 326 | + } |
|
| 293 | 327 | foreach ($result as $file => $md5) { |
| 294 | 328 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
| 295 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 296 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
| 329 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
| 330 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 331 | + } elseif ($globalDebug) { |
|
| 332 | + echo 'Download '.$file.' failed'; |
|
| 333 | + } |
|
| 297 | 334 | } |
| 298 | 335 | } |
| 299 | 336 | |
@@ -310,13 +347,17 @@ discard block |
||
| 310 | 347 | $Image = new Image($this->db); |
| 311 | 348 | $Spotter = new Spotter($this->db); |
| 312 | 349 | |
| 313 | - if (empty($crash)) return false; |
|
| 350 | + if (empty($crash)) { |
|
| 351 | + return false; |
|
| 352 | + } |
|
| 314 | 353 | if ($new === false) { |
| 315 | 354 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
| 316 | 355 | $sthd = $Connection->db->prepare($query_delete); |
| 317 | 356 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 318 | 357 | } |
| 319 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 358 | + if ($globalTransaction) { |
|
| 359 | + $Connection->db->beginTransaction(); |
|
| 360 | + } |
|
| 320 | 361 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
| 321 | 362 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 322 | 363 | $sth_check = $Connection->db->prepare($query_check); |
@@ -331,7 +372,9 @@ discard block |
||
| 331 | 372 | return $value === "" ? NULL : $value; |
| 332 | 373 | }, $cr); |
| 333 | 374 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
| 334 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 375 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
| 376 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 377 | + } |
|
| 335 | 378 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
| 336 | 379 | $sth_check->execute($query_check_values); |
| 337 | 380 | $result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC); |
@@ -342,13 +385,19 @@ discard block |
||
| 342 | 385 | if ($globalAircraftImageFetch) { |
| 343 | 386 | $imgchk = $Image->getSpotterImage($cr['registration']); |
| 344 | 387 | if (empty($imgchk)) { |
| 345 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 388 | + if ($globalDebug) { |
|
| 389 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 390 | + } |
|
| 346 | 391 | $Image->addSpotterImage($cr['registration']); |
| 347 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
| 392 | + if ($globalDebug) { |
|
| 393 | + echo "\t".'Done'."\n"; |
|
| 394 | + } |
|
| 348 | 395 | } |
| 349 | 396 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 350 | 397 | } |
| 351 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 398 | + if ($cr['title'] == '') { |
|
| 399 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 400 | + } |
|
| 352 | 401 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
| 353 | 402 | } |
| 354 | 403 | } |
@@ -358,9 +407,13 @@ discard block |
||
| 358 | 407 | $Connection->db->beginTransaction(); |
| 359 | 408 | } |
| 360 | 409 | } |
| 361 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 410 | + if ($globalTransaction) { |
|
| 411 | + $Connection->db->commit(); |
|
| 412 | + } |
|
| 362 | 413 | } catch(PDOException $e) { |
| 363 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 414 | + if ($globalTransaction) { |
|
| 415 | + $Connection->db->rollBack(); |
|
| 416 | + } |
|
| 364 | 417 | echo $e->getMessage(); |
| 365 | 418 | } |
| 366 | 419 | $sth_check->closeCursor(); |
@@ -403,8 +456,11 @@ discard block |
||
| 403 | 456 | return "error : ".$e->getMessage(); |
| 404 | 457 | } |
| 405 | 458 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 406 | - if ($row['nb'] > 0) return false; |
|
| 407 | - else return true; |
|
| 459 | + if ($row['nb'] > 0) { |
|
| 460 | + return false; |
|
| 461 | + } else { |
|
| 462 | + return true; |
|
| 463 | + } |
|
| 408 | 464 | } |
| 409 | 465 | |
| 410 | 466 | /** |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection. (SpotterLive)'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection. (SpotterLive)'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -129,8 +133,11 @@ discard block |
||
| 129 | 133 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 130 | 134 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 131 | 135 | } |
| 132 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 133 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 136 | + if ($filter_query_where == '' && $where) { |
|
| 137 | + $filter_query_where = ' WHERE'; |
|
| 138 | + } elseif ($filter_query_where != '' && $and) { |
|
| 139 | + $filter_query_where .= ' AND'; |
|
| 140 | + } |
|
| 134 | 141 | if ($filter_query_where != '') { |
| 135 | 142 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 136 | 143 | } |
@@ -173,9 +180,13 @@ discard block |
||
| 173 | 180 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 174 | 181 | } |
| 175 | 182 | } |
| 176 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 183 | + if ($orderby_query == '') { |
|
| 184 | + $orderby_query = ' ORDER BY date DESC'; |
|
| 185 | + } |
|
| 177 | 186 | |
| 178 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 187 | + if (!isset($globalLiveInterval)) { |
|
| 188 | + $globalLiveInterval = '200'; |
|
| 189 | + } |
|
| 179 | 190 | if ($globalDBdriver == 'mysql') { |
| 180 | 191 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 181 | 192 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -199,7 +210,9 @@ discard block |
||
| 199 | 210 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
| 200 | 211 | date_default_timezone_set('UTC'); |
| 201 | 212 | $filter_query = $this->getFilter($filter,true,true); |
| 202 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 213 | + if (!isset($globalLiveInterval)) { |
|
| 214 | + $globalLiveInterval = '200'; |
|
| 215 | + } |
|
| 203 | 216 | if ($globalDBdriver == 'mysql') { |
| 204 | 217 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 205 | 218 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -263,14 +276,22 @@ discard block |
||
| 263 | 276 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 264 | 277 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 265 | 278 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 266 | - if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true; |
|
| 279 | + if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') { |
|
| 280 | + $usecoord = true; |
|
| 281 | + } |
|
| 267 | 282 | } |
| 268 | 283 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 269 | 284 | $filter_query = $this->getFilter($filter,true,true); |
| 270 | 285 | |
| 271 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 272 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 273 | - if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit; |
|
| 286 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 287 | + $globalLiveInterval = '200'; |
|
| 288 | + } |
|
| 289 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
| 290 | + $globalMap3DAircraftsLimit = '300'; |
|
| 291 | + } |
|
| 292 | + if ($limit == 0 || $limit == '') { |
|
| 293 | + $limit = $globalMap3DAircraftsLimit; |
|
| 294 | + } |
|
| 274 | 295 | if ($globalDBdriver == 'mysql') { |
| 275 | 296 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 276 | 297 | /* |
@@ -283,26 +304,42 @@ discard block |
||
| 283 | 304 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 284 | 305 | //if ($limit > 0) $query .= " LIMIT ".$limit; |
| 285 | 306 | $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 286 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 287 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 307 | + if ($usecoord) { |
|
| 308 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 309 | + } |
|
| 310 | + if ($id != '') { |
|
| 311 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 312 | + } |
|
| 288 | 313 | $query .= "UNION |
| 289 | 314 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 290 | 315 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 291 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 292 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 316 | + if ($usecoord) { |
|
| 317 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 318 | + } |
|
| 319 | + if ($id != '') { |
|
| 320 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 321 | + } |
|
| 293 | 322 | //if ($limit > 0) $query .= " LIMIT ".$limit; |
| 294 | 323 | $query .= ") AS spotter |
| 295 | 324 | WHERE latitude <> '0' AND longitude <> '0' |
| 296 | 325 | ORDER BY flightaware_id, date"; |
| 297 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 326 | + if ($limit > 0) { |
|
| 327 | + $query .= " LIMIT ".$limit; |
|
| 328 | + } |
|
| 298 | 329 | } else { |
| 299 | 330 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 300 | 331 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 301 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 302 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 332 | + if ($usecoord) { |
|
| 333 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 334 | + } |
|
| 335 | + if ($id != '') { |
|
| 336 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 337 | + } |
|
| 303 | 338 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 304 | 339 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 305 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 340 | + if ($limit > 0) { |
|
| 341 | + $query .= " LIMIT ".$limit; |
|
| 342 | + } |
|
| 306 | 343 | } |
| 307 | 344 | } else { |
| 308 | 345 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -320,29 +357,47 @@ discard block |
||
| 320 | 357 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 321 | 358 | //if ($limit > 0) $query .= " ORDER BY spotter_live.date ASC LIMIT ".$limit; |
| 322 | 359 | $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 323 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 324 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 360 | + if ($usecoord) { |
|
| 361 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 362 | + } |
|
| 363 | + if ($id != '') { |
|
| 364 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 365 | + } |
|
| 325 | 366 | $query .= "UNION |
| 326 | 367 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 327 | 368 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 328 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 329 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 369 | + if ($usecoord) { |
|
| 370 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 371 | + } |
|
| 372 | + if ($id != '') { |
|
| 373 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 374 | + } |
|
| 330 | 375 | //if ($limit > 0) $query .= " ORDER BY date ASC LIMIT ".$limit; |
| 331 | 376 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 332 | 377 | $query .= "ORDER BY flightaware_id, date"; |
| 333 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 378 | + if ($limit > 0) { |
|
| 379 | + $query .= " LIMIT ".$limit; |
|
| 380 | + } |
|
| 334 | 381 | } else { |
| 335 | 382 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 336 | 383 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
| 337 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 338 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 384 | + if ($usecoord) { |
|
| 385 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 386 | + } |
|
| 387 | + if ($id != '') { |
|
| 388 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 389 | + } |
|
| 339 | 390 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 340 | 391 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 341 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 392 | + if ($limit > 0) { |
|
| 393 | + $query .= " LIMIT ".$limit; |
|
| 394 | + } |
|
| 342 | 395 | } |
| 343 | 396 | } |
| 344 | 397 | $query_values = array(); |
| 345 | - if ($id != '') $query_values = array(':id' => $id); |
|
| 398 | + if ($id != '') { |
|
| 399 | + $query_values = array(':id' => $id); |
|
| 400 | + } |
|
| 346 | 401 | try { |
| 347 | 402 | $sth = $this->db->prepare($query); |
| 348 | 403 | $sth->execute($query_values); |
@@ -369,9 +424,15 @@ discard block |
||
| 369 | 424 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 370 | 425 | $filter_query = $this->getFilter($filter,true,true); |
| 371 | 426 | |
| 372 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 373 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 374 | - if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit; |
|
| 427 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 428 | + $globalLiveInterval = '200'; |
|
| 429 | + } |
|
| 430 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
| 431 | + $globalMap3DAircraftsLimit = '300'; |
|
| 432 | + } |
|
| 433 | + if ($limit == 0 || $limit == '') { |
|
| 434 | + $limit = $globalMap3DAircraftsLimit; |
|
| 435 | + } |
|
| 375 | 436 | if ($globalDBdriver == 'mysql') { |
| 376 | 437 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 377 | 438 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
@@ -382,13 +443,17 @@ discard block |
||
| 382 | 443 | $query .= ") AS spotter |
| 383 | 444 | WHERE latitude <> '0' AND longitude <> '0' |
| 384 | 445 | ORDER BY flightaware_id, date"; |
| 385 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 446 | + if ($limit > 0) { |
|
| 447 | + $query .= " LIMIT ".$limit; |
|
| 448 | + } |
|
| 386 | 449 | } else { |
| 387 | 450 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 388 | 451 | FROM spotter_live'.$filter_query.' spotter_live.flightaware_id = :id '; |
| 389 | 452 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 390 | 453 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 391 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 454 | + if ($limit > 0) { |
|
| 455 | + $query .= " LIMIT ".$limit; |
|
| 456 | + } |
|
| 392 | 457 | } |
| 393 | 458 | } else { |
| 394 | 459 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -404,13 +469,17 @@ discard block |
||
| 404 | 469 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
| 405 | 470 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 406 | 471 | $query .= "ORDER BY flightaware_id, date"; |
| 407 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 472 | + if ($limit > 0) { |
|
| 473 | + $query .= " LIMIT ".$limit; |
|
| 474 | + } |
|
| 408 | 475 | } else { |
| 409 | 476 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 410 | 477 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id "; |
| 411 | 478 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 412 | 479 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 413 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 480 | + if ($limit > 0) { |
|
| 481 | + $query .= " LIMIT ".$limit; |
|
| 482 | + } |
|
| 414 | 483 | } |
| 415 | 484 | } |
| 416 | 485 | $query_values = array(':id' => $id); |
@@ -436,7 +505,9 @@ discard block |
||
| 436 | 505 | global $globalDBdriver, $globalLiveInterval; |
| 437 | 506 | $filter_query = $this->getFilter($filter,true,true); |
| 438 | 507 | |
| 439 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 508 | + if (!isset($globalLiveInterval)) { |
|
| 509 | + $globalLiveInterval = '200'; |
|
| 510 | + } |
|
| 440 | 511 | if ($globalDBdriver == 'mysql') { |
| 441 | 512 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 442 | 513 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -467,7 +538,9 @@ discard block |
||
| 467 | 538 | { |
| 468 | 539 | global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit; |
| 469 | 540 | $Spotter = new Spotter($this->db); |
| 470 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 541 | + if (!isset($globalLiveInterval)) { |
|
| 542 | + $globalLiveInterval = '200'; |
|
| 543 | + } |
|
| 471 | 544 | $filter_query = $this->getFilter($filter); |
| 472 | 545 | |
| 473 | 546 | if (is_array($coord)) { |
@@ -475,7 +548,9 @@ discard block |
||
| 475 | 548 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 476 | 549 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 477 | 550 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 478 | - } else return array(); |
|
| 551 | + } else { |
|
| 552 | + return array(); |
|
| 553 | + } |
|
| 479 | 554 | if ($globalDBdriver == 'mysql') { |
| 480 | 555 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 481 | 556 | } else { |
@@ -500,7 +575,9 @@ discard block |
||
| 500 | 575 | public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array()) |
| 501 | 576 | { |
| 502 | 577 | global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
| 503 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 578 | + if (!isset($globalLiveInterval)) { |
|
| 579 | + $globalLiveInterval = '200'; |
|
| 580 | + } |
|
| 504 | 581 | $filter_query = $this->getFilter($filter,true,true); |
| 505 | 582 | |
| 506 | 583 | if (is_array($coord)) { |
@@ -508,7 +585,9 @@ discard block |
||
| 508 | 585 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 509 | 586 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 510 | 587 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 511 | - } else return array(); |
|
| 588 | + } else { |
|
| 589 | + return array(); |
|
| 590 | + } |
|
| 512 | 591 | if ($globalDBdriver == 'mysql') { |
| 513 | 592 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 514 | 593 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -763,11 +842,15 @@ discard block |
||
| 763 | 842 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 764 | 843 | if ($globalDBdriver == 'mysql') { |
| 765 | 844 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 766 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 845 | + if ($liveinterval) { |
|
| 846 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 847 | + } |
|
| 767 | 848 | $query .= ' ORDER BY date'; |
| 768 | 849 | } else { |
| 769 | 850 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 770 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 851 | + if ($liveinterval) { |
|
| 852 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 853 | + } |
|
| 771 | 854 | $query .= ' ORDER BY date'; |
| 772 | 855 | } |
| 773 | 856 | |
@@ -862,7 +945,9 @@ discard block |
||
| 862 | 945 | $i++; |
| 863 | 946 | $j++; |
| 864 | 947 | if ($j == 30) { |
| 865 | - if ($globalDebug) echo "."; |
|
| 948 | + if ($globalDebug) { |
|
| 949 | + echo "."; |
|
| 950 | + } |
|
| 866 | 951 | try { |
| 867 | 952 | |
| 868 | 953 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1237,7 +1322,9 @@ discard block |
||
| 1237 | 1322 | { |
| 1238 | 1323 | return false; |
| 1239 | 1324 | } |
| 1240 | - } else return ''; |
|
| 1325 | + } else { |
|
| 1326 | + return ''; |
|
| 1327 | + } |
|
| 1241 | 1328 | |
| 1242 | 1329 | if ($longitude != '') |
| 1243 | 1330 | { |
@@ -1245,7 +1332,9 @@ discard block |
||
| 1245 | 1332 | { |
| 1246 | 1333 | return false; |
| 1247 | 1334 | } |
| 1248 | - } else return ''; |
|
| 1335 | + } else { |
|
| 1336 | + return ''; |
|
| 1337 | + } |
|
| 1249 | 1338 | |
| 1250 | 1339 | if ($waypoints != '') |
| 1251 | 1340 | { |
@@ -1261,14 +1350,18 @@ discard block |
||
| 1261 | 1350 | { |
| 1262 | 1351 | return false; |
| 1263 | 1352 | } |
| 1264 | - } else $altitude = 0; |
|
| 1353 | + } else { |
|
| 1354 | + $altitude = 0; |
|
| 1355 | + } |
|
| 1265 | 1356 | if ($altitude_real != '') |
| 1266 | 1357 | { |
| 1267 | 1358 | if (!is_numeric($altitude_real)) |
| 1268 | 1359 | { |
| 1269 | 1360 | return false; |
| 1270 | 1361 | } |
| 1271 | - } else $altitude_real = 0; |
|
| 1362 | + } else { |
|
| 1363 | + $altitude_real = 0; |
|
| 1364 | + } |
|
| 1272 | 1365 | |
| 1273 | 1366 | if ($heading != '') |
| 1274 | 1367 | { |
@@ -1276,7 +1369,9 @@ discard block |
||
| 1276 | 1369 | { |
| 1277 | 1370 | return false; |
| 1278 | 1371 | } |
| 1279 | - } else $heading = 0; |
|
| 1372 | + } else { |
|
| 1373 | + $heading = 0; |
|
| 1374 | + } |
|
| 1280 | 1375 | |
| 1281 | 1376 | if ($groundspeed != '') |
| 1282 | 1377 | { |
@@ -1284,9 +1379,13 @@ discard block |
||
| 1284 | 1379 | { |
| 1285 | 1380 | return false; |
| 1286 | 1381 | } |
| 1287 | - } else $groundspeed = 0; |
|
| 1382 | + } else { |
|
| 1383 | + $groundspeed = 0; |
|
| 1384 | + } |
|
| 1288 | 1385 | date_default_timezone_set('UTC'); |
| 1289 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1386 | + if ($date == '') { |
|
| 1387 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1388 | + } |
|
| 1290 | 1389 | |
| 1291 | 1390 | |
| 1292 | 1391 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1331,14 +1430,24 @@ discard block |
||
| 1331 | 1430 | $arrival_airport_country = ''; |
| 1332 | 1431 | |
| 1333 | 1432 | |
| 1334 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1335 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1336 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1337 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1433 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1434 | + $squawk = NULL; |
|
| 1435 | + } |
|
| 1436 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1437 | + $verticalrate = NULL; |
|
| 1438 | + } |
|
| 1439 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1440 | + $groundspeed = 0; |
|
| 1441 | + } |
|
| 1442 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1443 | + $heading = 0; |
|
| 1444 | + } |
|
| 1338 | 1445 | |
| 1339 | 1446 | $query = ''; |
| 1340 | 1447 | if ($globalArchive) { |
| 1341 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1448 | + if ($globalDebug) { |
|
| 1449 | + echo '-- Delete previous data -- '; |
|
| 1450 | + } |
|
| 1342 | 1451 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1343 | 1452 | } |
| 1344 | 1453 | |
@@ -1355,10 +1464,14 @@ discard block |
||
| 1355 | 1464 | return "error : ".$e->getMessage(); |
| 1356 | 1465 | } |
| 1357 | 1466 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1358 | - if ($globalDebug) echo '(Add to Spotter archive : '; |
|
| 1467 | + if ($globalDebug) { |
|
| 1468 | + echo '(Add to Spotter archive : '; |
|
| 1469 | + } |
|
| 1359 | 1470 | $SpotterArchive = new SpotterArchive($this->db); |
| 1360 | 1471 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1361 | - if ($globalDebug) echo $result.')'; |
|
| 1472 | + if ($globalDebug) { |
|
| 1473 | + echo $result.')'; |
|
| 1474 | + } |
|
| 1362 | 1475 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1363 | 1476 | echo '(Not adding to archive)'; |
| 1364 | 1477 | } elseif ($globalDebug && $noarchive === true) { |
@@ -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 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) { |
| 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); |
@@ -756,31 +773,54 @@ discard block |
||
| 756 | 773 | $msg = $message['message']; |
| 757 | 774 | $decode = $message['decode']; |
| 758 | 775 | $registration = (string)$message['registration']; |
| 759 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
| 760 | - else $latitude = ''; |
|
| 761 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
| 762 | - else $longitude = ''; |
|
| 763 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
| 764 | - else $airicao = ''; |
|
| 765 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
| 766 | - else $icao = $Translation->checkTranslation($ident); |
|
| 776 | + if (isset($decode['latitude'])) { |
|
| 777 | + $latitude = $decode['latitude']; |
|
| 778 | + } else { |
|
| 779 | + $latitude = ''; |
|
| 780 | + } |
|
| 781 | + if (isset($decode['longitude'])) { |
|
| 782 | + $longitude = $decode['longitude']; |
|
| 783 | + } else { |
|
| 784 | + $longitude = ''; |
|
| 785 | + } |
|
| 786 | + if (isset($decode['airicao'])) { |
|
| 787 | + $airicao = $decode['airicao']; |
|
| 788 | + } else { |
|
| 789 | + $airicao = ''; |
|
| 790 | + } |
|
| 791 | + if (isset($decode['icao'])) { |
|
| 792 | + $icao = $decode['icao']; |
|
| 793 | + } else { |
|
| 794 | + $icao = $Translation->checkTranslation($ident); |
|
| 795 | + } |
|
| 767 | 796 | $image_array = $Image->getSpotterImage($registration); |
| 768 | 797 | if (!isset($image_array[0]['registration'])) { |
| 769 | 798 | $Image->addSpotterImage($registration); |
| 770 | 799 | } |
| 771 | 800 | // Business jets always use GS0001 |
| 772 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 773 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
| 774 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
| 775 | - else $decode_json = ''; |
|
| 801 | + if ($ident != 'GS0001') { |
|
| 802 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 803 | + } |
|
| 804 | + if ($globalDebug && isset($info) && $info != '') { |
|
| 805 | + echo $info; |
|
| 806 | + } |
|
| 807 | + if (count($decode) > 0) { |
|
| 808 | + $decode_json = json_encode($decode); |
|
| 809 | + } else { |
|
| 810 | + $decode_json = ''; |
|
| 811 | + } |
|
| 776 | 812 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 777 | 813 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
| 778 | 814 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 779 | 815 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
| 780 | 816 | } |
| 781 | 817 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
| 782 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 783 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 818 | + if (!isset($globalACARSArchive)) { |
|
| 819 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 820 | + } |
|
| 821 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
| 822 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 823 | + } |
|
| 784 | 824 | if ($globalDebug && count($decode) > 0) { |
| 785 | 825 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
| 786 | 826 | } |
@@ -805,7 +845,9 @@ discard block |
||
| 805 | 845 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
| 806 | 846 | $Connection = new Connection($this->db); |
| 807 | 847 | $this->db = $Connection->db; |
| 808 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
| 848 | + if ($globalDebug) { |
|
| 849 | + echo "Test if not already in Live ACARS table..."; |
|
| 850 | + } |
|
| 809 | 851 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 810 | 852 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
| 811 | 853 | try { |
@@ -816,7 +858,9 @@ discard block |
||
| 816 | 858 | return false; |
| 817 | 859 | } |
| 818 | 860 | if ($stht->fetchColumn() == 0) { |
| 819 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 861 | + if ($globalDebug) { |
|
| 862 | + echo "Add Live ACARS data..."; |
|
| 863 | + } |
|
| 820 | 864 | $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)"; |
| 821 | 865 | $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")); |
| 822 | 866 | try { |
@@ -827,10 +871,14 @@ discard block |
||
| 827 | 871 | return false; |
| 828 | 872 | } |
| 829 | 873 | } else { |
| 830 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
| 874 | + if ($globalDebug) { |
|
| 875 | + echo "Data already in DB...\n"; |
|
| 876 | + } |
|
| 831 | 877 | return false; |
| 832 | 878 | } |
| 833 | - if ($globalDebug) echo "Done\n"; |
|
| 879 | + if ($globalDebug) { |
|
| 880 | + echo "Done\n"; |
|
| 881 | + } |
|
| 834 | 882 | return true; |
| 835 | 883 | } |
| 836 | 884 | return false; |
@@ -864,7 +912,9 @@ discard block |
||
| 864 | 912 | } |
| 865 | 913 | if ($stht->fetchColumn() == 0) { |
| 866 | 914 | */ |
| 867 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 915 | + if ($globalDebug) { |
|
| 916 | + echo "Add Live ACARS data..."; |
|
| 917 | + } |
|
| 868 | 918 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 869 | 919 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
| 870 | 920 | try { |
@@ -873,7 +923,9 @@ discard block |
||
| 873 | 923 | } catch(PDOException $e) { |
| 874 | 924 | return "error : ".$e->getMessage(); |
| 875 | 925 | } |
| 876 | - if ($globalDebug) echo "Done\n"; |
|
| 926 | + if ($globalDebug) { |
|
| 927 | + echo "Done\n"; |
|
| 928 | + } |
|
| 877 | 929 | } |
| 878 | 930 | return ''; |
| 879 | 931 | } |
@@ -897,8 +949,11 @@ discard block |
||
| 897 | 949 | return ''; |
| 898 | 950 | } |
| 899 | 951 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 900 | - if (count($row) > 0) return $row[0]['title']; |
|
| 901 | - else return ''; |
|
| 952 | + if (count($row) > 0) { |
|
| 953 | + return $row[0]['title']; |
|
| 954 | + } else { |
|
| 955 | + return ''; |
|
| 956 | + } |
|
| 902 | 957 | } |
| 903 | 958 | |
| 904 | 959 | /** |
@@ -917,8 +972,11 @@ discard block |
||
| 917 | 972 | return array(); |
| 918 | 973 | } |
| 919 | 974 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 920 | - if (count($row) > 0) return $row; |
|
| 921 | - else return array(); |
|
| 975 | + if (count($row) > 0) { |
|
| 976 | + return $row; |
|
| 977 | + } else { |
|
| 978 | + return array(); |
|
| 979 | + } |
|
| 922 | 980 | } |
| 923 | 981 | |
| 924 | 982 | /** |
@@ -938,8 +996,11 @@ discard block |
||
| 938 | 996 | return array(); |
| 939 | 997 | } |
| 940 | 998 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 941 | - if (count($row) > 0) return $row[0]; |
|
| 942 | - else return array(); |
|
| 999 | + if (count($row) > 0) { |
|
| 1000 | + return $row[0]; |
|
| 1001 | + } else { |
|
| 1002 | + return array(); |
|
| 1003 | + } |
|
| 943 | 1004 | } |
| 944 | 1005 | |
| 945 | 1006 | /** |
@@ -987,19 +1048,35 @@ discard block |
||
| 987 | 1048 | if ($row['registration'] != '') { |
| 988 | 1049 | $row['registration'] = str_replace('.','',$row['registration']); |
| 989 | 1050 | $image_array = $Image->getSpotterImage($row['registration']); |
| 990 | - 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'])); |
|
| 991 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 992 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 993 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 994 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1051 | + if (count($image_array) > 0) { |
|
| 1052 | + $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'])); |
|
| 1053 | + } else { |
|
| 1054 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1055 | + } |
|
| 1056 | + } else { |
|
| 1057 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1058 | + } |
|
| 1059 | + if ($row['registration'] == '') { |
|
| 1060 | + $row['registration'] = 'NA'; |
|
| 1061 | + } |
|
| 1062 | + if ($row['ident'] == '') { |
|
| 1063 | + $row['ident'] = 'NA'; |
|
| 1064 | + } |
|
| 995 | 1065 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 996 | 1066 | if (isset($identicao[0])) { |
| 997 | 1067 | if (substr($row['ident'],0,2) == 'AF') { |
| 998 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 999 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1000 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1068 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1069 | + $icao = $row['ident']; |
|
| 1070 | + } else { |
|
| 1071 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1072 | + } |
|
| 1073 | + } else { |
|
| 1074 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1075 | + } |
|
| 1001 | 1076 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1002 | - } else $icao = $row['ident']; |
|
| 1077 | + } else { |
|
| 1078 | + $icao = $row['ident']; |
|
| 1079 | + } |
|
| 1003 | 1080 | $icao = $Translation->checkTranslation($icao,false); |
| 1004 | 1081 | $decode = json_decode($row['decode'],true); |
| 1005 | 1082 | $found = false; |
@@ -1024,7 +1101,9 @@ discard block |
||
| 1024 | 1101 | $found = true; |
| 1025 | 1102 | } |
| 1026 | 1103 | } |
| 1027 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1104 | + if ($found) { |
|
| 1105 | + $row['decode'] = json_encode($decode); |
|
| 1106 | + } |
|
| 1028 | 1107 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1029 | 1108 | $result[] = $data; |
| 1030 | 1109 | $i++; |
@@ -1032,8 +1111,9 @@ discard block |
||
| 1032 | 1111 | if (isset($result)) { |
| 1033 | 1112 | $result[0]['query_number_rows'] = $i; |
| 1034 | 1113 | return $result; |
| 1114 | + } else { |
|
| 1115 | + return array(); |
|
| 1035 | 1116 | } |
| 1036 | - else return array(); |
|
| 1037 | 1117 | } |
| 1038 | 1118 | |
| 1039 | 1119 | /** |
@@ -1086,31 +1166,51 @@ discard block |
||
| 1086 | 1166 | if ($row['registration'] != '') { |
| 1087 | 1167 | $row['registration'] = str_replace('.','',$row['registration']); |
| 1088 | 1168 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1089 | - 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'])); |
|
| 1090 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1091 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1169 | + if (count($image_array) > 0) { |
|
| 1170 | + $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'])); |
|
| 1171 | + } else { |
|
| 1172 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1173 | + } |
|
| 1174 | + } else { |
|
| 1175 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1176 | + } |
|
| 1092 | 1177 | $icao = ''; |
| 1093 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 1094 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1178 | + if ($row['registration'] == '') { |
|
| 1179 | + $row['registration'] = 'NA'; |
|
| 1180 | + } |
|
| 1181 | + if ($row['ident'] == '') { |
|
| 1182 | + $row['ident'] = 'NA'; |
|
| 1183 | + } |
|
| 1095 | 1184 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 1096 | 1185 | if (isset($identicao[0])) { |
| 1097 | 1186 | if (substr($row['ident'],0,2) == 'AF') { |
| 1098 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1099 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1100 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1187 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1188 | + $icao = $row['ident']; |
|
| 1189 | + } else { |
|
| 1190 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1191 | + } |
|
| 1192 | + } else { |
|
| 1193 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1194 | + } |
|
| 1101 | 1195 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1102 | - } else $icao = $row['ident']; |
|
| 1196 | + } else { |
|
| 1197 | + $icao = $row['ident']; |
|
| 1198 | + } |
|
| 1103 | 1199 | $icao = $Translation->checkTranslation($icao); |
| 1104 | 1200 | $decode = json_decode($row['decode'],true); |
| 1105 | 1201 | $found = false; |
| 1106 | 1202 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
| 1107 | 1203 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1108 | - 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>'; |
|
| 1204 | + if (isset($airport_info[0]['icao'])) { |
|
| 1205 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1206 | + } |
|
| 1109 | 1207 | $found = true; |
| 1110 | 1208 | } |
| 1111 | 1209 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
| 1112 | 1210 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1113 | - 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>'; |
|
| 1211 | + if (isset($airport_info[0]['icao'])) { |
|
| 1212 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1213 | + } |
|
| 1114 | 1214 | $found = true; |
| 1115 | 1215 | } |
| 1116 | 1216 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1120,7 +1220,9 @@ discard block |
||
| 1120 | 1220 | $found = true; |
| 1121 | 1221 | } |
| 1122 | 1222 | } |
| 1123 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1223 | + if ($found) { |
|
| 1224 | + $row['decode'] = json_encode($decode); |
|
| 1225 | + } |
|
| 1124 | 1226 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1125 | 1227 | $result[] = $data; |
| 1126 | 1228 | $i++; |
@@ -1128,7 +1230,9 @@ discard block |
||
| 1128 | 1230 | if (!empty($result)) { |
| 1129 | 1231 | $result[0]['query_number_rows'] = $i; |
| 1130 | 1232 | return $result; |
| 1131 | - } else return array(); |
|
| 1233 | + } else { |
|
| 1234 | + return array(); |
|
| 1235 | + } |
|
| 1132 | 1236 | } |
| 1133 | 1237 | |
| 1134 | 1238 | /** |
@@ -1147,25 +1251,37 @@ discard block |
||
| 1147 | 1251 | $ident = trim($ident); |
| 1148 | 1252 | $Translation = new Translation($this->db); |
| 1149 | 1253 | $Spotter = new Spotter($this->db); |
| 1150 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
| 1254 | + if ($globalDebug) { |
|
| 1255 | + echo "Test if we add ModeS data..."; |
|
| 1256 | + } |
|
| 1151 | 1257 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
| 1152 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
| 1153 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
| 1258 | + if ($icao == '') { |
|
| 1259 | + $icao = $Translation->checkTranslation($ident); |
|
| 1260 | + } |
|
| 1261 | + if ($globalDebug) { |
|
| 1262 | + echo '- Ident : '.$icao.' - '; |
|
| 1263 | + } |
|
| 1154 | 1264 | if ($ident == '' || $registration == '') { |
| 1155 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
| 1265 | + if ($globalDebug) { |
|
| 1266 | + echo "Ident or registration null, exit\n"; |
|
| 1267 | + } |
|
| 1156 | 1268 | return ''; |
| 1157 | 1269 | } |
| 1158 | 1270 | $registration = str_replace('.','',$registration); |
| 1159 | 1271 | $ident = $Translation->ident2icao($ident); |
| 1160 | 1272 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1161 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
| 1273 | + if ($globalDebug) { |
|
| 1274 | + echo "Check if needed to add translation ".$ident.'... '; |
|
| 1275 | + } |
|
| 1162 | 1276 | $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"; |
| 1163 | 1277 | $querysi_values = array(':registration' => $registration); |
| 1164 | 1278 | try { |
| 1165 | 1279 | $sthsi = $this->db->prepare($querysi); |
| 1166 | 1280 | $sthsi->execute($querysi_values); |
| 1167 | 1281 | } catch(PDOException $e) { |
| 1168 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1282 | + if ($globalDebug) { |
|
| 1283 | + echo $e->getMessage(); |
|
| 1284 | + } |
|
| 1169 | 1285 | return "error : ".$e->getMessage(); |
| 1170 | 1286 | } |
| 1171 | 1287 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1173,9 +1289,14 @@ discard block |
||
| 1173 | 1289 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
| 1174 | 1290 | $Translation = new Translation($this->db); |
| 1175 | 1291 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1176 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1177 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1178 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1292 | + if ($globalDebug) { |
|
| 1293 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1294 | + } |
|
| 1295 | + if ($ident != $trans_ident) { |
|
| 1296 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1297 | + } elseif ($trans_ident == $ident) { |
|
| 1298 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1299 | + } |
|
| 1179 | 1300 | } else { |
| 1180 | 1301 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1181 | 1302 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1184,32 +1305,46 @@ discard block |
||
| 1184 | 1305 | $sth = $this->db->prepare($query); |
| 1185 | 1306 | $sth->execute($query_values); |
| 1186 | 1307 | } catch(PDOException $e) { |
| 1187 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1308 | + if ($globalDebug) { |
|
| 1309 | + echo $e->getMessage(); |
|
| 1310 | + } |
|
| 1188 | 1311 | return "error : ".$e->getMessage(); |
| 1189 | 1312 | } |
| 1190 | 1313 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1191 | 1314 | $sth->closeCursor(); |
| 1192 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
| 1193 | - else $hex = ''; |
|
| 1315 | + if (isset($result['modes'])) { |
|
| 1316 | + $hex = $result['modes']; |
|
| 1317 | + } else { |
|
| 1318 | + $hex = ''; |
|
| 1319 | + } |
|
| 1194 | 1320 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
| 1195 | - if ($this->fromACARSscript) $this->SI->add($SI_data); |
|
| 1321 | + if ($this->fromACARSscript) { |
|
| 1322 | + $this->SI->add($SI_data); |
|
| 1323 | + } |
|
| 1196 | 1324 | } |
| 1197 | 1325 | } |
| 1198 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1326 | + if ($globalDebug) { |
|
| 1327 | + echo 'Done'."\n"; |
|
| 1328 | + } |
|
| 1199 | 1329 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
| 1200 | 1330 | $query_values = array(':ident' => $icao); |
| 1201 | 1331 | try { |
| 1202 | 1332 | $sth = $this->db->prepare($query); |
| 1203 | 1333 | $sth->execute($query_values); |
| 1204 | 1334 | } catch(PDOException $e) { |
| 1205 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1335 | + if ($globalDebug) { |
|
| 1336 | + echo $e->getMessage(); |
|
| 1337 | + } |
|
| 1206 | 1338 | return "error : ".$e->getMessage(); |
| 1207 | 1339 | } |
| 1208 | 1340 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1209 | 1341 | $sth->closeCursor(); |
| 1210 | 1342 | if (isset($result['flightaware_id'])) { |
| 1211 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
| 1212 | - else $ModeS = ''; |
|
| 1343 | + if (isset($result['ModeS'])) { |
|
| 1344 | + $ModeS = $result['ModeS']; |
|
| 1345 | + } else { |
|
| 1346 | + $ModeS = ''; |
|
| 1347 | + } |
|
| 1213 | 1348 | if ($ModeS == '') { |
| 1214 | 1349 | $id = explode('-',$result['flightaware_id']); |
| 1215 | 1350 | $ModeS = $id[0]; |
@@ -1222,24 +1357,32 @@ discard block |
||
| 1222 | 1357 | $sthc = $this->db->prepare($queryc); |
| 1223 | 1358 | $sthc->execute($queryc_values); |
| 1224 | 1359 | } catch(PDOException $e) { |
| 1225 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1360 | + if ($globalDebug) { |
|
| 1361 | + echo $e->getMessage(); |
|
| 1362 | + } |
|
| 1226 | 1363 | return "error : ".$e->getMessage(); |
| 1227 | 1364 | } |
| 1228 | 1365 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1229 | 1366 | $sthc->closeCursor(); |
| 1230 | 1367 | if (count($row) == 0) { |
| 1231 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
| 1368 | + if ($globalDebug) { |
|
| 1369 | + echo " Add to ModeS table - "; |
|
| 1370 | + } |
|
| 1232 | 1371 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1233 | 1372 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
| 1234 | 1373 | try { |
| 1235 | 1374 | $sthi = $this->db->prepare($queryi); |
| 1236 | 1375 | $sthi->execute($queryi_values); |
| 1237 | 1376 | } catch(PDOException $e) { |
| 1238 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1377 | + if ($globalDebug) { |
|
| 1378 | + echo $e->getMessage(); |
|
| 1379 | + } |
|
| 1239 | 1380 | return "error : ".$e->getMessage(); |
| 1240 | 1381 | } |
| 1241 | 1382 | } else { |
| 1242 | - if ($globalDebug) echo " Update ModeS table - "; |
|
| 1383 | + if ($globalDebug) { |
|
| 1384 | + echo " Update ModeS table - "; |
|
| 1385 | + } |
|
| 1243 | 1386 | if ($ICAOTypeCode != '') { |
| 1244 | 1387 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1245 | 1388 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1251,7 +1394,9 @@ discard block |
||
| 1251 | 1394 | $sthi = $this->db->prepare($queryi); |
| 1252 | 1395 | $sthi->execute($queryi_values); |
| 1253 | 1396 | } catch(PDOException $e) { |
| 1254 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1397 | + if ($globalDebug) { |
|
| 1398 | + echo $e->getMessage(); |
|
| 1399 | + } |
|
| 1255 | 1400 | return "error : ".$e->getMessage(); |
| 1256 | 1401 | } |
| 1257 | 1402 | } |
@@ -1272,7 +1417,9 @@ discard block |
||
| 1272 | 1417 | return "error : ".$e->getMessage(); |
| 1273 | 1418 | } |
| 1274 | 1419 | */ |
| 1275 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
| 1420 | + if ($globalDebug) { |
|
| 1421 | + echo " Update Spotter_output table - "; |
|
| 1422 | + } |
|
| 1276 | 1423 | if ($ICAOTypeCode != '') { |
| 1277 | 1424 | if ($globalDBdriver == 'mysql') { |
| 1278 | 1425 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1283,8 +1430,7 @@ discard block |
||
| 1283 | 1430 | } else { |
| 1284 | 1431 | if ($globalDBdriver == 'mysql') { |
| 1285 | 1432 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
| 1286 | - } |
|
| 1287 | - elseif ($globalDBdriver == 'pgsql') { |
|
| 1433 | + } elseif ($globalDBdriver == 'pgsql') { |
|
| 1288 | 1434 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1289 | 1435 | } |
| 1290 | 1436 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1293,14 +1439,20 @@ discard block |
||
| 1293 | 1439 | $sthi = $this->db->prepare($queryi); |
| 1294 | 1440 | $sthi->execute($queryi_values); |
| 1295 | 1441 | } catch(PDOException $e) { |
| 1296 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1442 | + if ($globalDebug) { |
|
| 1443 | + echo $e->getMessage(); |
|
| 1444 | + } |
|
| 1297 | 1445 | return "error : ".$e->getMessage(); |
| 1298 | 1446 | } |
| 1299 | 1447 | } |
| 1300 | 1448 | } else { |
| 1301 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
| 1449 | + if ($globalDebug) { |
|
| 1450 | + echo " Can't find ModeS in spotter_output - "; |
|
| 1451 | + } |
|
| 1452 | + } |
|
| 1453 | + if ($globalDebug) { |
|
| 1454 | + echo "Done\n"; |
|
| 1302 | 1455 | } |
| 1303 | - if ($globalDebug) echo "Done\n"; |
|
| 1304 | 1456 | return ''; |
| 1305 | 1457 | } |
| 1306 | 1458 | } |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 37 | 37 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 38 | 38 | curl_setopt($ch, CURLOPT_TIMEOUT, 200); |
| 39 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 39 | + if ($referer != '') { |
|
| 40 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 41 | + } |
|
| 40 | 42 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 41 | 43 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 42 | 44 | curl_exec($ch); |
@@ -47,12 +49,16 @@ discard block |
||
| 47 | 49 | public static function gunzip($in_file,$out_file_name = '') { |
| 48 | 50 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 49 | 51 | $buffer_size = 4096; // read 4kb at a time |
| 50 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 52 | + if ($out_file_name == '') { |
|
| 53 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 54 | + } |
|
| 51 | 55 | if ($in_file != '' && file_exists($in_file)) { |
| 52 | 56 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 53 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 54 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 55 | - else { |
|
| 57 | + if (function_exists('gzopen')) { |
|
| 58 | + $file = gzopen($in_file,'rb'); |
|
| 59 | + } elseif (function_exists('gzopen64')) { |
|
| 60 | + $file = gzopen64($in_file,'rb'); |
|
| 61 | + } else { |
|
| 56 | 62 | echo 'gzopen not available'; |
| 57 | 63 | die; |
| 58 | 64 | } |
@@ -73,8 +79,12 @@ discard block |
||
| 73 | 79 | if ($res === TRUE) { |
| 74 | 80 | $zip->extractTo($path); |
| 75 | 81 | $zip->close(); |
| 76 | - } else return false; |
|
| 77 | - } else return false; |
|
| 82 | + } else { |
|
| 83 | + return false; |
|
| 84 | + } |
|
| 85 | + } else { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 78 | 88 | } |
| 79 | 89 | |
| 80 | 90 | public static function connect_sqlite($database) { |
@@ -89,7 +99,9 @@ discard block |
||
| 89 | 99 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 90 | 100 | global $globalDebug, $globalTransaction; |
| 91 | 101 | //$query = 'TRUNCATE TABLE routes'; |
| 92 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 102 | + if ($globalDebug) { |
|
| 103 | + echo " - Delete previous routes from DB -"; |
|
| 104 | + } |
|
| 93 | 105 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 94 | 106 | $Connection = new Connection(); |
| 95 | 107 | try { |
@@ -100,7 +112,9 @@ discard block |
||
| 100 | 112 | return "error : ".$e->getMessage(); |
| 101 | 113 | } |
| 102 | 114 | |
| 103 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 115 | + if ($globalDebug) { |
|
| 116 | + echo " - Add routes to DB -"; |
|
| 117 | + } |
|
| 104 | 118 | update_db::connect_sqlite($database_file); |
| 105 | 119 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 106 | 120 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -115,15 +129,21 @@ discard block |
||
| 115 | 129 | $Connection = new Connection(); |
| 116 | 130 | $sth_dest = $Connection->db->prepare($query_dest); |
| 117 | 131 | try { |
| 118 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 132 | + if ($globalTransaction) { |
|
| 133 | + $Connection->db->beginTransaction(); |
|
| 134 | + } |
|
| 119 | 135 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 120 | 136 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 121 | 137 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 122 | 138 | $sth_dest->execute($query_dest_values); |
| 123 | 139 | } |
| 124 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 140 | + if ($globalTransaction) { |
|
| 141 | + $Connection->db->commit(); |
|
| 142 | + } |
|
| 125 | 143 | } catch(PDOException $e) { |
| 126 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 144 | + if ($globalTransaction) { |
|
| 145 | + $Connection->db->rollBack(); |
|
| 146 | + } |
|
| 127 | 147 | return "error : ".$e->getMessage(); |
| 128 | 148 | } |
| 129 | 149 | return ''; |
@@ -131,7 +151,9 @@ discard block |
||
| 131 | 151 | public static function retrieve_route_oneworld($database_file) { |
| 132 | 152 | global $globalDebug, $globalTransaction; |
| 133 | 153 | //$query = 'TRUNCATE TABLE routes'; |
| 134 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 154 | + if ($globalDebug) { |
|
| 155 | + echo " - Delete previous routes from DB -"; |
|
| 156 | + } |
|
| 135 | 157 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 136 | 158 | $Connection = new Connection(); |
| 137 | 159 | try { |
@@ -142,14 +164,18 @@ discard block |
||
| 142 | 164 | return "error : ".$e->getMessage(); |
| 143 | 165 | } |
| 144 | 166 | |
| 145 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 167 | + if ($globalDebug) { |
|
| 168 | + echo " - Add routes to DB -"; |
|
| 169 | + } |
|
| 146 | 170 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 147 | 171 | $Spotter = new Spotter(); |
| 148 | 172 | if ($fh = fopen($database_file,"r")) { |
| 149 | 173 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 150 | 174 | $Connection = new Connection(); |
| 151 | 175 | $sth_dest = $Connection->db->prepare($query_dest); |
| 152 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 176 | + if ($globalTransaction) { |
|
| 177 | + $Connection->db->beginTransaction(); |
|
| 178 | + } |
|
| 153 | 179 | while (!feof($fh)) { |
| 154 | 180 | $line = fgetcsv($fh,9999,','); |
| 155 | 181 | if ($line[0] != '') { |
@@ -158,13 +184,17 @@ discard block |
||
| 158 | 184 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
| 159 | 185 | $sth_dest->execute($query_dest_values); |
| 160 | 186 | } catch(PDOException $e) { |
| 161 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 187 | + if ($globalTransaction) { |
|
| 188 | + $Connection->db->rollBack(); |
|
| 189 | + } |
|
| 162 | 190 | return "error : ".$e->getMessage(); |
| 163 | 191 | } |
| 164 | 192 | } |
| 165 | 193 | } |
| 166 | 194 | } |
| 167 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 195 | + if ($globalTransaction) { |
|
| 196 | + $Connection->db->commit(); |
|
| 197 | + } |
|
| 168 | 198 | } |
| 169 | 199 | return ''; |
| 170 | 200 | } |
@@ -172,7 +202,9 @@ discard block |
||
| 172 | 202 | public static function retrieve_route_skyteam($database_file) { |
| 173 | 203 | global $globalDebug, $globalTransaction; |
| 174 | 204 | //$query = 'TRUNCATE TABLE routes'; |
| 175 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 205 | + if ($globalDebug) { |
|
| 206 | + echo " - Delete previous routes from DB -"; |
|
| 207 | + } |
|
| 176 | 208 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 177 | 209 | $Connection = new Connection(); |
| 178 | 210 | try { |
@@ -183,7 +215,9 @@ discard block |
||
| 183 | 215 | return "error : ".$e->getMessage(); |
| 184 | 216 | } |
| 185 | 217 | |
| 186 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 218 | + if ($globalDebug) { |
|
| 219 | + echo " - Add routes to DB -"; |
|
| 220 | + } |
|
| 187 | 221 | |
| 188 | 222 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 189 | 223 | $Spotter = new Spotter(); |
@@ -192,7 +226,9 @@ discard block |
||
| 192 | 226 | $Connection = new Connection(); |
| 193 | 227 | $sth_dest = $Connection->db->prepare($query_dest); |
| 194 | 228 | try { |
| 195 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 229 | + if ($globalTransaction) { |
|
| 230 | + $Connection->db->beginTransaction(); |
|
| 231 | + } |
|
| 196 | 232 | while (!feof($fh)) { |
| 197 | 233 | $line = fgetcsv($fh,9999,','); |
| 198 | 234 | if ($line[0] != '') { |
@@ -203,9 +239,13 @@ discard block |
||
| 203 | 239 | } |
| 204 | 240 | } |
| 205 | 241 | } |
| 206 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 242 | + if ($globalTransaction) { |
|
| 243 | + $Connection->db->commit(); |
|
| 244 | + } |
|
| 207 | 245 | } catch(PDOException $e) { |
| 208 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 246 | + if ($globalTransaction) { |
|
| 247 | + $Connection->db->rollBack(); |
|
| 248 | + } |
|
| 209 | 249 | return "error : ".$e->getMessage(); |
| 210 | 250 | } |
| 211 | 251 | } |
@@ -248,11 +288,16 @@ discard block |
||
| 248 | 288 | $sth_dest = $Connection->db->prepare($query_dest); |
| 249 | 289 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 250 | 290 | try { |
| 251 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 291 | + if ($globalTransaction) { |
|
| 292 | + $Connection->db->beginTransaction(); |
|
| 293 | + } |
|
| 252 | 294 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 253 | 295 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 254 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 255 | - else $type = null; |
|
| 296 | + if ($values['UserString4'] == 'M') { |
|
| 297 | + $type = 'military'; |
|
| 298 | + } else { |
|
| 299 | + $type = null; |
|
| 300 | + } |
|
| 256 | 301 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 257 | 302 | $sth_dest->execute($query_dest_values); |
| 258 | 303 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -260,7 +305,9 @@ discard block |
||
| 260 | 305 | $sth_dest_owner->execute($query_dest_owner_values); |
| 261 | 306 | } |
| 262 | 307 | } |
| 263 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 308 | + if ($globalTransaction) { |
|
| 309 | + $Connection->db->commit(); |
|
| 310 | + } |
|
| 264 | 311 | } catch(PDOException $e) { |
| 265 | 312 | return "error : ".$e->getMessage(); |
| 266 | 313 | } |
@@ -297,7 +344,9 @@ discard block |
||
| 297 | 344 | $Connection = new Connection(); |
| 298 | 345 | $sth_dest = $Connection->db->prepare($query_dest); |
| 299 | 346 | try { |
| 300 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 347 | + if ($globalTransaction) { |
|
| 348 | + $Connection->db->beginTransaction(); |
|
| 349 | + } |
|
| 301 | 350 | while (!feof($fh)) { |
| 302 | 351 | $values = array(); |
| 303 | 352 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -308,7 +357,9 @@ discard block |
||
| 308 | 357 | // Check if we can find ICAO, else set it to GLID |
| 309 | 358 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 310 | 359 | $search_more = ''; |
| 311 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 360 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 361 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 362 | + } |
|
| 312 | 363 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 313 | 364 | $sth_search = $Connection->db->prepare($query_search); |
| 314 | 365 | try { |
@@ -321,7 +372,9 @@ discard block |
||
| 321 | 372 | } catch(PDOException $e) { |
| 322 | 373 | return "error : ".$e->getMessage(); |
| 323 | 374 | } |
| 324 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 375 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 376 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 377 | + } |
|
| 325 | 378 | // Add data to db |
| 326 | 379 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 327 | 380 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -330,7 +383,9 @@ discard block |
||
| 330 | 383 | $sth_dest->execute($query_dest_values); |
| 331 | 384 | } |
| 332 | 385 | } |
| 333 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 386 | + if ($globalTransaction) { |
|
| 387 | + $Connection->db->commit(); |
|
| 388 | + } |
|
| 334 | 389 | } catch(PDOException $e) { |
| 335 | 390 | return "error : ".$e->getMessage(); |
| 336 | 391 | } |
@@ -366,7 +421,9 @@ discard block |
||
| 366 | 421 | $Connection = new Connection(); |
| 367 | 422 | $sth_dest = $Connection->db->prepare($query_dest); |
| 368 | 423 | try { |
| 369 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 424 | + if ($globalTransaction) { |
|
| 425 | + $Connection->db->beginTransaction(); |
|
| 426 | + } |
|
| 370 | 427 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 371 | 428 | while (!feof($fh)) { |
| 372 | 429 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -380,13 +437,17 @@ discard block |
||
| 380 | 437 | // Check if we can find ICAO, else set it to GLID |
| 381 | 438 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 382 | 439 | $search_more = ''; |
| 383 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 440 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 441 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 442 | + } |
|
| 384 | 443 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 385 | 444 | $sth_search = $Connection->db->prepare($query_search); |
| 386 | 445 | try { |
| 387 | 446 | $sth_search->execute(); |
| 388 | 447 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 389 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 448 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 449 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 450 | + } |
|
| 390 | 451 | } catch(PDOException $e) { |
| 391 | 452 | return "error : ".$e->getMessage(); |
| 392 | 453 | } |
@@ -399,7 +460,9 @@ discard block |
||
| 399 | 460 | $sth_dest->execute($query_dest_values); |
| 400 | 461 | } |
| 401 | 462 | } |
| 402 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 463 | + if ($globalTransaction) { |
|
| 464 | + $Connection->db->commit(); |
|
| 465 | + } |
|
| 403 | 466 | } catch(PDOException $e) { |
| 404 | 467 | return "error : ".$e->getMessage(); |
| 405 | 468 | } |
@@ -438,7 +501,9 @@ discard block |
||
| 438 | 501 | $sth_dest = $Connection->db->prepare($query_dest); |
| 439 | 502 | $sth_modes = $Connection->db->prepare($query_modes); |
| 440 | 503 | try { |
| 441 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 504 | + if ($globalTransaction) { |
|
| 505 | + $Connection->db->beginTransaction(); |
|
| 506 | + } |
|
| 442 | 507 | $tmp = fgetcsv($fh,9999,',','"'); |
| 443 | 508 | while (!feof($fh)) { |
| 444 | 509 | $line = fgetcsv($fh,9999,',','"'); |
@@ -448,16 +513,22 @@ discard block |
||
| 448 | 513 | $values['registration'] = $line[0]; |
| 449 | 514 | $values['base'] = $line[4]; |
| 450 | 515 | $values['owner'] = $line[5]; |
| 451 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 452 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 516 | + if ($line[6] == '') { |
|
| 517 | + $values['date_first_reg'] = null; |
|
| 518 | + } else { |
|
| 519 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 520 | + } |
|
| 453 | 521 | $values['cancel'] = $line[7]; |
| 454 | 522 | } elseif ($country == 'EI') { |
| 455 | 523 | // TODO : add modeS & reg to aircraft_modes |
| 456 | 524 | $values['registration'] = $line[0]; |
| 457 | 525 | $values['base'] = $line[3]; |
| 458 | 526 | $values['owner'] = $line[2]; |
| 459 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 460 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 527 | + if ($line[1] == '') { |
|
| 528 | + $values['date_first_reg'] = null; |
|
| 529 | + } else { |
|
| 530 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 531 | + } |
|
| 461 | 532 | $values['cancel'] = ''; |
| 462 | 533 | $values['modes'] = $line[7]; |
| 463 | 534 | $values['icao'] = $line[8]; |
@@ -476,16 +547,22 @@ discard block |
||
| 476 | 547 | $values['registration'] = $line[3]; |
| 477 | 548 | $values['base'] = null; |
| 478 | 549 | $values['owner'] = $line[5]; |
| 479 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 480 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 550 | + if ($line[18] == '') { |
|
| 551 | + $values['date_first_reg'] = null; |
|
| 552 | + } else { |
|
| 553 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 554 | + } |
|
| 481 | 555 | $values['cancel'] = ''; |
| 482 | 556 | } elseif ($country == 'VH') { |
| 483 | 557 | // TODO : add modeS & reg to aircraft_modes |
| 484 | 558 | $values['registration'] = $line[0]; |
| 485 | 559 | $values['base'] = null; |
| 486 | 560 | $values['owner'] = $line[12]; |
| 487 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 488 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 561 | + if ($line[28] == '') { |
|
| 562 | + $values['date_first_reg'] = null; |
|
| 563 | + } else { |
|
| 564 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 565 | + } |
|
| 489 | 566 | |
| 490 | 567 | $values['cancel'] = $line[39]; |
| 491 | 568 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -504,29 +581,41 @@ discard block |
||
| 504 | 581 | $values['registration'] = $line[0]; |
| 505 | 582 | $values['base'] = null; |
| 506 | 583 | $values['owner'] = $line[8]; |
| 507 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 508 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 584 | + if ($line[7] == '') { |
|
| 585 | + $values['date_first_reg'] = null; |
|
| 586 | + } else { |
|
| 587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 588 | + } |
|
| 509 | 589 | $values['cancel'] = ''; |
| 510 | 590 | } elseif ($country == 'PP') { |
| 511 | 591 | $values['registration'] = $line[0]; |
| 512 | 592 | $values['base'] = null; |
| 513 | 593 | $values['owner'] = $line[4]; |
| 514 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 515 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 594 | + if ($line[6] == '') { |
|
| 595 | + $values['date_first_reg'] = null; |
|
| 596 | + } else { |
|
| 597 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 598 | + } |
|
| 516 | 599 | $values['cancel'] = $line[7]; |
| 517 | 600 | } elseif ($country == 'E7') { |
| 518 | 601 | $values['registration'] = $line[0]; |
| 519 | 602 | $values['base'] = null; |
| 520 | 603 | $values['owner'] = $line[4]; |
| 521 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 522 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 604 | + if ($line[5] == '') { |
|
| 605 | + $values['date_first_reg'] = null; |
|
| 606 | + } else { |
|
| 607 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 608 | + } |
|
| 523 | 609 | $values['cancel'] = ''; |
| 524 | 610 | } elseif ($country == '8Q') { |
| 525 | 611 | $values['registration'] = $line[0]; |
| 526 | 612 | $values['base'] = null; |
| 527 | 613 | $values['owner'] = $line[3]; |
| 528 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 529 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 614 | + if ($line[7] == '') { |
|
| 615 | + $values['date_first_reg'] = null; |
|
| 616 | + } else { |
|
| 617 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 618 | + } |
|
| 530 | 619 | $values['cancel'] = ''; |
| 531 | 620 | } elseif ($country == 'ZK') { |
| 532 | 621 | $values['registration'] = $line[0]; |
@@ -571,7 +660,9 @@ discard block |
||
| 571 | 660 | $sth_modes->execute($query_modes_values); |
| 572 | 661 | } |
| 573 | 662 | } |
| 574 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 663 | + if ($globalTransaction) { |
|
| 664 | + $Connection->db->commit(); |
|
| 665 | + } |
|
| 575 | 666 | } catch(PDOException $e) { |
| 576 | 667 | return "error : ".$e->getMessage(); |
| 577 | 668 | } |
@@ -707,25 +798,45 @@ discard block |
||
| 707 | 798 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 708 | 799 | $Connection = new Connection(); |
| 709 | 800 | $sth_dest = $Connection->db->prepare($query_dest); |
| 710 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 801 | + if ($globalTransaction) { |
|
| 802 | + $Connection->db->beginTransaction(); |
|
| 803 | + } |
|
| 711 | 804 | |
| 712 | 805 | $i = 0; |
| 713 | 806 | while($row = sparql_fetch_array($result)) |
| 714 | 807 | { |
| 715 | 808 | if ($i >= 1) { |
| 716 | 809 | //print_r($row); |
| 717 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 718 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 719 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 720 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 810 | + if (!isset($row['iata'])) { |
|
| 811 | + $row['iata'] = ''; |
|
| 812 | + } |
|
| 813 | + if (!isset($row['icao'])) { |
|
| 814 | + $row['icao'] = ''; |
|
| 815 | + } |
|
| 816 | + if (!isset($row['type'])) { |
|
| 817 | + $row['type'] = ''; |
|
| 818 | + } |
|
| 819 | + if (!isset($row['altitude'])) { |
|
| 820 | + $row['altitude'] = ''; |
|
| 821 | + } |
|
| 721 | 822 | if (isset($row['city_bis'])) { |
| 722 | 823 | $row['city'] = $row['city_bis']; |
| 723 | 824 | } |
| 724 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 725 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 726 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 727 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 728 | - if (!isset($row['name'])) continue; |
|
| 825 | + if (!isset($row['city'])) { |
|
| 826 | + $row['city'] = ''; |
|
| 827 | + } |
|
| 828 | + if (!isset($row['country'])) { |
|
| 829 | + $row['country'] = ''; |
|
| 830 | + } |
|
| 831 | + if (!isset($row['homepage'])) { |
|
| 832 | + $row['homepage'] = ''; |
|
| 833 | + } |
|
| 834 | + if (!isset($row['wikipedia_page'])) { |
|
| 835 | + $row['wikipedia_page'] = ''; |
|
| 836 | + } |
|
| 837 | + if (!isset($row['name'])) { |
|
| 838 | + continue; |
|
| 839 | + } |
|
| 729 | 840 | if (!isset($row['image'])) { |
| 730 | 841 | $row['image'] = ''; |
| 731 | 842 | $row['image_thumb'] = ''; |
@@ -781,7 +892,9 @@ discard block |
||
| 781 | 892 | |
| 782 | 893 | $i++; |
| 783 | 894 | } |
| 784 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 895 | + if ($globalTransaction) { |
|
| 896 | + $Connection->db->commit(); |
|
| 897 | + } |
|
| 785 | 898 | /* |
| 786 | 899 | echo "Delete duplicate rows...\n"; |
| 787 | 900 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -824,7 +937,9 @@ discard block |
||
| 824 | 937 | $delimiter = ','; |
| 825 | 938 | $out_file = $tmp_dir.'airports.csv'; |
| 826 | 939 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 827 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 940 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 941 | + return FALSE; |
|
| 942 | + } |
|
| 828 | 943 | echo "Add data from ourairports.com...\n"; |
| 829 | 944 | |
| 830 | 945 | $header = NULL; |
@@ -834,8 +949,9 @@ discard block |
||
| 834 | 949 | //$Connection->db->beginTransaction(); |
| 835 | 950 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 836 | 951 | { |
| 837 | - if(!$header) $header = $row; |
|
| 838 | - else { |
|
| 952 | + if(!$header) { |
|
| 953 | + $header = $row; |
|
| 954 | + } else { |
|
| 839 | 955 | $data = array(); |
| 840 | 956 | $data = array_combine($header, $row); |
| 841 | 957 | try { |
@@ -876,7 +992,9 @@ discard block |
||
| 876 | 992 | echo "Download data from another free database...\n"; |
| 877 | 993 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 878 | 994 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 879 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 995 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 996 | + return FALSE; |
|
| 997 | + } |
|
| 880 | 998 | update_db::unzip($out_file); |
| 881 | 999 | $header = NULL; |
| 882 | 1000 | echo "Add data from another free database...\n"; |
@@ -887,8 +1005,9 @@ discard block |
||
| 887 | 1005 | //$Connection->db->beginTransaction(); |
| 888 | 1006 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 889 | 1007 | { |
| 890 | - if(!$header) $header = $row; |
|
| 891 | - else { |
|
| 1008 | + if(!$header) { |
|
| 1009 | + $header = $row; |
|
| 1010 | + } else { |
|
| 892 | 1011 | $data = $row; |
| 893 | 1012 | |
| 894 | 1013 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1082,7 +1201,9 @@ discard block |
||
| 1082 | 1201 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
| 1083 | 1202 | { |
| 1084 | 1203 | $i = 0; |
| 1085 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1204 | + if ($globalTransaction) { |
|
| 1205 | + $Connection->db->beginTransaction(); |
|
| 1206 | + } |
|
| 1086 | 1207 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1087 | 1208 | { |
| 1088 | 1209 | if ($i > 0) { |
@@ -1095,7 +1216,9 @@ discard block |
||
| 1095 | 1216 | } |
| 1096 | 1217 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
| 1097 | 1218 | if (!empty($result_search)) { |
| 1098 | - if ($globalDebug) echo '.'; |
|
| 1219 | + if ($globalDebug) { |
|
| 1220 | + echo '.'; |
|
| 1221 | + } |
|
| 1099 | 1222 | //if ($globalDBdriver == 'mysql') { |
| 1100 | 1223 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
| 1101 | 1224 | //} else { |
@@ -1117,8 +1240,12 @@ discard block |
||
| 1117 | 1240 | } |
| 1118 | 1241 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
| 1119 | 1242 | if (!empty($result_search_mfr)) { |
| 1120 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
| 1121 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
| 1243 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
| 1244 | + $data[16] = $data[23]; |
|
| 1245 | + } |
|
| 1246 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
| 1247 | + $data[16] = $data[15]; |
|
| 1248 | + } |
|
| 1122 | 1249 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1123 | 1250 | try { |
| 1124 | 1251 | $sthf = $Connection->db->prepare($queryf); |
@@ -1129,7 +1256,9 @@ discard block |
||
| 1129 | 1256 | } |
| 1130 | 1257 | } |
| 1131 | 1258 | if (strtotime($data[29]) > time()) { |
| 1132 | - if ($globalDebug) echo 'i'; |
|
| 1259 | + if ($globalDebug) { |
|
| 1260 | + echo 'i'; |
|
| 1261 | + } |
|
| 1133 | 1262 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1134 | 1263 | try { |
| 1135 | 1264 | $sth = $Connection->db->prepare($query); |
@@ -1140,13 +1269,19 @@ discard block |
||
| 1140 | 1269 | } |
| 1141 | 1270 | } |
| 1142 | 1271 | if ($i % 90 == 0) { |
| 1143 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1144 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1272 | + if ($globalTransaction) { |
|
| 1273 | + $Connection->db->commit(); |
|
| 1274 | + } |
|
| 1275 | + if ($globalTransaction) { |
|
| 1276 | + $Connection->db->beginTransaction(); |
|
| 1277 | + } |
|
| 1145 | 1278 | } |
| 1146 | 1279 | $i++; |
| 1147 | 1280 | } |
| 1148 | 1281 | fclose($handle); |
| 1149 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1282 | + if ($globalTransaction) { |
|
| 1283 | + $Connection->db->commit(); |
|
| 1284 | + } |
|
| 1150 | 1285 | } |
| 1151 | 1286 | return ''; |
| 1152 | 1287 | } |
@@ -1166,11 +1301,15 @@ discard block |
||
| 1166 | 1301 | if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) |
| 1167 | 1302 | { |
| 1168 | 1303 | $i = 0; |
| 1169 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1304 | + if ($globalTransaction) { |
|
| 1305 | + $Connection->db->beginTransaction(); |
|
| 1306 | + } |
|
| 1170 | 1307 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1171 | 1308 | { |
| 1172 | 1309 | if ($i > 0) { |
| 1173 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1310 | + if ($data[1] == 'NULL') { |
|
| 1311 | + $data[1] = $data[0]; |
|
| 1312 | + } |
|
| 1174 | 1313 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1175 | 1314 | try { |
| 1176 | 1315 | $sth = $Connection->db->prepare($query); |
@@ -1182,7 +1321,9 @@ discard block |
||
| 1182 | 1321 | $i++; |
| 1183 | 1322 | } |
| 1184 | 1323 | fclose($handle); |
| 1185 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1324 | + if ($globalTransaction) { |
|
| 1325 | + $Connection->db->commit(); |
|
| 1326 | + } |
|
| 1186 | 1327 | } |
| 1187 | 1328 | return ''; |
| 1188 | 1329 | } |
@@ -1214,11 +1355,15 @@ discard block |
||
| 1214 | 1355 | if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE) |
| 1215 | 1356 | { |
| 1216 | 1357 | $i = 0; |
| 1217 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1358 | + if ($globalTransaction) { |
|
| 1359 | + $Connection->db->beginTransaction(); |
|
| 1360 | + } |
|
| 1218 | 1361 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1219 | 1362 | { |
| 1220 | 1363 | if ($i > 0) { |
| 1221 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1364 | + if ($data[1] == 'NULL') { |
|
| 1365 | + $data[1] = $data[0]; |
|
| 1366 | + } |
|
| 1222 | 1367 | $query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)'; |
| 1223 | 1368 | try { |
| 1224 | 1369 | $sth = $Connection->db->prepare($query); |
@@ -1230,7 +1375,9 @@ discard block |
||
| 1230 | 1375 | $i++; |
| 1231 | 1376 | } |
| 1232 | 1377 | fclose($handle); |
| 1233 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1378 | + if ($globalTransaction) { |
|
| 1379 | + $Connection->db->commit(); |
|
| 1380 | + } |
|
| 1234 | 1381 | } |
| 1235 | 1382 | /* |
| 1236 | 1383 | $query = "UNLOCK TABLES"; |
@@ -1260,7 +1407,9 @@ discard block |
||
| 1260 | 1407 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
| 1261 | 1408 | { |
| 1262 | 1409 | $i = 0; |
| 1263 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1410 | + if ($globalTransaction) { |
|
| 1411 | + $Connection->db->beginTransaction(); |
|
| 1412 | + } |
|
| 1264 | 1413 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1265 | 1414 | { |
| 1266 | 1415 | if ($i > 0) { |
@@ -1276,7 +1425,9 @@ discard block |
||
| 1276 | 1425 | $i++; |
| 1277 | 1426 | } |
| 1278 | 1427 | fclose($handle); |
| 1279 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1428 | + if ($globalTransaction) { |
|
| 1429 | + $Connection->db->commit(); |
|
| 1430 | + } |
|
| 1280 | 1431 | } |
| 1281 | 1432 | return ''; |
| 1282 | 1433 | } |
@@ -1296,7 +1447,9 @@ discard block |
||
| 1296 | 1447 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
| 1297 | 1448 | { |
| 1298 | 1449 | $i = 0; |
| 1299 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1450 | + if ($globalTransaction) { |
|
| 1451 | + $Connection->db->beginTransaction(); |
|
| 1452 | + } |
|
| 1300 | 1453 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1301 | 1454 | { |
| 1302 | 1455 | if ($i > 0) { |
@@ -1306,19 +1459,25 @@ discard block |
||
| 1306 | 1459 | $sth = $Connection->db->prepare($query); |
| 1307 | 1460 | $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
| 1308 | 1461 | } catch(PDOException $e) { |
| 1309 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1462 | + if ($globalDebug) { |
|
| 1463 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1464 | + } |
|
| 1310 | 1465 | die(); |
| 1311 | 1466 | } |
| 1312 | 1467 | } |
| 1313 | 1468 | if ($globalTransaction && $i % 2000 == 0) { |
| 1314 | 1469 | $Connection->db->commit(); |
| 1315 | - if ($globalDebug) echo '.'; |
|
| 1470 | + if ($globalDebug) { |
|
| 1471 | + echo '.'; |
|
| 1472 | + } |
|
| 1316 | 1473 | $Connection->db->beginTransaction(); |
| 1317 | 1474 | } |
| 1318 | 1475 | $i++; |
| 1319 | 1476 | } |
| 1320 | 1477 | fclose($handle); |
| 1321 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1478 | + if ($globalTransaction) { |
|
| 1479 | + $Connection->db->commit(); |
|
| 1480 | + } |
|
| 1322 | 1481 | } |
| 1323 | 1482 | return ''; |
| 1324 | 1483 | } |
@@ -1337,7 +1496,9 @@ discard block |
||
| 1337 | 1496 | if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE) |
| 1338 | 1497 | { |
| 1339 | 1498 | $i = 0; |
| 1340 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1499 | + if ($globalTransaction) { |
|
| 1500 | + $Connection->db->beginTransaction(); |
|
| 1501 | + } |
|
| 1341 | 1502 | while (($data = fgets($handle, 1000)) !== FALSE) |
| 1342 | 1503 | { |
| 1343 | 1504 | $query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)'; |
@@ -1345,18 +1506,24 @@ discard block |
||
| 1345 | 1506 | $sth = $Connection->db->prepare($query); |
| 1346 | 1507 | $sth->execute(array(':callSign' => trim($data),':source' => 'website_fam')); |
| 1347 | 1508 | } catch(PDOException $e) { |
| 1348 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data; |
|
| 1509 | + if ($globalDebug) { |
|
| 1510 | + echo "error: ".$e->getMessage()." - data: ".$data; |
|
| 1511 | + } |
|
| 1349 | 1512 | die(); |
| 1350 | 1513 | } |
| 1351 | 1514 | if ($globalTransaction && $i % 2000 == 0) { |
| 1352 | 1515 | $Connection->db->commit(); |
| 1353 | - if ($globalDebug) echo '.'; |
|
| 1516 | + if ($globalDebug) { |
|
| 1517 | + echo '.'; |
|
| 1518 | + } |
|
| 1354 | 1519 | $Connection->db->beginTransaction(); |
| 1355 | 1520 | } |
| 1356 | 1521 | $i++; |
| 1357 | 1522 | } |
| 1358 | 1523 | fclose($handle); |
| 1359 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1524 | + if ($globalTransaction) { |
|
| 1525 | + $Connection->db->commit(); |
|
| 1526 | + } |
|
| 1360 | 1527 | } |
| 1361 | 1528 | return ''; |
| 1362 | 1529 | } |
@@ -1381,7 +1548,9 @@ discard block |
||
| 1381 | 1548 | $i = 0; |
| 1382 | 1549 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1383 | 1550 | //$Connection->db->beginTransaction(); |
| 1384 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1551 | + if ($globalTransaction) { |
|
| 1552 | + $Connection->db->beginTransaction(); |
|
| 1553 | + } |
|
| 1385 | 1554 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1386 | 1555 | { |
| 1387 | 1556 | if ($i > 0) { |
@@ -1397,7 +1566,9 @@ discard block |
||
| 1397 | 1566 | $i++; |
| 1398 | 1567 | } |
| 1399 | 1568 | fclose($handle); |
| 1400 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1569 | + if ($globalTransaction) { |
|
| 1570 | + $Connection->db->commit(); |
|
| 1571 | + } |
|
| 1401 | 1572 | } |
| 1402 | 1573 | return ''; |
| 1403 | 1574 | } |
@@ -1417,7 +1588,9 @@ discard block |
||
| 1417 | 1588 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
| 1418 | 1589 | { |
| 1419 | 1590 | $i = 0; |
| 1420 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1591 | + if ($globalTransaction) { |
|
| 1592 | + $Connection->db->beginTransaction(); |
|
| 1593 | + } |
|
| 1421 | 1594 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1422 | 1595 | { |
| 1423 | 1596 | if ($i > 0) { |
@@ -1434,7 +1607,9 @@ discard block |
||
| 1434 | 1607 | $i++; |
| 1435 | 1608 | } |
| 1436 | 1609 | fclose($handle); |
| 1437 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1610 | + if ($globalTransaction) { |
|
| 1611 | + $Connection->db->commit(); |
|
| 1612 | + } |
|
| 1438 | 1613 | } |
| 1439 | 1614 | return ''; |
| 1440 | 1615 | } |
@@ -1453,7 +1628,9 @@ discard block |
||
| 1453 | 1628 | $Connection = new Connection(); |
| 1454 | 1629 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
| 1455 | 1630 | { |
| 1456 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1631 | + if ($globalTransaction) { |
|
| 1632 | + $Connection->db->beginTransaction(); |
|
| 1633 | + } |
|
| 1457 | 1634 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
| 1458 | 1635 | { |
| 1459 | 1636 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1468,7 +1645,9 @@ discard block |
||
| 1468 | 1645 | } |
| 1469 | 1646 | } |
| 1470 | 1647 | fclose($handle); |
| 1471 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1648 | + if ($globalTransaction) { |
|
| 1649 | + $Connection->db->commit(); |
|
| 1650 | + } |
|
| 1472 | 1651 | } |
| 1473 | 1652 | return ''; |
| 1474 | 1653 | } |
@@ -1546,9 +1725,14 @@ discard block |
||
| 1546 | 1725 | if ($i > 0 && $data[0] != '') { |
| 1547 | 1726 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
| 1548 | 1727 | $period = str_replace(',','',$data[14]); |
| 1549 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
| 1550 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1551 | - else $launch_date = NULL; |
|
| 1728 | + if (!empty($period) && strpos($period,'days')) { |
|
| 1729 | + $period = str_replace(' days','',$period)*24*60; |
|
| 1730 | + } |
|
| 1731 | + if ($data[18] != '') { |
|
| 1732 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1733 | + } else { |
|
| 1734 | + $launch_date = NULL; |
|
| 1735 | + } |
|
| 1552 | 1736 | $data = array_map(function($value) { |
| 1553 | 1737 | return trim($value) === '' ? null : $value; |
| 1554 | 1738 | }, $data); |
@@ -1740,10 +1924,14 @@ discard block |
||
| 1740 | 1924 | $owner_code = trim(substr($data,49,5)); |
| 1741 | 1925 | |
| 1742 | 1926 | if (!isset($satcat_sources[$owner_code]) && $owner_code != 'TBD') { |
| 1743 | - if ($globalDebug) echo $data.'owner_code: '.$owner_code."\n"; |
|
| 1927 | + if ($globalDebug) { |
|
| 1928 | + echo $data.'owner_code: '.$owner_code."\n"; |
|
| 1929 | + } |
|
| 1744 | 1930 | } |
| 1745 | 1931 | if (!isset($satcat_launch_site[trim(substr($data,68,5))])) { |
| 1746 | - if ($globalDebug) echo 'launch_site_code: '.trim(substr($data,68,5))."\n"; |
|
| 1932 | + if ($globalDebug) { |
|
| 1933 | + echo 'launch_site_code: '.trim(substr($data,68,5))."\n"; |
|
| 1934 | + } |
|
| 1747 | 1935 | } |
| 1748 | 1936 | |
| 1749 | 1937 | if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) { |
@@ -1910,7 +2098,9 @@ discard block |
||
| 1910 | 2098 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1911 | 2099 | { |
| 1912 | 2100 | $i = 0; |
| 1913 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 2101 | + if ($globalTransaction) { |
|
| 2102 | + $Connection->db->beginTransaction(); |
|
| 2103 | + } |
|
| 1914 | 2104 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1915 | 2105 | { |
| 1916 | 2106 | $i++; |
@@ -1938,7 +2128,9 @@ discard block |
||
| 1938 | 2128 | } |
| 1939 | 2129 | } |
| 1940 | 2130 | fclose($handle); |
| 1941 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 2131 | + if ($globalTransaction) { |
|
| 2132 | + $Connection->db->commit(); |
|
| 2133 | + } |
|
| 1942 | 2134 | } |
| 1943 | 2135 | return ''; |
| 1944 | 2136 | } |
@@ -1954,7 +2146,9 @@ discard block |
||
| 1954 | 2146 | $Source->deleteLocationByType('fires'); |
| 1955 | 2147 | $i = 0; |
| 1956 | 2148 | if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) { |
| 1957 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 2149 | + if ($globalTransaction) { |
|
| 2150 | + $Connection->db->beginTransaction(); |
|
| 2151 | + } |
|
| 1958 | 2152 | while (($row = fgetcsv($handle,1000)) !== false) { |
| 1959 | 2153 | if ($i > 0 && $row[0] != '' && $row[8] != 'low') { |
| 1960 | 2154 | $description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]); |
@@ -1969,7 +2163,9 @@ discard block |
||
| 1969 | 2163 | } |
| 1970 | 2164 | $i++; |
| 1971 | 2165 | } |
| 1972 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 2166 | + if ($globalTransaction) { |
|
| 2167 | + $Connection->db->commit(); |
|
| 2168 | + } |
|
| 1973 | 2169 | } |
| 1974 | 2170 | } |
| 1975 | 2171 | |
@@ -1990,7 +2186,9 @@ discard block |
||
| 1990 | 2186 | $Connection = new Connection(); |
| 1991 | 2187 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1992 | 2188 | { |
| 1993 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 2189 | + if ($globalTransaction) { |
|
| 2190 | + $Connection->db->beginTransaction(); |
|
| 2191 | + } |
|
| 1994 | 2192 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1995 | 2193 | { |
| 1996 | 2194 | if(count($row) > 1) { |
@@ -2004,7 +2202,9 @@ discard block |
||
| 2004 | 2202 | } |
| 2005 | 2203 | } |
| 2006 | 2204 | fclose($handle); |
| 2007 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 2205 | + if ($globalTransaction) { |
|
| 2206 | + $Connection->db->commit(); |
|
| 2207 | + } |
|
| 2008 | 2208 | } |
| 2009 | 2209 | return ''; |
| 2010 | 2210 | } |
@@ -2024,8 +2224,9 @@ discard block |
||
| 2024 | 2224 | } |
| 2025 | 2225 | |
| 2026 | 2226 | |
| 2027 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 2028 | - else { |
|
| 2227 | + if ($globalDBdriver == 'mysql') { |
|
| 2228 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 2229 | + } else { |
|
| 2029 | 2230 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 2030 | 2231 | $query = "CREATE EXTENSION postgis"; |
| 2031 | 2232 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -2044,7 +2245,9 @@ discard block |
||
| 2044 | 2245 | global $tmp_dir, $globalDebug; |
| 2045 | 2246 | include_once('class.create_db.php'); |
| 2046 | 2247 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 2047 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 2248 | + if ($globalDebug) { |
|
| 2249 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 2250 | + } |
|
| 2048 | 2251 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
| 2049 | 2252 | $error = ''; |
| 2050 | 2253 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -2054,20 +2257,34 @@ discard block |
||
| 2054 | 2257 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 2055 | 2258 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 2056 | 2259 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
| 2057 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2260 | + if ($globalDebug) { |
|
| 2261 | + echo "Gunzip..."; |
|
| 2262 | + } |
|
| 2058 | 2263 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 2059 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2264 | + if ($globalDebug) { |
|
| 2265 | + echo "Add to DB..."; |
|
| 2266 | + } |
|
| 2060 | 2267 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 2061 | 2268 | $NOTAM = new NOTAM(); |
| 2062 | 2269 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 2063 | 2270 | update_db::insert_notam_version($notam_md5); |
| 2064 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
| 2065 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 2066 | - } elseif ($globalDebug) echo "No new version."; |
|
| 2067 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
| 2271 | + } else { |
|
| 2272 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
| 2273 | + } |
|
| 2274 | + } else { |
|
| 2275 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 2276 | + } |
|
| 2277 | + } elseif ($globalDebug) { |
|
| 2278 | + echo "No new version."; |
|
| 2279 | + } |
|
| 2280 | + } else { |
|
| 2281 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
| 2282 | + } |
|
| 2068 | 2283 | if ($error != '') { |
| 2069 | 2284 | return $error; |
| 2070 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2285 | + } elseif ($globalDebug) { |
|
| 2286 | + echo "Done\n"; |
|
| 2287 | + } |
|
| 2071 | 2288 | return ''; |
| 2072 | 2289 | } |
| 2073 | 2290 | |
@@ -2122,68 +2339,114 @@ discard block |
||
| 2122 | 2339 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 2123 | 2340 | if (extension_loaded('zip')) { |
| 2124 | 2341 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 2125 | - if ($globalDebug) echo "Unzip..."; |
|
| 2342 | + if ($globalDebug) { |
|
| 2343 | + echo "Unzip..."; |
|
| 2344 | + } |
|
| 2126 | 2345 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 2127 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2346 | + if ($globalDebug) { |
|
| 2347 | + echo "Add to DB..."; |
|
| 2348 | + } |
|
| 2128 | 2349 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 2129 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 2350 | + if ($globalDebug) { |
|
| 2351 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 2352 | + } |
|
| 2130 | 2353 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 2131 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 2132 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 2133 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 2134 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
| 2354 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 2355 | + $error = "Failed to copy airlines logo."; |
|
| 2356 | + } |
|
| 2357 | + } else { |
|
| 2358 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 2359 | + } |
|
| 2360 | + } else { |
|
| 2361 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 2362 | + } |
|
| 2363 | + } else { |
|
| 2364 | + $error = "ZIP module not loaded but required for IVAO."; |
|
| 2365 | + } |
|
| 2135 | 2366 | if ($error != '') { |
| 2136 | 2367 | return $error; |
| 2137 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2368 | + } elseif ($globalDebug) { |
|
| 2369 | + echo "Done\n"; |
|
| 2370 | + } |
|
| 2138 | 2371 | return ''; |
| 2139 | 2372 | } |
| 2140 | 2373 | |
| 2141 | 2374 | public static function update_routes() { |
| 2142 | 2375 | global $tmp_dir, $globalDebug; |
| 2143 | 2376 | $error = ''; |
| 2144 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 2377 | + if ($globalDebug) { |
|
| 2378 | + echo "Routes : Download..."; |
|
| 2379 | + } |
|
| 2145 | 2380 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 2146 | 2381 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 2147 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2382 | + if ($globalDebug) { |
|
| 2383 | + echo "Gunzip..."; |
|
| 2384 | + } |
|
| 2148 | 2385 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 2149 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2386 | + if ($globalDebug) { |
|
| 2387 | + echo "Add to DB..."; |
|
| 2388 | + } |
|
| 2150 | 2389 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 2151 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 2390 | + } else { |
|
| 2391 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 2392 | + } |
|
| 2152 | 2393 | if ($error != '') { |
| 2153 | 2394 | return $error; |
| 2154 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2395 | + } elseif ($globalDebug) { |
|
| 2396 | + echo "Done\n"; |
|
| 2397 | + } |
|
| 2155 | 2398 | return ''; |
| 2156 | 2399 | } |
| 2157 | 2400 | public static function update_oneworld() { |
| 2158 | 2401 | global $tmp_dir, $globalDebug; |
| 2159 | 2402 | $error = ''; |
| 2160 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 2403 | + if ($globalDebug) { |
|
| 2404 | + echo "Schedules Oneworld : Download..."; |
|
| 2405 | + } |
|
| 2161 | 2406 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 2162 | 2407 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 2163 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2408 | + if ($globalDebug) { |
|
| 2409 | + echo "Gunzip..."; |
|
| 2410 | + } |
|
| 2164 | 2411 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 2165 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2412 | + if ($globalDebug) { |
|
| 2413 | + echo "Add to DB..."; |
|
| 2414 | + } |
|
| 2166 | 2415 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 2167 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 2416 | + } else { |
|
| 2417 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 2418 | + } |
|
| 2168 | 2419 | if ($error != '') { |
| 2169 | 2420 | return $error; |
| 2170 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2421 | + } elseif ($globalDebug) { |
|
| 2422 | + echo "Done\n"; |
|
| 2423 | + } |
|
| 2171 | 2424 | return ''; |
| 2172 | 2425 | } |
| 2173 | 2426 | public static function update_skyteam() { |
| 2174 | 2427 | global $tmp_dir, $globalDebug; |
| 2175 | 2428 | $error = ''; |
| 2176 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 2429 | + if ($globalDebug) { |
|
| 2430 | + echo "Schedules Skyteam : Download..."; |
|
| 2431 | + } |
|
| 2177 | 2432 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 2178 | 2433 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 2179 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2434 | + if ($globalDebug) { |
|
| 2435 | + echo "Gunzip..."; |
|
| 2436 | + } |
|
| 2180 | 2437 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 2181 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2438 | + if ($globalDebug) { |
|
| 2439 | + echo "Add to DB..."; |
|
| 2440 | + } |
|
| 2182 | 2441 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 2183 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 2442 | + } else { |
|
| 2443 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 2444 | + } |
|
| 2184 | 2445 | if ($error != '') { |
| 2185 | 2446 | return $error; |
| 2186 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2447 | + } elseif ($globalDebug) { |
|
| 2448 | + echo "Done\n"; |
|
| 2449 | + } |
|
| 2187 | 2450 | return ''; |
| 2188 | 2451 | } |
| 2189 | 2452 | public static function update_ModeS() { |
@@ -2200,340 +2463,590 @@ discard block |
||
| 2200 | 2463 | exit; |
| 2201 | 2464 | } elseif ($globalDebug) echo "Done\n"; |
| 2202 | 2465 | */ |
| 2203 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 2204 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 2466 | + if ($globalDebug) { |
|
| 2467 | + echo "Modes : Download..."; |
|
| 2468 | + } |
|
| 2469 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 2205 | 2470 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
| 2206 | 2471 | |
| 2207 | 2472 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 2208 | 2473 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
| 2209 | - if ($globalDebug) echo "Unzip..."; |
|
| 2210 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 2474 | + if ($globalDebug) { |
|
| 2475 | + echo "Unzip..."; |
|
| 2476 | + } |
|
| 2477 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 2211 | 2478 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
| 2212 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2479 | + if ($globalDebug) { |
|
| 2480 | + echo "Add to DB..."; |
|
| 2481 | + } |
|
| 2213 | 2482 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 2214 | 2483 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
| 2215 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 2484 | + } else { |
|
| 2485 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 2486 | + } |
|
| 2216 | 2487 | if ($error != '') { |
| 2217 | 2488 | return $error; |
| 2218 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2489 | + } elseif ($globalDebug) { |
|
| 2490 | + echo "Done\n"; |
|
| 2491 | + } |
|
| 2219 | 2492 | return ''; |
| 2220 | 2493 | } |
| 2221 | 2494 | |
| 2222 | 2495 | public static function update_ModeS_faa() { |
| 2223 | 2496 | global $tmp_dir, $globalDebug; |
| 2224 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
| 2497 | + if ($globalDebug) { |
|
| 2498 | + echo "Modes FAA: Download..."; |
|
| 2499 | + } |
|
| 2225 | 2500 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
| 2226 | 2501 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 2227 | - if ($globalDebug) echo "Unzip..."; |
|
| 2502 | + if ($globalDebug) { |
|
| 2503 | + echo "Unzip..."; |
|
| 2504 | + } |
|
| 2228 | 2505 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
| 2229 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2506 | + if ($globalDebug) { |
|
| 2507 | + echo "Add to DB..."; |
|
| 2508 | + } |
|
| 2230 | 2509 | $error = update_db::modes_faa(); |
| 2231 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 2510 | + } else { |
|
| 2511 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 2512 | + } |
|
| 2232 | 2513 | if ($error != '') { |
| 2233 | 2514 | return $error; |
| 2234 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2515 | + } elseif ($globalDebug) { |
|
| 2516 | + echo "Done\n"; |
|
| 2517 | + } |
|
| 2235 | 2518 | return ''; |
| 2236 | 2519 | } |
| 2237 | 2520 | |
| 2238 | 2521 | public static function update_ModeS_flarm() { |
| 2239 | 2522 | global $tmp_dir, $globalDebug; |
| 2240 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 2523 | + if ($globalDebug) { |
|
| 2524 | + echo "Modes Flarmnet: Download..."; |
|
| 2525 | + } |
|
| 2241 | 2526 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 2242 | 2527 | if (file_exists($tmp_dir.'data.fln')) { |
| 2243 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2528 | + if ($globalDebug) { |
|
| 2529 | + echo "Add to DB..."; |
|
| 2530 | + } |
|
| 2244 | 2531 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 2245 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 2532 | + } else { |
|
| 2533 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 2534 | + } |
|
| 2246 | 2535 | if ($error != '') { |
| 2247 | 2536 | return $error; |
| 2248 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2537 | + } elseif ($globalDebug) { |
|
| 2538 | + echo "Done\n"; |
|
| 2539 | + } |
|
| 2249 | 2540 | return ''; |
| 2250 | 2541 | } |
| 2251 | 2542 | |
| 2252 | 2543 | public static function update_ModeS_ogn() { |
| 2253 | 2544 | global $tmp_dir, $globalDebug; |
| 2254 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 2545 | + if ($globalDebug) { |
|
| 2546 | + echo "Modes OGN: Download..."; |
|
| 2547 | + } |
|
| 2255 | 2548 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 2256 | 2549 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 2257 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2550 | + if ($globalDebug) { |
|
| 2551 | + echo "Add to DB..."; |
|
| 2552 | + } |
|
| 2258 | 2553 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 2259 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2554 | + } else { |
|
| 2555 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2556 | + } |
|
| 2260 | 2557 | if ($error != '') { |
| 2261 | 2558 | return $error; |
| 2262 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2559 | + } elseif ($globalDebug) { |
|
| 2560 | + echo "Done\n"; |
|
| 2561 | + } |
|
| 2263 | 2562 | return ''; |
| 2264 | 2563 | } |
| 2265 | 2564 | |
| 2266 | 2565 | public static function update_owner() { |
| 2267 | 2566 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 2268 | 2567 | |
| 2269 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 2568 | + if ($globalDebug) { |
|
| 2569 | + echo "Owner France: Download..."; |
|
| 2570 | + } |
|
| 2270 | 2571 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 2271 | 2572 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 2272 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2573 | + if ($globalDebug) { |
|
| 2574 | + echo "Add to DB..."; |
|
| 2575 | + } |
|
| 2273 | 2576 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 2274 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2577 | + } else { |
|
| 2578 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2579 | + } |
|
| 2275 | 2580 | if ($error != '') { |
| 2276 | 2581 | return $error; |
| 2277 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2582 | + } elseif ($globalDebug) { |
|
| 2583 | + echo "Done\n"; |
|
| 2584 | + } |
|
| 2278 | 2585 | |
| 2279 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 2586 | + if ($globalDebug) { |
|
| 2587 | + echo "Owner Ireland: Download..."; |
|
| 2588 | + } |
|
| 2280 | 2589 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 2281 | 2590 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 2282 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2591 | + if ($globalDebug) { |
|
| 2592 | + echo "Add to DB..."; |
|
| 2593 | + } |
|
| 2283 | 2594 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 2284 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2595 | + } else { |
|
| 2596 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2597 | + } |
|
| 2285 | 2598 | if ($error != '') { |
| 2286 | 2599 | return $error; |
| 2287 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2288 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 2600 | + } elseif ($globalDebug) { |
|
| 2601 | + echo "Done\n"; |
|
| 2602 | + } |
|
| 2603 | + if ($globalDebug) { |
|
| 2604 | + echo "Owner Switzerland: Download..."; |
|
| 2605 | + } |
|
| 2289 | 2606 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 2290 | 2607 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 2291 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2608 | + if ($globalDebug) { |
|
| 2609 | + echo "Add to DB..."; |
|
| 2610 | + } |
|
| 2292 | 2611 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 2293 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2612 | + } else { |
|
| 2613 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2614 | + } |
|
| 2294 | 2615 | if ($error != '') { |
| 2295 | 2616 | return $error; |
| 2296 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2297 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 2617 | + } elseif ($globalDebug) { |
|
| 2618 | + echo "Done\n"; |
|
| 2619 | + } |
|
| 2620 | + if ($globalDebug) { |
|
| 2621 | + echo "Owner Czech Republic: Download..."; |
|
| 2622 | + } |
|
| 2298 | 2623 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 2299 | 2624 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 2300 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2625 | + if ($globalDebug) { |
|
| 2626 | + echo "Add to DB..."; |
|
| 2627 | + } |
|
| 2301 | 2628 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 2302 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2629 | + } else { |
|
| 2630 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2631 | + } |
|
| 2303 | 2632 | if ($error != '') { |
| 2304 | 2633 | return $error; |
| 2305 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2306 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 2634 | + } elseif ($globalDebug) { |
|
| 2635 | + echo "Done\n"; |
|
| 2636 | + } |
|
| 2637 | + if ($globalDebug) { |
|
| 2638 | + echo "Owner Australia: Download..."; |
|
| 2639 | + } |
|
| 2307 | 2640 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 2308 | 2641 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 2309 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2642 | + if ($globalDebug) { |
|
| 2643 | + echo "Add to DB..."; |
|
| 2644 | + } |
|
| 2310 | 2645 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 2311 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2646 | + } else { |
|
| 2647 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2648 | + } |
|
| 2312 | 2649 | if ($error != '') { |
| 2313 | 2650 | return $error; |
| 2314 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2315 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 2651 | + } elseif ($globalDebug) { |
|
| 2652 | + echo "Done\n"; |
|
| 2653 | + } |
|
| 2654 | + if ($globalDebug) { |
|
| 2655 | + echo "Owner Austria: Download..."; |
|
| 2656 | + } |
|
| 2316 | 2657 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 2317 | 2658 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 2318 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2659 | + if ($globalDebug) { |
|
| 2660 | + echo "Add to DB..."; |
|
| 2661 | + } |
|
| 2319 | 2662 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 2320 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2663 | + } else { |
|
| 2664 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2665 | + } |
|
| 2321 | 2666 | if ($error != '') { |
| 2322 | 2667 | return $error; |
| 2323 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2324 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 2668 | + } elseif ($globalDebug) { |
|
| 2669 | + echo "Done\n"; |
|
| 2670 | + } |
|
| 2671 | + if ($globalDebug) { |
|
| 2672 | + echo "Owner Chile: Download..."; |
|
| 2673 | + } |
|
| 2325 | 2674 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 2326 | 2675 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 2327 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2676 | + if ($globalDebug) { |
|
| 2677 | + echo "Add to DB..."; |
|
| 2678 | + } |
|
| 2328 | 2679 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 2329 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2680 | + } else { |
|
| 2681 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2682 | + } |
|
| 2330 | 2683 | if ($error != '') { |
| 2331 | 2684 | return $error; |
| 2332 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2333 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 2685 | + } elseif ($globalDebug) { |
|
| 2686 | + echo "Done\n"; |
|
| 2687 | + } |
|
| 2688 | + if ($globalDebug) { |
|
| 2689 | + echo "Owner Colombia: Download..."; |
|
| 2690 | + } |
|
| 2334 | 2691 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 2335 | 2692 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 2336 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2693 | + if ($globalDebug) { |
|
| 2694 | + echo "Add to DB..."; |
|
| 2695 | + } |
|
| 2337 | 2696 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 2338 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2697 | + } else { |
|
| 2698 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2699 | + } |
|
| 2339 | 2700 | if ($error != '') { |
| 2340 | 2701 | return $error; |
| 2341 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2342 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2702 | + } elseif ($globalDebug) { |
|
| 2703 | + echo "Done\n"; |
|
| 2704 | + } |
|
| 2705 | + if ($globalDebug) { |
|
| 2706 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2707 | + } |
|
| 2343 | 2708 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 2344 | 2709 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 2345 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2710 | + if ($globalDebug) { |
|
| 2711 | + echo "Add to DB..."; |
|
| 2712 | + } |
|
| 2346 | 2713 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 2347 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2714 | + } else { |
|
| 2715 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2716 | + } |
|
| 2348 | 2717 | if ($error != '') { |
| 2349 | 2718 | return $error; |
| 2350 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2351 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 2719 | + } elseif ($globalDebug) { |
|
| 2720 | + echo "Done\n"; |
|
| 2721 | + } |
|
| 2722 | + if ($globalDebug) { |
|
| 2723 | + echo "Owner Brazil: Download..."; |
|
| 2724 | + } |
|
| 2352 | 2725 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 2353 | 2726 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 2354 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2727 | + if ($globalDebug) { |
|
| 2728 | + echo "Add to DB..."; |
|
| 2729 | + } |
|
| 2355 | 2730 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 2356 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2731 | + } else { |
|
| 2732 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2733 | + } |
|
| 2357 | 2734 | if ($error != '') { |
| 2358 | 2735 | return $error; |
| 2359 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2360 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 2736 | + } elseif ($globalDebug) { |
|
| 2737 | + echo "Done\n"; |
|
| 2738 | + } |
|
| 2739 | + if ($globalDebug) { |
|
| 2740 | + echo "Owner Cayman Islands: Download..."; |
|
| 2741 | + } |
|
| 2361 | 2742 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 2362 | 2743 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 2363 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2744 | + if ($globalDebug) { |
|
| 2745 | + echo "Add to DB..."; |
|
| 2746 | + } |
|
| 2364 | 2747 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 2365 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2748 | + } else { |
|
| 2749 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2750 | + } |
|
| 2366 | 2751 | if ($error != '') { |
| 2367 | 2752 | return $error; |
| 2368 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2369 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 2753 | + } elseif ($globalDebug) { |
|
| 2754 | + echo "Done\n"; |
|
| 2755 | + } |
|
| 2756 | + if ($globalDebug) { |
|
| 2757 | + echo "Owner Croatia: Download..."; |
|
| 2758 | + } |
|
| 2370 | 2759 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 2371 | 2760 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 2372 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2761 | + if ($globalDebug) { |
|
| 2762 | + echo "Add to DB..."; |
|
| 2763 | + } |
|
| 2373 | 2764 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 2374 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2765 | + } else { |
|
| 2766 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2767 | + } |
|
| 2375 | 2768 | if ($error != '') { |
| 2376 | 2769 | return $error; |
| 2377 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2378 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 2770 | + } elseif ($globalDebug) { |
|
| 2771 | + echo "Done\n"; |
|
| 2772 | + } |
|
| 2773 | + if ($globalDebug) { |
|
| 2774 | + echo "Owner Luxembourg: Download..."; |
|
| 2775 | + } |
|
| 2379 | 2776 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 2380 | 2777 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 2381 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2778 | + if ($globalDebug) { |
|
| 2779 | + echo "Add to DB..."; |
|
| 2780 | + } |
|
| 2382 | 2781 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 2383 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2782 | + } else { |
|
| 2783 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2784 | + } |
|
| 2384 | 2785 | if ($error != '') { |
| 2385 | 2786 | return $error; |
| 2386 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2387 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 2787 | + } elseif ($globalDebug) { |
|
| 2788 | + echo "Done\n"; |
|
| 2789 | + } |
|
| 2790 | + if ($globalDebug) { |
|
| 2791 | + echo "Owner Maldives: Download..."; |
|
| 2792 | + } |
|
| 2388 | 2793 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 2389 | 2794 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 2390 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2795 | + if ($globalDebug) { |
|
| 2796 | + echo "Add to DB..."; |
|
| 2797 | + } |
|
| 2391 | 2798 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 2392 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2799 | + } else { |
|
| 2800 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2801 | + } |
|
| 2393 | 2802 | if ($error != '') { |
| 2394 | 2803 | return $error; |
| 2395 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2396 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 2804 | + } elseif ($globalDebug) { |
|
| 2805 | + echo "Done\n"; |
|
| 2806 | + } |
|
| 2807 | + if ($globalDebug) { |
|
| 2808 | + echo "Owner New Zealand: Download..."; |
|
| 2809 | + } |
|
| 2397 | 2810 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 2398 | 2811 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 2399 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2812 | + if ($globalDebug) { |
|
| 2813 | + echo "Add to DB..."; |
|
| 2814 | + } |
|
| 2400 | 2815 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 2401 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2816 | + } else { |
|
| 2817 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2818 | + } |
|
| 2402 | 2819 | if ($error != '') { |
| 2403 | 2820 | return $error; |
| 2404 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2405 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 2821 | + } elseif ($globalDebug) { |
|
| 2822 | + echo "Done\n"; |
|
| 2823 | + } |
|
| 2824 | + if ($globalDebug) { |
|
| 2825 | + echo "Owner Papua New Guinea: Download..."; |
|
| 2826 | + } |
|
| 2406 | 2827 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 2407 | 2828 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 2408 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2829 | + if ($globalDebug) { |
|
| 2830 | + echo "Add to DB..."; |
|
| 2831 | + } |
|
| 2409 | 2832 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 2410 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2833 | + } else { |
|
| 2834 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2835 | + } |
|
| 2411 | 2836 | if ($error != '') { |
| 2412 | 2837 | return $error; |
| 2413 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2414 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 2838 | + } elseif ($globalDebug) { |
|
| 2839 | + echo "Done\n"; |
|
| 2840 | + } |
|
| 2841 | + if ($globalDebug) { |
|
| 2842 | + echo "Owner Slovakia: Download..."; |
|
| 2843 | + } |
|
| 2415 | 2844 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 2416 | 2845 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 2417 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2846 | + if ($globalDebug) { |
|
| 2847 | + echo "Add to DB..."; |
|
| 2848 | + } |
|
| 2418 | 2849 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 2419 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2850 | + } else { |
|
| 2851 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2852 | + } |
|
| 2420 | 2853 | if ($error != '') { |
| 2421 | 2854 | return $error; |
| 2422 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2423 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 2855 | + } elseif ($globalDebug) { |
|
| 2856 | + echo "Done\n"; |
|
| 2857 | + } |
|
| 2858 | + if ($globalDebug) { |
|
| 2859 | + echo "Owner Ecuador: Download..."; |
|
| 2860 | + } |
|
| 2424 | 2861 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 2425 | 2862 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 2426 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2863 | + if ($globalDebug) { |
|
| 2864 | + echo "Add to DB..."; |
|
| 2865 | + } |
|
| 2427 | 2866 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 2428 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2867 | + } else { |
|
| 2868 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2869 | + } |
|
| 2429 | 2870 | if ($error != '') { |
| 2430 | 2871 | return $error; |
| 2431 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2432 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 2872 | + } elseif ($globalDebug) { |
|
| 2873 | + echo "Done\n"; |
|
| 2874 | + } |
|
| 2875 | + if ($globalDebug) { |
|
| 2876 | + echo "Owner Iceland: Download..."; |
|
| 2877 | + } |
|
| 2433 | 2878 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 2434 | 2879 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 2435 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2880 | + if ($globalDebug) { |
|
| 2881 | + echo "Add to DB..."; |
|
| 2882 | + } |
|
| 2436 | 2883 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 2437 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2884 | + } else { |
|
| 2885 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2886 | + } |
|
| 2438 | 2887 | if ($error != '') { |
| 2439 | 2888 | return $error; |
| 2440 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2441 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
| 2889 | + } elseif ($globalDebug) { |
|
| 2890 | + echo "Done\n"; |
|
| 2891 | + } |
|
| 2892 | + if ($globalDebug) { |
|
| 2893 | + echo "Owner Isle of Man: Download..."; |
|
| 2894 | + } |
|
| 2442 | 2895 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
| 2443 | 2896 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 2444 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2897 | + if ($globalDebug) { |
|
| 2898 | + echo "Add to DB..."; |
|
| 2899 | + } |
|
| 2445 | 2900 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
| 2446 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2901 | + } else { |
|
| 2902 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2903 | + } |
|
| 2447 | 2904 | if ($error != '') { |
| 2448 | 2905 | return $error; |
| 2449 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2906 | + } elseif ($globalDebug) { |
|
| 2907 | + echo "Done\n"; |
|
| 2908 | + } |
|
| 2450 | 2909 | if ($globalMasterSource) { |
| 2451 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
| 2910 | + if ($globalDebug) { |
|
| 2911 | + echo "ModeS Netherlands: Download..."; |
|
| 2912 | + } |
|
| 2452 | 2913 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
| 2453 | 2914 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 2454 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2915 | + if ($globalDebug) { |
|
| 2916 | + echo "Add to DB..."; |
|
| 2917 | + } |
|
| 2455 | 2918 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
| 2456 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2919 | + } else { |
|
| 2920 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2921 | + } |
|
| 2457 | 2922 | if ($error != '') { |
| 2458 | 2923 | return $error; |
| 2459 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2460 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
| 2924 | + } elseif ($globalDebug) { |
|
| 2925 | + echo "Done\n"; |
|
| 2926 | + } |
|
| 2927 | + if ($globalDebug) { |
|
| 2928 | + echo "ModeS Denmark: Download..."; |
|
| 2929 | + } |
|
| 2461 | 2930 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
| 2462 | 2931 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 2463 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2932 | + if ($globalDebug) { |
|
| 2933 | + echo "Add to DB..."; |
|
| 2934 | + } |
|
| 2464 | 2935 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
| 2465 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2936 | + } else { |
|
| 2937 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2938 | + } |
|
| 2466 | 2939 | if ($error != '') { |
| 2467 | 2940 | return $error; |
| 2468 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2469 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2941 | + } elseif ($globalDebug) { |
|
| 2942 | + echo "Done\n"; |
|
| 2943 | + } |
|
| 2944 | + } elseif ($globalDebug) { |
|
| 2945 | + echo "Done\n"; |
|
| 2946 | + } |
|
| 2470 | 2947 | return ''; |
| 2471 | 2948 | } |
| 2472 | 2949 | |
| 2473 | 2950 | public static function update_translation() { |
| 2474 | 2951 | global $tmp_dir, $globalDebug; |
| 2475 | 2952 | $error = ''; |
| 2476 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 2953 | + if ($globalDebug) { |
|
| 2954 | + echo "Translation : Download..."; |
|
| 2955 | + } |
|
| 2477 | 2956 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 2478 | 2957 | if (file_exists($tmp_dir.'translation.zip')) { |
| 2479 | - if ($globalDebug) echo "Unzip..."; |
|
| 2958 | + if ($globalDebug) { |
|
| 2959 | + echo "Unzip..."; |
|
| 2960 | + } |
|
| 2480 | 2961 | update_db::unzip($tmp_dir.'translation.zip'); |
| 2481 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2962 | + if ($globalDebug) { |
|
| 2963 | + echo "Add to DB..."; |
|
| 2964 | + } |
|
| 2482 | 2965 | $error = update_db::translation(); |
| 2483 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2966 | + } else { |
|
| 2967 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2968 | + } |
|
| 2484 | 2969 | if ($error != '') { |
| 2485 | 2970 | return $error; |
| 2486 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2971 | + } elseif ($globalDebug) { |
|
| 2972 | + echo "Done\n"; |
|
| 2973 | + } |
|
| 2487 | 2974 | return ''; |
| 2488 | 2975 | } |
| 2489 | 2976 | |
| 2490 | 2977 | public static function update_translation_fam() { |
| 2491 | 2978 | global $tmp_dir, $globalDebug; |
| 2492 | 2979 | $error = ''; |
| 2493 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 2980 | + if ($globalDebug) { |
|
| 2981 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 2982 | + } |
|
| 2494 | 2983 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 2495 | 2984 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
| 2496 | 2985 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
| 2497 | 2986 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
| 2498 | 2987 | $translation_md5 = $translation_md5_file[0]; |
| 2499 | 2988 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
| 2500 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2989 | + if ($globalDebug) { |
|
| 2990 | + echo "Gunzip..."; |
|
| 2991 | + } |
|
| 2501 | 2992 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 2502 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2993 | + if ($globalDebug) { |
|
| 2994 | + echo "Add to DB..."; |
|
| 2995 | + } |
|
| 2503 | 2996 | $error = update_db::translation_fam(); |
| 2504 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
| 2505 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2997 | + } else { |
|
| 2998 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
| 2999 | + } |
|
| 3000 | + } else { |
|
| 3001 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 3002 | + } |
|
| 2506 | 3003 | if ($error != '') { |
| 2507 | 3004 | return $error; |
| 2508 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3005 | + } elseif ($globalDebug) { |
|
| 3006 | + echo "Done\n"; |
|
| 3007 | + } |
|
| 2509 | 3008 | return ''; |
| 2510 | 3009 | } |
| 2511 | 3010 | public static function update_ModeS_fam() { |
| 2512 | 3011 | global $tmp_dir, $globalDebug; |
| 2513 | 3012 | $error = ''; |
| 2514 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
| 3013 | + if ($globalDebug) { |
|
| 3014 | + echo "ModeS from FlightAirMap website : Download..."; |
|
| 3015 | + } |
|
| 2515 | 3016 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
| 2516 | 3017 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
| 2517 | 3018 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
| 2518 | 3019 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
| 2519 | 3020 | $modes_md5 = $modes_md5_file[0]; |
| 2520 | 3021 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
| 2521 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3022 | + if ($globalDebug) { |
|
| 3023 | + echo "Gunzip..."; |
|
| 3024 | + } |
|
| 2522 | 3025 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
| 2523 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3026 | + if ($globalDebug) { |
|
| 3027 | + echo "Add to DB..."; |
|
| 3028 | + } |
|
| 2524 | 3029 | $error = update_db::modes_fam(); |
| 2525 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
| 2526 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 3030 | + } else { |
|
| 3031 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
| 3032 | + } |
|
| 3033 | + } else { |
|
| 3034 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 3035 | + } |
|
| 2527 | 3036 | if ($error != '') { |
| 2528 | 3037 | return $error; |
| 2529 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3038 | + } elseif ($globalDebug) { |
|
| 3039 | + echo "Done\n"; |
|
| 3040 | + } |
|
| 2530 | 3041 | return ''; |
| 2531 | 3042 | } |
| 2532 | 3043 | |
| 2533 | 3044 | public static function update_airlines_fam() { |
| 2534 | 3045 | global $tmp_dir, $globalDebug; |
| 2535 | 3046 | $error = ''; |
| 2536 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
| 3047 | + if ($globalDebug) { |
|
| 3048 | + echo "Airlines from FlightAirMap website : Download..."; |
|
| 3049 | + } |
|
| 2537 | 3050 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
| 2538 | 3051 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
| 2539 | 3052 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2542,26 +3055,42 @@ discard block |
||
| 2542 | 3055 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
| 2543 | 3056 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
| 2544 | 3057 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
| 2545 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3058 | + if ($globalDebug) { |
|
| 3059 | + echo "Gunzip..."; |
|
| 3060 | + } |
|
| 2546 | 3061 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
| 2547 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3062 | + if ($globalDebug) { |
|
| 3063 | + echo "Add to DB..."; |
|
| 3064 | + } |
|
| 2548 | 3065 | $error = update_db::airlines_fam(); |
| 2549 | 3066 | update_db::insert_airlines_version($airlines_md5); |
| 2550 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
| 2551 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 2552 | - } elseif ($globalDebug) echo "No update."; |
|
| 2553 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
| 3067 | + } else { |
|
| 3068 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
| 3069 | + } |
|
| 3070 | + } else { |
|
| 3071 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 3072 | + } |
|
| 3073 | + } elseif ($globalDebug) { |
|
| 3074 | + echo "No update."; |
|
| 3075 | + } |
|
| 3076 | + } else { |
|
| 3077 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
| 3078 | + } |
|
| 2554 | 3079 | if ($error != '') { |
| 2555 | 3080 | return $error; |
| 2556 | 3081 | } else { |
| 2557 | - if ($globalDebug) echo "Done\n"; |
|
| 3082 | + if ($globalDebug) { |
|
| 3083 | + echo "Done\n"; |
|
| 3084 | + } |
|
| 2558 | 3085 | } |
| 2559 | 3086 | return ''; |
| 2560 | 3087 | } |
| 2561 | 3088 | |
| 2562 | 3089 | public static function update_owner_fam() { |
| 2563 | 3090 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2564 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
| 3091 | + if ($globalDebug) { |
|
| 3092 | + echo "owner from FlightAirMap website : Download..."; |
|
| 3093 | + } |
|
| 2565 | 3094 | $error = ''; |
| 2566 | 3095 | if ($globalOwner === TRUE) { |
| 2567 | 3096 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
@@ -2574,55 +3103,89 @@ discard block |
||
| 2574 | 3103 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
| 2575 | 3104 | $owners_md5 = $owners_md5_file[0]; |
| 2576 | 3105 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
| 2577 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3106 | + if ($globalDebug) { |
|
| 3107 | + echo "Gunzip..."; |
|
| 3108 | + } |
|
| 2578 | 3109 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
| 2579 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3110 | + if ($globalDebug) { |
|
| 3111 | + echo "Add to DB..."; |
|
| 3112 | + } |
|
| 2580 | 3113 | $error = update_db::owner_fam(); |
| 2581 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
| 2582 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 3114 | + } else { |
|
| 3115 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
| 3116 | + } |
|
| 3117 | + } else { |
|
| 3118 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 3119 | + } |
|
| 2583 | 3120 | if ($error != '') { |
| 2584 | 3121 | return $error; |
| 2585 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3122 | + } elseif ($globalDebug) { |
|
| 3123 | + echo "Done\n"; |
|
| 3124 | + } |
|
| 2586 | 3125 | return ''; |
| 2587 | 3126 | } |
| 2588 | 3127 | public static function update_routes_fam() { |
| 2589 | 3128 | global $tmp_dir, $globalDebug; |
| 2590 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
| 3129 | + if ($globalDebug) { |
|
| 3130 | + echo "Routes from FlightAirMap website : Download..."; |
|
| 3131 | + } |
|
| 2591 | 3132 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
| 2592 | 3133 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
| 2593 | 3134 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
| 2594 | 3135 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
| 2595 | 3136 | $routes_md5 = $routes_md5_file[0]; |
| 2596 | 3137 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
| 2597 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3138 | + if ($globalDebug) { |
|
| 3139 | + echo "Gunzip..."; |
|
| 3140 | + } |
|
| 2598 | 3141 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
| 2599 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3142 | + if ($globalDebug) { |
|
| 3143 | + echo "Add to DB..."; |
|
| 3144 | + } |
|
| 2600 | 3145 | $error = update_db::routes_fam(); |
| 2601 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
| 2602 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 3146 | + } else { |
|
| 3147 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
| 3148 | + } |
|
| 3149 | + } else { |
|
| 3150 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 3151 | + } |
|
| 2603 | 3152 | if ($error != '') { |
| 2604 | 3153 | return $error; |
| 2605 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3154 | + } elseif ($globalDebug) { |
|
| 3155 | + echo "Done\n"; |
|
| 3156 | + } |
|
| 2606 | 3157 | return ''; |
| 2607 | 3158 | } |
| 2608 | 3159 | public static function update_block_fam() { |
| 2609 | 3160 | global $tmp_dir, $globalDebug; |
| 2610 | - if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download..."; |
|
| 3161 | + if ($globalDebug) { |
|
| 3162 | + echo "Blocked aircraft from FlightAirMap website : Download..."; |
|
| 3163 | + } |
|
| 2611 | 3164 | update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz'); |
| 2612 | 3165 | update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5'); |
| 2613 | 3166 | if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) { |
| 2614 | 3167 | $block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5')); |
| 2615 | 3168 | $block_md5 = $block_md5_file[0]; |
| 2616 | 3169 | if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) { |
| 2617 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3170 | + if ($globalDebug) { |
|
| 3171 | + echo "Gunzip..."; |
|
| 3172 | + } |
|
| 2618 | 3173 | update_db::gunzip($tmp_dir.'block.tsv.gz'); |
| 2619 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3174 | + if ($globalDebug) { |
|
| 3175 | + echo "Add to DB..."; |
|
| 3176 | + } |
|
| 2620 | 3177 | $error = update_db::block_fam(); |
| 2621 | - } else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed."; |
|
| 2622 | - } else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed."; |
|
| 3178 | + } else { |
|
| 3179 | + $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed."; |
|
| 3180 | + } |
|
| 3181 | + } else { |
|
| 3182 | + $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed."; |
|
| 3183 | + } |
|
| 2623 | 3184 | if ($error != '') { |
| 2624 | 3185 | return $error; |
| 2625 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3186 | + } elseif ($globalDebug) { |
|
| 3187 | + echo "Done\n"; |
|
| 3188 | + } |
|
| 2626 | 3189 | return ''; |
| 2627 | 3190 | } |
| 2628 | 3191 | public static function update_marine_identity_fam() { |
@@ -2632,21 +3195,33 @@ discard block |
||
| 2632 | 3195 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
| 2633 | 3196 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2634 | 3197 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2635 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
| 3198 | + if ($globalDebug) { |
|
| 3199 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
| 3200 | + } |
|
| 2636 | 3201 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
| 2637 | 3202 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2638 | 3203 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
| 2639 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3204 | + if ($globalDebug) { |
|
| 3205 | + echo "Gunzip..."; |
|
| 3206 | + } |
|
| 2640 | 3207 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
| 2641 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3208 | + if ($globalDebug) { |
|
| 3209 | + echo "Add to DB..."; |
|
| 3210 | + } |
|
| 2642 | 3211 | $error = update_db::marine_identity_fam(); |
| 2643 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
| 2644 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 3212 | + } else { |
|
| 3213 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
| 3214 | + } |
|
| 3215 | + } else { |
|
| 3216 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 3217 | + } |
|
| 2645 | 3218 | if ($error != '') { |
| 2646 | 3219 | return $error; |
| 2647 | 3220 | } else { |
| 2648 | 3221 | update_db::insert_marine_identity_version($marine_identity_md5); |
| 2649 | - if ($globalDebug) echo "Done\n"; |
|
| 3222 | + if ($globalDebug) { |
|
| 3223 | + echo "Done\n"; |
|
| 3224 | + } |
|
| 2650 | 3225 | } |
| 2651 | 3226 | } |
| 2652 | 3227 | } |
@@ -2660,21 +3235,33 @@ discard block |
||
| 2660 | 3235 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
| 2661 | 3236 | $satellite_md5 = $satellite_md5_file[0]; |
| 2662 | 3237 | if (!update_db::check_satellite_version($satellite_md5)) { |
| 2663 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
| 3238 | + if ($globalDebug) { |
|
| 3239 | + echo "Satellite from FlightAirMap website : Download..."; |
|
| 3240 | + } |
|
| 2664 | 3241 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
| 2665 | 3242 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
| 2666 | 3243 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
| 2667 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3244 | + if ($globalDebug) { |
|
| 3245 | + echo "Gunzip..."; |
|
| 3246 | + } |
|
| 2668 | 3247 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
| 2669 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3248 | + if ($globalDebug) { |
|
| 3249 | + echo "Add to DB..."; |
|
| 3250 | + } |
|
| 2670 | 3251 | $error = update_db::satellite_fam(); |
| 2671 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
| 2672 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
| 3252 | + } else { |
|
| 3253 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
| 3254 | + } |
|
| 3255 | + } else { |
|
| 3256 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
| 3257 | + } |
|
| 2673 | 3258 | if ($error != '') { |
| 2674 | 3259 | return $error; |
| 2675 | 3260 | } else { |
| 2676 | 3261 | update_db::insert_satellite_version($satellite_md5); |
| 2677 | - if ($globalDebug) echo "Done\n"; |
|
| 3262 | + if ($globalDebug) { |
|
| 3263 | + echo "Done\n"; |
|
| 3264 | + } |
|
| 2678 | 3265 | } |
| 2679 | 3266 | } |
| 2680 | 3267 | } |
@@ -2687,19 +3274,29 @@ discard block |
||
| 2687 | 3274 | $diagrams_md5_file = explode(' ',file_get_contents($tmp_dir.'diagramspdf.md5')); |
| 2688 | 3275 | $diagrams_md5 = $diagrams_md5_file[0]; |
| 2689 | 3276 | if (!update_db::check_diagrams_version($diagrams_md5)) { |
| 2690 | - if ($globalDebug) echo "Airports diagrams from FlightAirMap website : Download..."; |
|
| 3277 | + if ($globalDebug) { |
|
| 3278 | + echo "Airports diagrams from FlightAirMap website : Download..."; |
|
| 3279 | + } |
|
| 2691 | 3280 | update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf',$tmp_dir.'diagramspdf'); |
| 2692 | 3281 | if (file_exists($tmp_dir.'diagramspdf')) { |
| 2693 | 3282 | if (md5_file($tmp_dir.'diagramspdf') == $diagrams_md5) { |
| 2694 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3283 | + if ($globalDebug) { |
|
| 3284 | + echo "Add to DB..."; |
|
| 3285 | + } |
|
| 2695 | 3286 | $error = update_db::diagrams_fam(); |
| 2696 | - } else $error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed."; |
|
| 2697 | - } else $error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed."; |
|
| 3287 | + } else { |
|
| 3288 | + $error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed."; |
|
| 3289 | + } |
|
| 3290 | + } else { |
|
| 3291 | + $error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed."; |
|
| 3292 | + } |
|
| 2698 | 3293 | if ($error != '') { |
| 2699 | 3294 | return $error; |
| 2700 | 3295 | } else { |
| 2701 | 3296 | update_db::insert_diagrams_version($diagrams_md5); |
| 2702 | - if ($globalDebug) echo "Done\n"; |
|
| 3297 | + if ($globalDebug) { |
|
| 3298 | + echo "Done\n"; |
|
| 3299 | + } |
|
| 2703 | 3300 | } |
| 2704 | 3301 | } |
| 2705 | 3302 | } |
@@ -2707,17 +3304,25 @@ discard block |
||
| 2707 | 3304 | } |
| 2708 | 3305 | public static function update_banned_fam() { |
| 2709 | 3306 | global $tmp_dir, $globalDebug; |
| 2710 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 3307 | + if ($globalDebug) { |
|
| 3308 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 3309 | + } |
|
| 2711 | 3310 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
| 2712 | 3311 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2713 | 3312 | //if ($globalDebug) echo "Gunzip..."; |
| 2714 | 3313 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
| 2715 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3314 | + if ($globalDebug) { |
|
| 3315 | + echo "Add to DB..."; |
|
| 3316 | + } |
|
| 2716 | 3317 | $error = update_db::banned_fam(); |
| 2717 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 3318 | + } else { |
|
| 3319 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 3320 | + } |
|
| 2718 | 3321 | if ($error != '') { |
| 2719 | 3322 | return $error; |
| 2720 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3323 | + } elseif ($globalDebug) { |
|
| 3324 | + echo "Done\n"; |
|
| 3325 | + } |
|
| 2721 | 3326 | return ''; |
| 2722 | 3327 | } |
| 2723 | 3328 | |
@@ -2725,7 +3330,9 @@ discard block |
||
| 2725 | 3330 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 2726 | 3331 | include_once('class.create_db.php'); |
| 2727 | 3332 | $error = ''; |
| 2728 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 3333 | + if ($globalDebug) { |
|
| 3334 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 3335 | + } |
|
| 2729 | 3336 | if ($globalDBdriver == 'mysql') { |
| 2730 | 3337 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 2731 | 3338 | } else { |
@@ -2742,9 +3349,13 @@ discard block |
||
| 2742 | 3349 | } |
| 2743 | 3350 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2744 | 3351 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
| 2745 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3352 | + if ($globalDebug) { |
|
| 3353 | + echo "Gunzip..."; |
|
| 3354 | + } |
|
| 2746 | 3355 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 2747 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3356 | + if ($globalDebug) { |
|
| 3357 | + echo "Add to DB..."; |
|
| 3358 | + } |
|
| 2748 | 3359 | $Connection = new Connection(); |
| 2749 | 3360 | if ($Connection->tableExists('airspace')) { |
| 2750 | 3361 | $query = 'DROP TABLE airspace'; |
@@ -2757,20 +3368,30 @@ discard block |
||
| 2757 | 3368 | } |
| 2758 | 3369 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2759 | 3370 | update_db::insert_airspace_version($airspace_md5); |
| 2760 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
| 2761 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
| 3371 | + } else { |
|
| 3372 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
| 3373 | + } |
|
| 3374 | + } else { |
|
| 3375 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
| 3376 | + } |
|
| 2762 | 3377 | } |
| 2763 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 3378 | + } else { |
|
| 3379 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 3380 | + } |
|
| 2764 | 3381 | if ($error != '') { |
| 2765 | 3382 | return $error; |
| 2766 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3383 | + } elseif ($globalDebug) { |
|
| 3384 | + echo "Done\n"; |
|
| 3385 | + } |
|
| 2767 | 3386 | return ''; |
| 2768 | 3387 | } |
| 2769 | 3388 | |
| 2770 | 3389 | public static function update_geoid_fam() { |
| 2771 | 3390 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2772 | 3391 | $error = ''; |
| 2773 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
| 3392 | + if ($globalDebug) { |
|
| 3393 | + echo "Geoid from FlightAirMap website : Download..."; |
|
| 3394 | + } |
|
| 2774 | 3395 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
| 2775 | 3396 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2776 | 3397 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2779,80 +3400,126 @@ discard block |
||
| 2779 | 3400 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
| 2780 | 3401 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2781 | 3402 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
| 2782 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3403 | + if ($globalDebug) { |
|
| 3404 | + echo "Gunzip..."; |
|
| 3405 | + } |
|
| 2783 | 3406 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
| 2784 | 3407 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2785 | 3408 | update_db::insert_geoid_version($geoid_md5); |
| 2786 | - } else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
| 2787 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
| 2788 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 2789 | - } elseif ($globalDebug) echo 'No new version'."\n"; |
|
| 2790 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 3409 | + } else { |
|
| 3410 | + $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
| 3411 | + } |
|
| 3412 | + } else { |
|
| 3413 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
| 3414 | + } |
|
| 3415 | + } else { |
|
| 3416 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 3417 | + } |
|
| 3418 | + } elseif ($globalDebug) { |
|
| 3419 | + echo 'No new version'."\n"; |
|
| 3420 | + } |
|
| 3421 | + } else { |
|
| 3422 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 3423 | + } |
|
| 2791 | 3424 | if ($error != '') { |
| 2792 | 3425 | return $error; |
| 2793 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3426 | + } elseif ($globalDebug) { |
|
| 3427 | + echo "Done\n"; |
|
| 3428 | + } |
|
| 2794 | 3429 | return ''; |
| 2795 | 3430 | } |
| 2796 | 3431 | |
| 2797 | 3432 | public static function update_tle() { |
| 2798 | 3433 | global $tmp_dir, $globalDebug; |
| 2799 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 3434 | + if ($globalDebug) { |
|
| 3435 | + echo "Download TLE : Download..."; |
|
| 3436 | + } |
|
| 2800 | 3437 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
| 2801 | 3438 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
| 2802 | 3439 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
| 2803 | 3440 | foreach ($alltle as $filename) { |
| 2804 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 3441 | + if ($globalDebug) { |
|
| 3442 | + echo "downloading ".$filename.'...'; |
|
| 3443 | + } |
|
| 2805 | 3444 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 2806 | 3445 | if (file_exists($tmp_dir.$filename)) { |
| 2807 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 3446 | + if ($globalDebug) { |
|
| 3447 | + echo "Add to DB ".$filename."..."; |
|
| 3448 | + } |
|
| 2808 | 3449 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 2809 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 3450 | + } else { |
|
| 3451 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 3452 | + } |
|
| 2810 | 3453 | if ($error != '') { |
| 2811 | 3454 | echo $error."\n"; |
| 2812 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3455 | + } elseif ($globalDebug) { |
|
| 3456 | + echo "Done\n"; |
|
| 3457 | + } |
|
| 2813 | 3458 | } |
| 2814 | 3459 | return ''; |
| 2815 | 3460 | } |
| 2816 | 3461 | |
| 2817 | 3462 | public static function update_ucsdb() { |
| 2818 | 3463 | global $tmp_dir, $globalDebug; |
| 2819 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
| 3464 | + if ($globalDebug) { |
|
| 3465 | + echo "Download UCS DB : Download..."; |
|
| 3466 | + } |
|
| 2820 | 3467 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt',$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'); |
| 2821 | 3468 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
| 2822 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3469 | + if ($globalDebug) { |
|
| 3470 | + echo "Add to DB..."; |
|
| 3471 | + } |
|
| 2823 | 3472 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'); |
| 2824 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed."; |
|
| 3473 | + } else { |
|
| 3474 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed."; |
|
| 3475 | + } |
|
| 2825 | 3476 | if ($error != '') { |
| 2826 | 3477 | echo $error."\n"; |
| 2827 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3478 | + } elseif ($globalDebug) { |
|
| 3479 | + echo "Done\n"; |
|
| 3480 | + } |
|
| 2828 | 3481 | return ''; |
| 2829 | 3482 | } |
| 2830 | 3483 | |
| 2831 | 3484 | public static function update_celestrak() { |
| 2832 | 3485 | global $tmp_dir, $globalDebug; |
| 2833 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
| 3486 | + if ($globalDebug) { |
|
| 3487 | + echo "Download Celestrak DB : Download..."; |
|
| 3488 | + } |
|
| 2834 | 3489 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
| 2835 | 3490 | if (file_exists($tmp_dir.'satcat.txt')) { |
| 2836 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3491 | + if ($globalDebug) { |
|
| 3492 | + echo "Add to DB..."; |
|
| 3493 | + } |
|
| 2837 | 3494 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
| 2838 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
| 3495 | + } else { |
|
| 3496 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
| 3497 | + } |
|
| 2839 | 3498 | if ($error != '') { |
| 2840 | 3499 | echo $error."\n"; |
| 2841 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3500 | + } elseif ($globalDebug) { |
|
| 3501 | + echo "Done\n"; |
|
| 3502 | + } |
|
| 2842 | 3503 | return ''; |
| 2843 | 3504 | } |
| 2844 | 3505 | |
| 2845 | 3506 | public static function update_models() { |
| 2846 | 3507 | global $tmp_dir, $globalDebug; |
| 2847 | 3508 | $error = ''; |
| 2848 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 3509 | + if ($globalDebug) { |
|
| 3510 | + echo "Models from FlightAirMap website : Download..."; |
|
| 3511 | + } |
|
| 2849 | 3512 | if (!is_writable(dirname(__FILE__).'/../models')) { |
| 2850 | - if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
| 3513 | + if ($globalDebug) { |
|
| 3514 | + echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
| 3515 | + } |
|
| 2851 | 3516 | return ''; |
| 2852 | 3517 | } |
| 2853 | 3518 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 2854 | 3519 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2855 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3520 | + if ($globalDebug) { |
|
| 3521 | + echo "Check files...\n"; |
|
| 3522 | + } |
|
| 2856 | 3523 | $newmodelsdb = array(); |
| 2857 | 3524 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 2858 | 3525 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2871,18 +3538,28 @@ discard block |
||
| 2871 | 3538 | } |
| 2872 | 3539 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2873 | 3540 | foreach ($diff as $key => $value) { |
| 2874 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3541 | + if ($globalDebug) { |
|
| 3542 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3543 | + } |
|
| 2875 | 3544 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 2876 | 3545 | } |
| 2877 | 3546 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 2878 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3547 | + } else { |
|
| 3548 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3549 | + } |
|
| 2879 | 3550 | if ($error != '') { |
| 2880 | 3551 | return $error; |
| 2881 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2882 | - if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
| 3552 | + } elseif ($globalDebug) { |
|
| 3553 | + echo "Done\n"; |
|
| 3554 | + } |
|
| 3555 | + if ($globalDebug) { |
|
| 3556 | + echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
| 3557 | + } |
|
| 2883 | 3558 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
| 2884 | 3559 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
| 2885 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3560 | + if ($globalDebug) { |
|
| 3561 | + echo "Check files...\n"; |
|
| 3562 | + } |
|
| 2886 | 3563 | $newmodelsdb = array(); |
| 2887 | 3564 | if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
| 2888 | 3565 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2901,29 +3578,43 @@ discard block |
||
| 2901 | 3578 | } |
| 2902 | 3579 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2903 | 3580 | foreach ($diff as $key => $value) { |
| 2904 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3581 | + if ($globalDebug) { |
|
| 3582 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3583 | + } |
|
| 2905 | 3584 | update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
| 2906 | 3585 | |
| 2907 | 3586 | } |
| 2908 | 3587 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
| 2909 | - } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
| 3588 | + } else { |
|
| 3589 | + $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
| 3590 | + } |
|
| 2910 | 3591 | if ($error != '') { |
| 2911 | 3592 | return $error; |
| 2912 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3593 | + } elseif ($globalDebug) { |
|
| 3594 | + echo "Done\n"; |
|
| 3595 | + } |
|
| 2913 | 3596 | return ''; |
| 2914 | 3597 | } |
| 2915 | 3598 | public static function update_weather_models() { |
| 2916 | 3599 | global $tmp_dir, $globalDebug; |
| 2917 | 3600 | $error = ''; |
| 2918 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 3601 | + if ($globalDebug) { |
|
| 3602 | + echo "Models from FlightAirMap website : Download..."; |
|
| 3603 | + } |
|
| 2919 | 3604 | if (!is_writable(dirname(__FILE__).'/../models/gltf2/weather')) { |
| 2920 | - if ($globalDebug) echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !'; |
|
| 3605 | + if ($globalDebug) { |
|
| 3606 | + echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !'; |
|
| 3607 | + } |
|
| 2921 | 3608 | return ''; |
| 2922 | 3609 | } |
| 2923 | - if ($globalDebug) echo "Weather Models from FlightAirMap website : Download..."; |
|
| 3610 | + if ($globalDebug) { |
|
| 3611 | + echo "Weather Models from FlightAirMap website : Download..."; |
|
| 3612 | + } |
|
| 2924 | 3613 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum'); |
| 2925 | 3614 | if (file_exists($tmp_dir.'modelsweather.md5sum')) { |
| 2926 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3615 | + if ($globalDebug) { |
|
| 3616 | + echo "Check files...\n"; |
|
| 3617 | + } |
|
| 2927 | 3618 | $newmodelsdb = array(); |
| 2928 | 3619 | if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) { |
| 2929 | 3620 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2942,25 +3633,35 @@ discard block |
||
| 2942 | 3633 | } |
| 2943 | 3634 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2944 | 3635 | foreach ($diff as $key => $value) { |
| 2945 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3636 | + if ($globalDebug) { |
|
| 3637 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3638 | + } |
|
| 2946 | 3639 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key); |
| 2947 | 3640 | |
| 2948 | 3641 | } |
| 2949 | 3642 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum'); |
| 2950 | - } else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
|
| 3643 | + } else { |
|
| 3644 | + $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
|
| 3645 | + } |
|
| 2951 | 3646 | if ($error != '') { |
| 2952 | 3647 | return $error; |
| 2953 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3648 | + } elseif ($globalDebug) { |
|
| 3649 | + echo "Done\n"; |
|
| 3650 | + } |
|
| 2954 | 3651 | return ''; |
| 2955 | 3652 | } |
| 2956 | 3653 | |
| 2957 | 3654 | public static function update_liveries() { |
| 2958 | 3655 | global $tmp_dir, $globalDebug; |
| 2959 | 3656 | $error = ''; |
| 2960 | - if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
|
| 3657 | + if ($globalDebug) { |
|
| 3658 | + echo "Liveries from FlightAirMap website : Download..."; |
|
| 3659 | + } |
|
| 2961 | 3660 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
| 2962 | 3661 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
| 2963 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3662 | + if ($globalDebug) { |
|
| 3663 | + echo "Check files...\n"; |
|
| 3664 | + } |
|
| 2964 | 3665 | $newmodelsdb = array(); |
| 2965 | 3666 | if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
| 2966 | 3667 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2979,15 +3680,21 @@ discard block |
||
| 2979 | 3680 | } |
| 2980 | 3681 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2981 | 3682 | foreach ($diff as $key => $value) { |
| 2982 | - if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
|
| 3683 | + if ($globalDebug) { |
|
| 3684 | + echo 'Downloading liveries '.$key.' ...'."\n"; |
|
| 3685 | + } |
|
| 2983 | 3686 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
| 2984 | 3687 | |
| 2985 | 3688 | } |
| 2986 | 3689 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
| 2987 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3690 | + } else { |
|
| 3691 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3692 | + } |
|
| 2988 | 3693 | if ($error != '') { |
| 2989 | 3694 | return $error; |
| 2990 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3695 | + } elseif ($globalDebug) { |
|
| 3696 | + echo "Done\n"; |
|
| 3697 | + } |
|
| 2991 | 3698 | return ''; |
| 2992 | 3699 | } |
| 2993 | 3700 | |
@@ -2995,13 +3702,19 @@ discard block |
||
| 2995 | 3702 | global $tmp_dir, $globalDebug; |
| 2996 | 3703 | $error = ''; |
| 2997 | 3704 | if (!is_writable(dirname(__FILE__).'/../models')) { |
| 2998 | - if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
| 3705 | + if ($globalDebug) { |
|
| 3706 | + echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
| 3707 | + } |
|
| 2999 | 3708 | return ''; |
| 3000 | 3709 | } |
| 3001 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 3710 | + if ($globalDebug) { |
|
| 3711 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 3712 | + } |
|
| 3002 | 3713 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 3003 | 3714 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 3004 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3715 | + if ($globalDebug) { |
|
| 3716 | + echo "Check files...\n"; |
|
| 3717 | + } |
|
| 3005 | 3718 | $newmodelsdb = array(); |
| 3006 | 3719 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 3007 | 3720 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -3020,15 +3733,21 @@ discard block |
||
| 3020 | 3733 | } |
| 3021 | 3734 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 3022 | 3735 | foreach ($diff as $key => $value) { |
| 3023 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 3736 | + if ($globalDebug) { |
|
| 3737 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 3738 | + } |
|
| 3024 | 3739 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 3025 | 3740 | |
| 3026 | 3741 | } |
| 3027 | 3742 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 3028 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3743 | + } else { |
|
| 3744 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3745 | + } |
|
| 3029 | 3746 | if ($error != '') { |
| 3030 | 3747 | return $error; |
| 3031 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3748 | + } elseif ($globalDebug) { |
|
| 3749 | + echo "Done\n"; |
|
| 3750 | + } |
|
| 3032 | 3751 | return ''; |
| 3033 | 3752 | } |
| 3034 | 3753 | |
@@ -3036,13 +3755,19 @@ discard block |
||
| 3036 | 3755 | global $tmp_dir, $globalDebug; |
| 3037 | 3756 | $error = ''; |
| 3038 | 3757 | if (!is_writable(dirname(__FILE__).'/../models/vehicules')) { |
| 3039 | - if ($globalDebug) echo dirname(__FILE__).'/../models/vehicules'.' is not writable !'; |
|
| 3758 | + if ($globalDebug) { |
|
| 3759 | + echo dirname(__FILE__).'/../models/vehicules'.' is not writable !'; |
|
| 3760 | + } |
|
| 3040 | 3761 | return ''; |
| 3041 | 3762 | } |
| 3042 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 3763 | + if ($globalDebug) { |
|
| 3764 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 3765 | + } |
|
| 3043 | 3766 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
| 3044 | 3767 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 3045 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3768 | + if ($globalDebug) { |
|
| 3769 | + echo "Check files...\n"; |
|
| 3770 | + } |
|
| 3046 | 3771 | $newmodelsdb = array(); |
| 3047 | 3772 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
| 3048 | 3773 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -3061,15 +3786,21 @@ discard block |
||
| 3061 | 3786 | } |
| 3062 | 3787 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 3063 | 3788 | foreach ($diff as $key => $value) { |
| 3064 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 3789 | + if ($globalDebug) { |
|
| 3790 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 3791 | + } |
|
| 3065 | 3792 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
| 3066 | 3793 | |
| 3067 | 3794 | } |
| 3068 | 3795 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
| 3069 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3796 | + } else { |
|
| 3797 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3798 | + } |
|
| 3070 | 3799 | if ($error != '') { |
| 3071 | 3800 | return $error; |
| 3072 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3801 | + } elseif ($globalDebug) { |
|
| 3802 | + echo "Done\n"; |
|
| 3803 | + } |
|
| 3073 | 3804 | return ''; |
| 3074 | 3805 | } |
| 3075 | 3806 | |
@@ -3142,7 +3873,9 @@ discard block |
||
| 3142 | 3873 | } |
| 3143 | 3874 | |
| 3144 | 3875 | $error = ''; |
| 3145 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 3876 | + if ($globalDebug) { |
|
| 3877 | + echo "Notam : Download..."; |
|
| 3878 | + } |
|
| 3146 | 3879 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 3147 | 3880 | if (file_exists($tmp_dir.'notam.rss')) { |
| 3148 | 3881 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -3157,14 +3890,30 @@ discard block |
||
| 3157 | 3890 | $data['fir'] = $q[0]; |
| 3158 | 3891 | $data['code'] = $q[1]; |
| 3159 | 3892 | $ifrvfr = $q[2]; |
| 3160 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 3161 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 3162 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 3163 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 3164 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 3165 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 3166 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 3167 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 3893 | + if ($ifrvfr == 'IV') { |
|
| 3894 | + $data['rules'] = 'IFR/VFR'; |
|
| 3895 | + } |
|
| 3896 | + if ($ifrvfr == 'I') { |
|
| 3897 | + $data['rules'] = 'IFR'; |
|
| 3898 | + } |
|
| 3899 | + if ($ifrvfr == 'V') { |
|
| 3900 | + $data['rules'] = 'VFR'; |
|
| 3901 | + } |
|
| 3902 | + if ($q[4] == 'A') { |
|
| 3903 | + $data['scope'] = 'Airport warning'; |
|
| 3904 | + } |
|
| 3905 | + if ($q[4] == 'E') { |
|
| 3906 | + $data['scope'] = 'Enroute warning'; |
|
| 3907 | + } |
|
| 3908 | + if ($q[4] == 'W') { |
|
| 3909 | + $data['scope'] = 'Navigation warning'; |
|
| 3910 | + } |
|
| 3911 | + if ($q[4] == 'AE') { |
|
| 3912 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 3913 | + } |
|
| 3914 | + if ($q[4] == 'AW') { |
|
| 3915 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 3916 | + } |
|
| 3168 | 3917 | //$data['scope'] = $q[4]; |
| 3169 | 3918 | $data['lower_limit'] = $q[5]; |
| 3170 | 3919 | $data['upper_limit'] = $q[6]; |
@@ -3172,8 +3921,12 @@ discard block |
||
| 3172 | 3921 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 3173 | 3922 | $latitude = $Common->convertDec($las,'latitude'); |
| 3174 | 3923 | $longitude = $Common->convertDec($lns,'longitude'); |
| 3175 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 3176 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 3924 | + if ($lac == 'S') { |
|
| 3925 | + $latitude = '-'.$latitude; |
|
| 3926 | + } |
|
| 3927 | + if ($lnc == 'W') { |
|
| 3928 | + $longitude = '-'.$longitude; |
|
| 3929 | + } |
|
| 3177 | 3930 | $data['center_latitude'] = $latitude; |
| 3178 | 3931 | $data['center_longitude'] = $longitude; |
| 3179 | 3932 | $data['radius'] = intval($radius); |
@@ -3203,10 +3956,14 @@ discard block |
||
| 3203 | 3956 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
| 3204 | 3957 | unset($data); |
| 3205 | 3958 | } |
| 3206 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 3959 | + } else { |
|
| 3960 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 3961 | + } |
|
| 3207 | 3962 | if ($error != '') { |
| 3208 | 3963 | return $error; |
| 3209 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3964 | + } elseif ($globalDebug) { |
|
| 3965 | + echo "Done\n"; |
|
| 3966 | + } |
|
| 3210 | 3967 | return ''; |
| 3211 | 3968 | } |
| 3212 | 3969 | |
@@ -3231,7 +3988,9 @@ discard block |
||
| 3231 | 3988 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 3232 | 3989 | $airspace_json = json_decode($airspace_lst,true); |
| 3233 | 3990 | foreach ($airspace_json['records'] as $airspace) { |
| 3234 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 3991 | + if ($globalDebug) { |
|
| 3992 | + echo $airspace['name']."...\n"; |
|
| 3993 | + } |
|
| 3235 | 3994 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 3236 | 3995 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 3237 | 3996 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -3275,8 +4034,11 @@ discard block |
||
| 3275 | 4034 | return "error : ".$e->getMessage(); |
| 3276 | 4035 | } |
| 3277 | 4036 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3278 | - if ($row['nb'] > 0) return false; |
|
| 3279 | - else return true; |
|
| 4037 | + if ($row['nb'] > 0) { |
|
| 4038 | + return false; |
|
| 4039 | + } else { |
|
| 4040 | + return true; |
|
| 4041 | + } |
|
| 3280 | 4042 | } |
| 3281 | 4043 | |
| 3282 | 4044 | public static function insert_last_update() { |
@@ -3301,8 +4063,11 @@ discard block |
||
| 3301 | 4063 | return "error : ".$e->getMessage(); |
| 3302 | 4064 | } |
| 3303 | 4065 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3304 | - if ($row['nb'] > 0) return true; |
|
| 3305 | - else return false; |
|
| 4066 | + if ($row['nb'] > 0) { |
|
| 4067 | + return true; |
|
| 4068 | + } else { |
|
| 4069 | + return false; |
|
| 4070 | + } |
|
| 3306 | 4071 | } |
| 3307 | 4072 | |
| 3308 | 4073 | public static function check_geoid_version($version) { |
@@ -3315,8 +4080,11 @@ discard block |
||
| 3315 | 4080 | return "error : ".$e->getMessage(); |
| 3316 | 4081 | } |
| 3317 | 4082 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3318 | - if ($row['nb'] > 0) return true; |
|
| 3319 | - else return false; |
|
| 4083 | + if ($row['nb'] > 0) { |
|
| 4084 | + return true; |
|
| 4085 | + } else { |
|
| 4086 | + return false; |
|
| 4087 | + } |
|
| 3320 | 4088 | } |
| 3321 | 4089 | |
| 3322 | 4090 | public static function check_marine_identity_version($version) { |
@@ -3329,8 +4097,11 @@ discard block |
||
| 3329 | 4097 | return "error : ".$e->getMessage(); |
| 3330 | 4098 | } |
| 3331 | 4099 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3332 | - if ($row['nb'] > 0) return true; |
|
| 3333 | - else return false; |
|
| 4100 | + if ($row['nb'] > 0) { |
|
| 4101 | + return true; |
|
| 4102 | + } else { |
|
| 4103 | + return false; |
|
| 4104 | + } |
|
| 3334 | 4105 | } |
| 3335 | 4106 | |
| 3336 | 4107 | public static function check_satellite_version($version) { |
@@ -3343,8 +4114,11 @@ discard block |
||
| 3343 | 4114 | return "error : ".$e->getMessage(); |
| 3344 | 4115 | } |
| 3345 | 4116 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3346 | - if ($row['nb'] > 0) return true; |
|
| 3347 | - else return false; |
|
| 4117 | + if ($row['nb'] > 0) { |
|
| 4118 | + return true; |
|
| 4119 | + } else { |
|
| 4120 | + return false; |
|
| 4121 | + } |
|
| 3348 | 4122 | } |
| 3349 | 4123 | public static function check_diagrams_version($version) { |
| 3350 | 4124 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'diagrams_version' AND value = :version"; |
@@ -3356,8 +4130,11 @@ discard block |
||
| 3356 | 4130 | return "error : ".$e->getMessage(); |
| 3357 | 4131 | } |
| 3358 | 4132 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3359 | - if ($row['nb'] > 0) return true; |
|
| 3360 | - else return false; |
|
| 4133 | + if ($row['nb'] > 0) { |
|
| 4134 | + return true; |
|
| 4135 | + } else { |
|
| 4136 | + return false; |
|
| 4137 | + } |
|
| 3361 | 4138 | } |
| 3362 | 4139 | |
| 3363 | 4140 | public static function check_airlines_version($version) { |
@@ -3370,8 +4147,11 @@ discard block |
||
| 3370 | 4147 | return "error : ".$e->getMessage(); |
| 3371 | 4148 | } |
| 3372 | 4149 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3373 | - if ($row['nb'] > 0) return true; |
|
| 3374 | - else return false; |
|
| 4150 | + if ($row['nb'] > 0) { |
|
| 4151 | + return true; |
|
| 4152 | + } else { |
|
| 4153 | + return false; |
|
| 4154 | + } |
|
| 3375 | 4155 | } |
| 3376 | 4156 | |
| 3377 | 4157 | public static function check_notam_version($version) { |
@@ -3384,8 +4164,11 @@ discard block |
||
| 3384 | 4164 | return "error : ".$e->getMessage(); |
| 3385 | 4165 | } |
| 3386 | 4166 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3387 | - if ($row['nb'] > 0) return true; |
|
| 3388 | - else return false; |
|
| 4167 | + if ($row['nb'] > 0) { |
|
| 4168 | + return true; |
|
| 4169 | + } else { |
|
| 4170 | + return false; |
|
| 4171 | + } |
|
| 3389 | 4172 | } |
| 3390 | 4173 | |
| 3391 | 4174 | public static function insert_airlines_version($version) { |
@@ -3486,8 +4269,11 @@ discard block |
||
| 3486 | 4269 | return "error : ".$e->getMessage(); |
| 3487 | 4270 | } |
| 3488 | 4271 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3489 | - if ($row['nb'] > 0) return false; |
|
| 3490 | - else return true; |
|
| 4272 | + if ($row['nb'] > 0) { |
|
| 4273 | + return false; |
|
| 4274 | + } else { |
|
| 4275 | + return true; |
|
| 4276 | + } |
|
| 3491 | 4277 | } |
| 3492 | 4278 | |
| 3493 | 4279 | public static function insert_last_notam_update() { |
@@ -3517,8 +4303,11 @@ discard block |
||
| 3517 | 4303 | return "error : ".$e->getMessage(); |
| 3518 | 4304 | } |
| 3519 | 4305 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3520 | - if ($row['nb'] > 0) return false; |
|
| 3521 | - else return true; |
|
| 4306 | + if ($row['nb'] > 0) { |
|
| 4307 | + return false; |
|
| 4308 | + } else { |
|
| 4309 | + return true; |
|
| 4310 | + } |
|
| 3522 | 4311 | } |
| 3523 | 4312 | |
| 3524 | 4313 | public static function insert_last_airspace_update() { |
@@ -3548,8 +4337,11 @@ discard block |
||
| 3548 | 4337 | return "error : ".$e->getMessage(); |
| 3549 | 4338 | } |
| 3550 | 4339 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3551 | - if ($row['nb'] > 0) return false; |
|
| 3552 | - else return true; |
|
| 4340 | + if ($row['nb'] > 0) { |
|
| 4341 | + return false; |
|
| 4342 | + } else { |
|
| 4343 | + return true; |
|
| 4344 | + } |
|
| 3553 | 4345 | } |
| 3554 | 4346 | |
| 3555 | 4347 | public static function insert_last_geoid_update() { |
@@ -3579,8 +4371,11 @@ discard block |
||
| 3579 | 4371 | return "error : ".$e->getMessage(); |
| 3580 | 4372 | } |
| 3581 | 4373 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3582 | - if ($row['nb'] > 0) return false; |
|
| 3583 | - else return true; |
|
| 4374 | + if ($row['nb'] > 0) { |
|
| 4375 | + return false; |
|
| 4376 | + } else { |
|
| 4377 | + return true; |
|
| 4378 | + } |
|
| 3584 | 4379 | } |
| 3585 | 4380 | |
| 3586 | 4381 | public static function insert_last_owner_update() { |
@@ -3610,8 +4405,11 @@ discard block |
||
| 3610 | 4405 | return "error : ".$e->getMessage(); |
| 3611 | 4406 | } |
| 3612 | 4407 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3613 | - if ($row['nb'] > 0) return false; |
|
| 3614 | - else return true; |
|
| 4408 | + if ($row['nb'] > 0) { |
|
| 4409 | + return false; |
|
| 4410 | + } else { |
|
| 4411 | + return true; |
|
| 4412 | + } |
|
| 3615 | 4413 | } |
| 3616 | 4414 | |
| 3617 | 4415 | public static function insert_last_fires_update() { |
@@ -3641,8 +4439,11 @@ discard block |
||
| 3641 | 4439 | return "error : ".$e->getMessage(); |
| 3642 | 4440 | } |
| 3643 | 4441 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3644 | - if ($row['nb'] > 0) return false; |
|
| 3645 | - else return true; |
|
| 4442 | + if ($row['nb'] > 0) { |
|
| 4443 | + return false; |
|
| 4444 | + } else { |
|
| 4445 | + return true; |
|
| 4446 | + } |
|
| 3646 | 4447 | } |
| 3647 | 4448 | |
| 3648 | 4449 | public static function insert_last_airlines_update() { |
@@ -3672,8 +4473,11 @@ discard block |
||
| 3672 | 4473 | return "error : ".$e->getMessage(); |
| 3673 | 4474 | } |
| 3674 | 4475 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3675 | - if ($row['nb'] > 0) return false; |
|
| 3676 | - else return true; |
|
| 4476 | + if ($row['nb'] > 0) { |
|
| 4477 | + return false; |
|
| 4478 | + } else { |
|
| 4479 | + return true; |
|
| 4480 | + } |
|
| 3677 | 4481 | } |
| 3678 | 4482 | |
| 3679 | 4483 | public static function insert_last_schedules_update() { |
@@ -3703,8 +4507,11 @@ discard block |
||
| 3703 | 4507 | return "error : ".$e->getMessage(); |
| 3704 | 4508 | } |
| 3705 | 4509 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3706 | - if ($row['nb'] > 0) return false; |
|
| 3707 | - else return true; |
|
| 4510 | + if ($row['nb'] > 0) { |
|
| 4511 | + return false; |
|
| 4512 | + } else { |
|
| 4513 | + return true; |
|
| 4514 | + } |
|
| 3708 | 4515 | } |
| 3709 | 4516 | |
| 3710 | 4517 | public static function insert_last_tle_update() { |
@@ -3734,8 +4541,11 @@ discard block |
||
| 3734 | 4541 | return "error : ".$e->getMessage(); |
| 3735 | 4542 | } |
| 3736 | 4543 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3737 | - if ($row['nb'] > 0) return false; |
|
| 3738 | - else return true; |
|
| 4544 | + if ($row['nb'] > 0) { |
|
| 4545 | + return false; |
|
| 4546 | + } else { |
|
| 4547 | + return true; |
|
| 4548 | + } |
|
| 3739 | 4549 | } |
| 3740 | 4550 | |
| 3741 | 4551 | public static function insert_last_ucsdb_update() { |
@@ -3765,8 +4575,11 @@ discard block |
||
| 3765 | 4575 | return "error : ".$e->getMessage(); |
| 3766 | 4576 | } |
| 3767 | 4577 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3768 | - if ($row['nb'] > 0) return false; |
|
| 3769 | - else return true; |
|
| 4578 | + if ($row['nb'] > 0) { |
|
| 4579 | + return false; |
|
| 4580 | + } else { |
|
| 4581 | + return true; |
|
| 4582 | + } |
|
| 3770 | 4583 | } |
| 3771 | 4584 | |
| 3772 | 4585 | public static function insert_last_celestrak_update() { |
@@ -3796,8 +4609,11 @@ discard block |
||
| 3796 | 4609 | return "error : ".$e->getMessage(); |
| 3797 | 4610 | } |
| 3798 | 4611 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3799 | - if ($row['nb'] > 0) return false; |
|
| 3800 | - else return true; |
|
| 4612 | + if ($row['nb'] > 0) { |
|
| 4613 | + return false; |
|
| 4614 | + } else { |
|
| 4615 | + return true; |
|
| 4616 | + } |
|
| 3801 | 4617 | } |
| 3802 | 4618 | |
| 3803 | 4619 | public static function check_last_satellite_update() { |
@@ -3815,8 +4631,11 @@ discard block |
||
| 3815 | 4631 | return "error : ".$e->getMessage(); |
| 3816 | 4632 | } |
| 3817 | 4633 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3818 | - if ($row['nb'] > 0) return false; |
|
| 3819 | - else return true; |
|
| 4634 | + if ($row['nb'] > 0) { |
|
| 4635 | + return false; |
|
| 4636 | + } else { |
|
| 4637 | + return true; |
|
| 4638 | + } |
|
| 3820 | 4639 | } |
| 3821 | 4640 | |
| 3822 | 4641 | public static function insert_last_marine_identity_update() { |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 26 | 28 | |
| 27 | 29 | if ($globalInstalled === FALSE) { |
| 28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
@@ -68,66 +70,107 @@ discard block |
||
| 68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 71 | if (isset($options['s'])) { |
| 70 | 72 | $globalSources = array(); |
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | - else $globalSources[] = array('host' => $options['s']); |
|
| 73 | -} elseif (isset($options['source'])) { |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['s']); |
|
| 77 | + } |
|
| 78 | + } elseif (isset($options['source'])) { |
|
| 74 | 79 | $globalSources = array(); |
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | - else $globalSources[] = array('host' => $options['source']); |
|
| 77 | -} |
|
| 80 | + if (isset($options['format'])) { |
|
| 81 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 82 | + } else { |
|
| 83 | + $globalSources[] = array('host' => $options['source']); |
|
| 84 | + } |
|
| 85 | + } |
|
| 78 | 86 | if (isset($options['aprsserverhost'])) { |
| 79 | 87 | $globalServerAPRS = TRUE; |
| 80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; |
| 81 | 89 | } |
| 82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 90 | +if (isset($options['aprsserverport'])) { |
|
| 91 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 92 | +} |
|
| 93 | +if (isset($options['aprsserverssid'])) { |
|
| 94 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 95 | +} |
|
| 96 | +if (isset($options['aprsserverpass'])) { |
|
| 97 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 98 | +} |
|
| 99 | +if (isset($options['noaprsserver'])) { |
|
| 100 | + $globalServerAPRS = FALSE; |
|
| 101 | +} |
|
| 86 | 102 | if (isset($options['enable-aircraft'])) { |
| 87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
| 103 | + if ($globalDebug) { |
|
| 104 | + echo 'Enable Aircraft mode'."\n"; |
|
| 105 | + } |
|
| 88 | 106 | $globalAircraft = TRUE; |
| 89 | 107 | } |
| 90 | 108 | if (isset($options['disable-aircraft'])) { |
| 91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
| 109 | + if ($globalDebug) { |
|
| 110 | + echo 'Disable Aircraft mode'."\n"; |
|
| 111 | + } |
|
| 92 | 112 | $globalAircraft = FALSE; |
| 93 | 113 | } |
| 94 | 114 | if (isset($options['enable-tracker'])) { |
| 95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
| 115 | + if ($globalDebug) { |
|
| 116 | + echo 'Enable Tracker mode'."\n"; |
|
| 117 | + } |
|
| 96 | 118 | $globalTracker = TRUE; |
| 97 | 119 | } |
| 98 | 120 | if (isset($options['disable-tracker'])) { |
| 99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
| 121 | + if ($globalDebug) { |
|
| 122 | + echo 'Disable Tracker mode'."\n"; |
|
| 123 | + } |
|
| 100 | 124 | $globalTracker = FALSE; |
| 101 | 125 | } |
| 102 | 126 | if (isset($options['enable-marine'])) { |
| 103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
| 127 | + if ($globalDebug) { |
|
| 128 | + echo 'Enable Marine mode'."\n"; |
|
| 129 | + } |
|
| 104 | 130 | $globalMarine = TRUE; |
| 105 | 131 | } |
| 106 | 132 | if (isset($options['disable-marine'])) { |
| 107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
| 133 | + if ($globalDebug) { |
|
| 134 | + echo 'Disable Marine mode'."\n"; |
|
| 135 | + } |
|
| 108 | 136 | $globalMarine = FALSE; |
| 109 | 137 | } |
| 110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 111 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 113 | -else $id_source = 1; |
|
| 138 | +if (isset($options['nodaemon'])) { |
|
| 139 | + $globalDaemon = FALSE; |
|
| 140 | +} |
|
| 141 | +if (isset($options['server'])) { |
|
| 142 | + $globalServer = TRUE; |
|
| 143 | +} |
|
| 144 | +if (isset($options['idsource'])) { |
|
| 145 | + $id_source = $options['idsource']; |
|
| 146 | +} else { |
|
| 147 | + $id_source = 1; |
|
| 148 | +} |
|
| 114 | 149 | if (isset($globalServer) && $globalServer) { |
| 115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 150 | + if ($globalDebug) { |
|
| 151 | + echo "Using Server Mode\n"; |
|
| 152 | + } |
|
| 116 | 153 | $SI=new SpotterServer(); |
| 117 | 154 | /* |
| 118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 156 | $SI = new adsb2aprs(); |
| 120 | 157 | $SI->connect(); |
| 121 | 158 | */ |
| 122 | -} else $SI=new SpotterImport($Connection->db); |
|
| 159 | +} else { |
|
| 160 | + $SI=new SpotterImport($Connection->db); |
|
| 161 | +} |
|
| 123 | 162 | |
| 124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 163 | +if (isset($globalTracker) && $globalTracker) { |
|
| 164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 165 | +} |
|
| 125 | 166 | if (isset($globalMarine) && $globalMarine) { |
| 126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 128 | 169 | } |
| 129 | 170 | |
| 130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 171 | +if (isset($globalTracker) && $globalTracker) { |
|
| 172 | + $TI = new TrackerImport($Connection->db); |
|
| 173 | +} |
|
| 131 | 174 | if (isset($globalMarine) && $globalMarine) { |
| 132 | 175 | $AIS = new AIS(); |
| 133 | 176 | $MI = new MarineImport($Connection->db); |
@@ -152,7 +195,9 @@ discard block |
||
| 152 | 195 | } |
| 153 | 196 | |
| 154 | 197 | // let's try and connect |
| 155 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 198 | +if ($globalDebug) { |
|
| 199 | + echo "Connecting...\n"; |
|
| 200 | +} |
|
| 156 | 201 | $use_aprs = false; |
| 157 | 202 | $aprs_full = false; |
| 158 | 203 | $reset = 0; |
@@ -161,7 +206,9 @@ discard block |
||
| 161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 163 | 208 | $reset++; |
| 164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 209 | + if ($globalDebug) { |
|
| 210 | + echo 'Connect to all...'."\n"; |
|
| 211 | + } |
|
| 165 | 212 | foreach ($hosts as $id => $value) { |
| 166 | 213 | $host = $value['host']; |
| 167 | 214 | $globalSources[$id]['last_exec'] = 0; |
@@ -171,32 +218,44 @@ discard block |
||
| 171 | 218 | //$formats[$id] = 'deltadbtxt'; |
| 172 | 219 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 173 | 220 | //$last_exec['deltadbtxt'] = 0; |
| 174 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 221 | + if ($globalDebug) { |
|
| 222 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 223 | + } |
|
| 175 | 224 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 176 | 225 | //$formats[$id] = 'vatsimtxt'; |
| 177 | 226 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 178 | 227 | //$last_exec['vatsimtxt'] = 0; |
| 179 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 228 | + if ($globalDebug) { |
|
| 229 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 230 | + } |
|
| 180 | 231 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 181 | 232 | //$formats[$id] = 'aircraftlistjson'; |
| 182 | 233 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 183 | 234 | //$last_exec['aircraftlistjson'] = 0; |
| 184 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 235 | + if ($globalDebug) { |
|
| 236 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 237 | + } |
|
| 185 | 238 | } else if (preg_match('/aircraft.json$/i',$host)) { |
| 186 | 239 | //$formats[$id] = 'aircraftjson'; |
| 187 | 240 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 188 | 241 | //$last_exec['aircraftlistjson'] = 0; |
| 189 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 244 | + } |
|
| 190 | 245 | } else if (preg_match('/aircraft$/i',$host)) { |
| 191 | 246 | //$formats[$id] = 'planefinderclient'; |
| 192 | 247 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 193 | 248 | //$last_exec['aircraftlistjson'] = 0; |
| 194 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 249 | + if ($globalDebug) { |
|
| 250 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 251 | + } |
|
| 195 | 252 | } else if (preg_match('/opensky/i',$host)) { |
| 196 | 253 | //$formats[$id] = 'aircraftlistjson'; |
| 197 | 254 | $globalSources[$id]['format'] = 'opensky'; |
| 198 | 255 | //$last_exec['aircraftlistjson'] = 0; |
| 199 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 256 | + if ($globalDebug) { |
|
| 257 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 258 | + } |
|
| 200 | 259 | /* |
| 201 | 260 | // Disabled for now, site change source format |
| 202 | 261 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -213,7 +272,9 @@ discard block |
||
| 213 | 272 | //$formats[$id] = 'planeupdatefaa'; |
| 214 | 273 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 215 | 274 | //$last_exec['planeupdatefaa'] = 0; |
| 216 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 275 | + if ($globalDebug) { |
|
| 276 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 277 | + } |
|
| 217 | 278 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 218 | 279 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 219 | 280 | exit(0); |
@@ -222,37 +283,53 @@ discard block |
||
| 222 | 283 | //$formats[$id] = 'phpvmacars'; |
| 223 | 284 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 224 | 285 | //$last_exec['phpvmacars'] = 0; |
| 225 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 286 | + if ($globalDebug) { |
|
| 287 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 288 | + } |
|
| 226 | 289 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 227 | 290 | //$formats[$id] = 'phpvmacars'; |
| 228 | 291 | $globalSources[$id]['format'] = 'vaos'; |
| 229 | 292 | //$last_exec['phpvmacars'] = 0; |
| 230 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 293 | + if ($globalDebug) { |
|
| 294 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 295 | + } |
|
| 231 | 296 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 232 | 297 | //$formats[$id] = 'phpvmacars'; |
| 233 | 298 | $globalSources[$id]['format'] = 'vam'; |
| 234 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 299 | + if ($globalDebug) { |
|
| 300 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 301 | + } |
|
| 235 | 302 | } else if (preg_match('/whazzup/i',$host)) { |
| 236 | 303 | //$formats[$id] = 'whazzup'; |
| 237 | 304 | $globalSources[$id]['format'] = 'whazzup'; |
| 238 | 305 | //$last_exec['whazzup'] = 0; |
| 239 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 306 | + if ($globalDebug) { |
|
| 307 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 308 | + } |
|
| 240 | 309 | } else if (preg_match('/blitzortung/i',$host)) { |
| 241 | 310 | $globalSources[$id]['format'] = 'blitzortung'; |
| 242 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 311 | + if ($globalDebug) { |
|
| 312 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 313 | + } |
|
| 243 | 314 | } else if (preg_match('/airwhere/i',$host)) { |
| 244 | 315 | $globalSources[$id]['format'] = 'airwhere'; |
| 245 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 316 | + if ($globalDebug) { |
|
| 317 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 318 | + } |
|
| 246 | 319 | } else if (preg_match('/recentpireps/i',$host)) { |
| 247 | 320 | //$formats[$id] = 'pirepsjson'; |
| 248 | 321 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 249 | 322 | //$last_exec['pirepsjson'] = 0; |
| 250 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 323 | + if ($globalDebug) { |
|
| 324 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 325 | + } |
|
| 251 | 326 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 252 | 327 | //$formats[$id] = 'fr24json'; |
| 253 | 328 | $globalSources[$id]['format'] = 'fr24json'; |
| 254 | 329 | //$last_exec['fr24json'] = 0; |
| 255 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 330 | + if ($globalDebug) { |
|
| 331 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 332 | + } |
|
| 256 | 333 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 257 | 334 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 258 | 335 | exit(0); |
@@ -261,7 +338,9 @@ discard block |
||
| 261 | 338 | //$formats[$id] = 'fr24json'; |
| 262 | 339 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 263 | 340 | //$last_exec['fr24json'] = 0; |
| 264 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 341 | + if ($globalDebug) { |
|
| 342 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 343 | + } |
|
| 265 | 344 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 266 | 345 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 267 | 346 | exit(0); |
@@ -270,17 +349,26 @@ discard block |
||
| 270 | 349 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 271 | 350 | //$formats[$id] = 'tsv'; |
| 272 | 351 | $globalSources[$id]['format'] = 'tsv'; |
| 273 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 352 | + if ($globalDebug) { |
|
| 353 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 354 | + } |
|
| 274 | 355 | } |
| 275 | 356 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
| 276 | 357 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
| 277 | 358 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 278 | 359 | if ($idf !== false) { |
| 279 | 360 | $httpfeeds[$id] = $idf; |
| 280 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 281 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 282 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 283 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 361 | + if ($globalDebug) { |
|
| 362 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 363 | + } |
|
| 364 | + } elseif ($globalDebug) { |
|
| 365 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 366 | + } |
|
| 367 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
| 368 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 369 | + } elseif ($globalDebug) { |
|
| 370 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 371 | + } |
|
| 284 | 372 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 285 | 373 | $hostport = explode(':',$host); |
| 286 | 374 | if (isset($hostport[1])) { |
@@ -320,19 +408,27 @@ discard block |
||
| 320 | 408 | //$formats[$id] = 'beast'; |
| 321 | 409 | $globalSources[$id]['format'] = 'beast'; |
| 322 | 410 | //} else $formats[$id] = 'sbs'; |
| 323 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 411 | + } else { |
|
| 412 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 413 | + } |
|
| 324 | 414 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 325 | 415 | } |
| 326 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 416 | + if ($globalDebug) { |
|
| 417 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 418 | + } |
|
| 327 | 419 | } else { |
| 328 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 420 | + if ($globalDebug) { |
|
| 421 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 422 | + } |
|
| 329 | 423 | sleep(10); |
| 330 | 424 | connect_all($hosts); |
| 331 | 425 | } |
| 332 | 426 | } |
| 333 | 427 | } |
| 334 | 428 | } |
| 335 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 429 | +if (!isset($globalMinFetch)) { |
|
| 430 | + $globalMinFetch = 15; |
|
| 431 | +} |
|
| 336 | 432 | |
| 337 | 433 | // Initialize all |
| 338 | 434 | $status = array(); |
@@ -341,13 +437,19 @@ discard block |
||
| 341 | 437 | $formats = array(); |
| 342 | 438 | $last_exec = array(); |
| 343 | 439 | $time = time(); |
| 344 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 345 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 346 | -else $timeout = 20; |
|
| 440 | +if (isset($globalSourcesTimeout)) { |
|
| 441 | + $timeout = $globalSourcesTimeOut; |
|
| 442 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 443 | + $timeout = $globalSBS1TimeOut; |
|
| 444 | +} else { |
|
| 445 | + $timeout = 20; |
|
| 446 | +} |
|
| 347 | 447 | $errno = ''; |
| 348 | 448 | $errstr=''; |
| 349 | 449 | |
| 350 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 450 | +if (!isset($globalDaemon)) { |
|
| 451 | + $globalDaemon = TRUE; |
|
| 452 | +} |
|
| 351 | 453 | /* Initiate connections to all the hosts simultaneously */ |
| 352 | 454 | //connect_all($hosts); |
| 353 | 455 | //connect_all($globalSources); |
@@ -376,7 +478,9 @@ discard block |
||
| 376 | 478 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 377 | 479 | $aprs_connect = 0; |
| 378 | 480 | $use_aprs = true; |
| 379 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 481 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 482 | + $aprs_full = true; |
|
| 483 | + } |
|
| 380 | 484 | break; |
| 381 | 485 | } |
| 382 | 486 | } |
@@ -387,25 +491,46 @@ discard block |
||
| 387 | 491 | $aprs_connect = 0; |
| 388 | 492 | $aprs_keep = 120; |
| 389 | 493 | $aprs_last_tx = time(); |
| 390 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 391 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 392 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 393 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 394 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 395 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 396 | - if ($aprs_full) $aprs_filter = ''; |
|
| 397 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 398 | - else $aprs_pass = '-1'; |
|
| 494 | + if (isset($globalAPRSversion)) { |
|
| 495 | + $aprs_version = $globalAPRSversion; |
|
| 496 | + } else { |
|
| 497 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 498 | + } |
|
| 499 | + if (isset($globalAPRSssid)) { |
|
| 500 | + $aprs_ssid = $globalAPRSssid; |
|
| 501 | + } else { |
|
| 502 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 503 | + } |
|
| 504 | + if (isset($globalAPRSfilter)) { |
|
| 505 | + $aprs_filter = $globalAPRSfilter; |
|
| 506 | + } else { |
|
| 507 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 508 | + } |
|
| 509 | + if ($aprs_full) { |
|
| 510 | + $aprs_filter = ''; |
|
| 511 | + } |
|
| 512 | + if (isset($globalAPRSpass)) { |
|
| 513 | + $aprs_pass = $globalAPRSpass; |
|
| 514 | + } else { |
|
| 515 | + $aprs_pass = '-1'; |
|
| 516 | + } |
|
| 399 | 517 | |
| 400 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 401 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 402 | -} |
|
| 518 | + if ($aprs_filter != '') { |
|
| 519 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 520 | + } else { |
|
| 521 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 522 | + } |
|
| 523 | + } |
|
| 403 | 524 | |
| 404 | 525 | // connected - lets do some work |
| 405 | 526 | //if ($globalDebug) echo "Connected!\n"; |
| 406 | 527 | sleep(1); |
| 407 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 408 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 528 | +if ($globalDebug) { |
|
| 529 | + echo "SCAN MODE \n\n"; |
|
| 530 | +} |
|
| 531 | +if (!isset($globalCronEnd)) { |
|
| 532 | + $globalCronEnd = 60; |
|
| 533 | +} |
|
| 409 | 534 | $endtime = time()+$globalCronEnd; |
| 410 | 535 | $i = 1; |
| 411 | 536 | $tt = array(); |
@@ -419,22 +544,32 @@ discard block |
||
| 419 | 544 | |
| 420 | 545 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 421 | 546 | while ($i > 0) { |
| 422 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 547 | + if (function_exists('pcntl_fork')) { |
|
| 548 | + pcntl_signal_dispatch(); |
|
| 549 | + } |
|
| 423 | 550 | |
| 424 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 551 | + if (!$globalDaemon) { |
|
| 552 | + $i = $endtime-time(); |
|
| 553 | + } |
|
| 425 | 554 | // Delete old ATC |
| 426 | 555 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 427 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 556 | + if ($globalDebug) { |
|
| 557 | + echo 'Delete old ATC...'."\n"; |
|
| 558 | + } |
|
| 428 | 559 | $ATC->deleteOldATC(); |
| 429 | 560 | } |
| 430 | 561 | |
| 431 | 562 | if (count($last_exec) == count($globalSources)) { |
| 432 | 563 | $max = $globalMinFetch; |
| 433 | 564 | foreach ($last_exec as $last) { |
| 434 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 565 | + if ((time() - $last['last']) < $max) { |
|
| 566 | + $max = time() - $last['last']; |
|
| 567 | + } |
|
| 435 | 568 | } |
| 436 | 569 | if ($max < $globalMinFetch) { |
| 437 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 570 | + if ($globalDebug) { |
|
| 571 | + echo 'Sleeping...'."\n"; |
|
| 572 | + } |
|
| 438 | 573 | sleep($globalMinFetch-$max+2); |
| 439 | 574 | } |
| 440 | 575 | } |
@@ -444,7 +579,9 @@ discard block |
||
| 444 | 579 | foreach ($globalSources as $id => $value) { |
| 445 | 580 | date_default_timezone_set('UTC'); |
| 446 | 581 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 447 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 582 | + if (!isset($last_exec[$id]['last'])) { |
|
| 583 | + $last_exec[$id]['last'] = 0; |
|
| 584 | + } |
|
| 448 | 585 | if ($value['format'] === 'deltadbtxt' && |
| 449 | 586 | ( |
| 450 | 587 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -453,7 +590,9 @@ discard block |
||
| 453 | 590 | ) { |
| 454 | 591 | //$buffer = $Common->getData($hosts[$id]); |
| 455 | 592 | $buffer = $Common->getData($value['host']); |
| 456 | - if ($buffer != '') $reset = 0; |
|
| 593 | + if ($buffer != '') { |
|
| 594 | + $reset = 0; |
|
| 595 | + } |
|
| 457 | 596 | $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
| 458 | 597 | $buffer = explode('\n', $buffer); |
| 459 | 598 | foreach ($buffer as $line) { |
@@ -462,20 +601,41 @@ discard block |
||
| 462 | 601 | $data = array(); |
| 463 | 602 | $data['hex'] = $line[1]; // hex |
| 464 | 603 | $data['ident'] = $line[2]; // ident |
| 465 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 466 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 467 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 468 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 469 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 604 | + if (isset($line[3])) { |
|
| 605 | + $data['altitude'] = $line[3]; |
|
| 606 | + } |
|
| 607 | + // altitude |
|
| 608 | + if (isset($line[4])) { |
|
| 609 | + $data['speed'] = $line[4]; |
|
| 610 | + } |
|
| 611 | + // speed |
|
| 612 | + if (isset($line[5])) { |
|
| 613 | + $data['heading'] = $line[5]; |
|
| 614 | + } |
|
| 615 | + // heading |
|
| 616 | + if (isset($line[6])) { |
|
| 617 | + $data['latitude'] = $line[6]; |
|
| 618 | + } |
|
| 619 | + // lat |
|
| 620 | + if (isset($line[7])) { |
|
| 621 | + $data['longitude'] = $line[7]; |
|
| 622 | + } |
|
| 623 | + // long |
|
| 470 | 624 | $data['verticalrate'] = ''; // vertical rate |
| 471 | 625 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 472 | 626 | $data['emergency'] = ''; // emergency |
| 473 | 627 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 474 | 628 | $data['format_source'] = 'deltadbtxt'; |
| 475 | 629 | $data['id_source'] = $id_source; |
| 476 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 477 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 478 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 630 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 631 | + $data['source_name'] = $value['name']; |
|
| 632 | + } |
|
| 633 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 634 | + $data['noarchive'] = true; |
|
| 635 | + } |
|
| 636 | + if (isset($value['sourcestats'])) { |
|
| 637 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 638 | + } |
|
| 479 | 639 | $SI->add($data); |
| 480 | 640 | unset($data); |
| 481 | 641 | } |
@@ -508,9 +668,15 @@ discard block |
||
| 508 | 668 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 509 | 669 | $data['format_source'] = 'radarcapejson'; |
| 510 | 670 | $data['id_source'] = $id_source; |
| 511 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 512 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 513 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 671 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 672 | + $data['source_name'] = $value['name']; |
|
| 673 | + } |
|
| 674 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 675 | + $data['noarchive'] = true; |
|
| 676 | + } |
|
| 677 | + if (isset($value['sourcestats'])) { |
|
| 678 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 679 | + } |
|
| 514 | 680 | $SI->add($data); |
| 515 | 681 | unset($data); |
| 516 | 682 | } |
@@ -525,7 +691,9 @@ discard block |
||
| 525 | 691 | date_default_timezone_set('CET'); |
| 526 | 692 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 527 | 693 | date_default_timezone_set('UTC'); |
| 528 | - if ($buffer != '') $reset = 0; |
|
| 694 | + if ($buffer != '') { |
|
| 695 | + $reset = 0; |
|
| 696 | + } |
|
| 529 | 697 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 530 | 698 | $buffer = explode('\n',$buffer); |
| 531 | 699 | foreach ($buffer as $line) { |
@@ -534,18 +702,42 @@ discard block |
||
| 534 | 702 | $add = false; |
| 535 | 703 | $ais_data = $AIS->parse_line(trim($line)); |
| 536 | 704 | $data = array(); |
| 537 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 538 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 539 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 540 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 541 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 542 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 543 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 544 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 545 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 546 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 547 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 548 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 705 | + if (isset($ais_data['ident'])) { |
|
| 706 | + $data['ident'] = $ais_data['ident']; |
|
| 707 | + } |
|
| 708 | + if (isset($ais_data['mmsi'])) { |
|
| 709 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 710 | + } |
|
| 711 | + if (isset($ais_data['speed'])) { |
|
| 712 | + $data['speed'] = $ais_data['speed']; |
|
| 713 | + } |
|
| 714 | + if (isset($ais_data['heading'])) { |
|
| 715 | + $data['heading'] = $ais_data['heading']; |
|
| 716 | + } |
|
| 717 | + if (isset($ais_data['latitude'])) { |
|
| 718 | + $data['latitude'] = $ais_data['latitude']; |
|
| 719 | + } |
|
| 720 | + if (isset($ais_data['longitude'])) { |
|
| 721 | + $data['longitude'] = $ais_data['longitude']; |
|
| 722 | + } |
|
| 723 | + if (isset($ais_data['status'])) { |
|
| 724 | + $data['status'] = $ais_data['status']; |
|
| 725 | + } |
|
| 726 | + if (isset($ais_data['statusid'])) { |
|
| 727 | + $data['status_id'] = $ais_data['statusid']; |
|
| 728 | + } |
|
| 729 | + if (isset($ais_data['type'])) { |
|
| 730 | + $data['type'] = $ais_data['type']; |
|
| 731 | + } |
|
| 732 | + if (isset($ais_data['typeid'])) { |
|
| 733 | + $data['type_id'] = $ais_data['typeid']; |
|
| 734 | + } |
|
| 735 | + if (isset($ais_data['imo'])) { |
|
| 736 | + $data['imo'] = $ais_data['imo']; |
|
| 737 | + } |
|
| 738 | + if (isset($ais_data['callsign'])) { |
|
| 739 | + $data['callsign'] = $ais_data['callsign']; |
|
| 740 | + } |
|
| 549 | 741 | if (isset($ais_data['timestamp'])) { |
| 550 | 742 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 551 | 743 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -559,8 +751,12 @@ discard block |
||
| 559 | 751 | $data['format_source'] = 'aisnmeatxt'; |
| 560 | 752 | $data['id_source'] = $id_source; |
| 561 | 753 | //print_r($data); |
| 562 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 563 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 754 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 755 | + $data['noarchive'] = true; |
|
| 756 | + } |
|
| 757 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 758 | + $MI->add($data); |
|
| 759 | + } |
|
| 564 | 760 | unset($data); |
| 565 | 761 | } |
| 566 | 762 | } |
@@ -583,20 +779,48 @@ discard block |
||
| 583 | 779 | if ($line != '') { |
| 584 | 780 | $ais_data = $AIS->parse_line(trim($line)); |
| 585 | 781 | $data = array(); |
| 586 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 587 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 588 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 589 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 590 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 591 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 592 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 593 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 594 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 595 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 596 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 597 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 598 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 599 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 782 | + if (isset($ais_data['ident'])) { |
|
| 783 | + $data['ident'] = $ais_data['ident']; |
|
| 784 | + } |
|
| 785 | + if (isset($ais_data['mmsi'])) { |
|
| 786 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 787 | + } |
|
| 788 | + if (isset($ais_data['speed'])) { |
|
| 789 | + $data['speed'] = $ais_data['speed']; |
|
| 790 | + } |
|
| 791 | + if (isset($ais_data['heading'])) { |
|
| 792 | + $data['heading'] = $ais_data['heading']; |
|
| 793 | + } |
|
| 794 | + if (isset($ais_data['latitude'])) { |
|
| 795 | + $data['latitude'] = $ais_data['latitude']; |
|
| 796 | + } |
|
| 797 | + if (isset($ais_data['longitude'])) { |
|
| 798 | + $data['longitude'] = $ais_data['longitude']; |
|
| 799 | + } |
|
| 800 | + if (isset($ais_data['status'])) { |
|
| 801 | + $data['status'] = $ais_data['status']; |
|
| 802 | + } |
|
| 803 | + if (isset($ais_data['statusid'])) { |
|
| 804 | + $data['status_id'] = $ais_data['statusid']; |
|
| 805 | + } |
|
| 806 | + if (isset($ais_data['type'])) { |
|
| 807 | + $data['type'] = $ais_data['type']; |
|
| 808 | + } |
|
| 809 | + if (isset($ais_data['typeid'])) { |
|
| 810 | + $data['type_id'] = $ais_data['typeid']; |
|
| 811 | + } |
|
| 812 | + if (isset($ais_data['imo'])) { |
|
| 813 | + $data['imo'] = $ais_data['imo']; |
|
| 814 | + } |
|
| 815 | + if (isset($ais_data['callsign'])) { |
|
| 816 | + $data['callsign'] = $ais_data['callsign']; |
|
| 817 | + } |
|
| 818 | + if (isset($ais_data['destination'])) { |
|
| 819 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 820 | + } |
|
| 821 | + if (isset($ais_data['eta_ts'])) { |
|
| 822 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 823 | + } |
|
| 600 | 824 | if (isset($ais_data['timestamp'])) { |
| 601 | 825 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 602 | 826 | } else { |
@@ -604,18 +828,27 @@ discard block |
||
| 604 | 828 | } |
| 605 | 829 | $data['format_source'] = 'aisnmeahttp'; |
| 606 | 830 | $data['id_source'] = $id_source; |
| 607 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 608 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 831 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 832 | + $data['noarchive'] = true; |
|
| 833 | + } |
|
| 834 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 835 | + $MI->add($data); |
|
| 836 | + } |
|
| 609 | 837 | unset($data); |
| 610 | 838 | } |
| 611 | 839 | } |
| 612 | 840 | } |
| 613 | 841 | } else { |
| 614 | 842 | $format = $value['format']; |
| 615 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 616 | - else $tt[$format] = 0; |
|
| 843 | + if (isset($tt[$format])) { |
|
| 844 | + $tt[$format]++; |
|
| 845 | + } else { |
|
| 846 | + $tt[$format] = 0; |
|
| 847 | + } |
|
| 617 | 848 | if ($tt[$format] > 30) { |
| 618 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 849 | + if ($globalDebug) { |
|
| 850 | + echo 'Reconnect...'."\n"; |
|
| 851 | + } |
|
| 619 | 852 | sleep(2); |
| 620 | 853 | //$sourceeen[] = $value; |
| 621 | 854 | //connect_all($sourceeen); |
@@ -651,12 +884,18 @@ discard block |
||
| 651 | 884 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 652 | 885 | //$data['type_id'] = $line['TYPE']; |
| 653 | 886 | $data['imo'] = $line['IMO']; |
| 654 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 655 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 887 | + if ($line['DEST'] != '') { |
|
| 888 | + $data['arrival_code'] = $line['DEST']; |
|
| 889 | + } |
|
| 890 | + if ($line['ARV'] != '') { |
|
| 891 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 892 | + } |
|
| 656 | 893 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 657 | 894 | $data['format_source'] = 'myshiptracking'; |
| 658 | 895 | $data['id_source'] = $id_source; |
| 659 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 896 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 897 | + $data['noarchive'] = true; |
|
| 898 | + } |
|
| 660 | 899 | $MI->add($data); |
| 661 | 900 | unset($data); |
| 662 | 901 | } |
@@ -681,7 +920,9 @@ discard block |
||
| 681 | 920 | $data['callsign'] = $line['callsign']; |
| 682 | 921 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 683 | 922 | $data['speed'] = $line['sog']; |
| 684 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 923 | + if ($line['heading'] != '511') { |
|
| 924 | + $data['heading'] = $line['heading']; |
|
| 925 | + } |
|
| 685 | 926 | $data['latitude'] = $line['latitude']; |
| 686 | 927 | $data['longitude'] = $line['longitude']; |
| 687 | 928 | $data['type_id'] = $line['shiptype']; |
@@ -689,7 +930,9 @@ discard block |
||
| 689 | 930 | $data['datetime'] = $line['time']; |
| 690 | 931 | $data['format_source'] = 'boatbeaconapp'; |
| 691 | 932 | $data['id_source'] = $id_source; |
| 692 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 933 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 934 | + $data['noarchive'] = true; |
|
| 935 | + } |
|
| 693 | 936 | $MI->add($data); |
| 694 | 937 | unset($data); |
| 695 | 938 | } |
@@ -711,22 +954,44 @@ discard block |
||
| 711 | 954 | foreach ($all_data['features'] as $line) { |
| 712 | 955 | print_r($line); |
| 713 | 956 | $data = array(); |
| 714 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 715 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 716 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 717 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 718 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 719 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 957 | + if (isset($line['properties']['name'])) { |
|
| 958 | + $data['ident'] = $line['properties']['name']; |
|
| 959 | + } |
|
| 960 | + if (isset($line['properties']['callsign'])) { |
|
| 961 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 962 | + } |
|
| 963 | + if (isset($line['properties']['mmsi'])) { |
|
| 964 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 965 | + } |
|
| 966 | + if (isset($line['properties']['imo'])) { |
|
| 967 | + $data['imo'] = $line['properties']['imo']; |
|
| 968 | + } |
|
| 969 | + if (isset($line['properties']['speed'])) { |
|
| 970 | + $data['speed'] = $line['properties']['speed']; |
|
| 971 | + } |
|
| 972 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 973 | + $data['heading'] = $line['properties']['heading']; |
|
| 974 | + } |
|
| 720 | 975 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 721 | 976 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 722 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 723 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 724 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 977 | + if (isset($line['properties']['vesselType'])) { |
|
| 978 | + $data['type'] = $line['properties']['vesselType']; |
|
| 979 | + } |
|
| 980 | + if (isset($line['properties']['destination'])) { |
|
| 981 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 982 | + } |
|
| 983 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 984 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 985 | + } |
|
| 725 | 986 | $data['format_source'] = 'boatnerd'; |
| 726 | 987 | $data['id_source'] = $id_source; |
| 727 | 988 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 728 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 729 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 989 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 990 | + $data['noarchive'] = true; |
|
| 991 | + } |
|
| 992 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 993 | + $MI->add($data); |
|
| 994 | + } |
|
| 730 | 995 | unset($data); |
| 731 | 996 | } |
| 732 | 997 | } |
@@ -739,11 +1004,17 @@ discard block |
||
| 739 | 1004 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 740 | 1005 | ) |
| 741 | 1006 | ) { |
| 742 | - if ($globalDebug) echo 'download...'; |
|
| 1007 | + if ($globalDebug) { |
|
| 1008 | + echo 'download...'; |
|
| 1009 | + } |
|
| 743 | 1010 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 744 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 1011 | + if ($globalDebug) { |
|
| 1012 | + echo 'done !'."\n"; |
|
| 1013 | + } |
|
| 745 | 1014 | // FIXME: Need more work |
| 746 | - if ($buffer != '') $reset = 0; |
|
| 1015 | + if ($buffer != '') { |
|
| 1016 | + $reset = 0; |
|
| 1017 | + } |
|
| 747 | 1018 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 748 | 1019 | $buffer = explode('\n',$buffer); |
| 749 | 1020 | foreach ($buffer as $line) { |
@@ -769,7 +1040,9 @@ discard block |
||
| 769 | 1040 | //$data['etaTime'] = substr($line,135,5); |
| 770 | 1041 | $data['format_source'] = 'shipplotter'; |
| 771 | 1042 | $data['id_source'] = $id_source; |
| 772 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1043 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1044 | + $data['noarchive'] = true; |
|
| 1045 | + } |
|
| 773 | 1046 | //print_r($data); |
| 774 | 1047 | //echo 'Add...'."\n"; |
| 775 | 1048 | $MI->add($data); |
@@ -792,11 +1065,17 @@ discard block |
||
| 792 | 1065 | } |
| 793 | 1066 | } |
| 794 | 1067 | |
| 795 | - if ($globalDebug) echo '! Download... '; |
|
| 1068 | + if ($globalDebug) { |
|
| 1069 | + echo '! Download... '; |
|
| 1070 | + } |
|
| 796 | 1071 | for ($i =0; $i <= 1; $i++) { |
| 797 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 1072 | + if ($globalDebug) { |
|
| 1073 | + echo 'Racetype: '.$i.' '; |
|
| 1074 | + } |
|
| 798 | 1075 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 799 | - if ($globalDebug) echo 'done'."\n"; |
|
| 1076 | + if ($globalDebug) { |
|
| 1077 | + echo 'done'."\n"; |
|
| 1078 | + } |
|
| 800 | 1079 | if ($buffer != '') { |
| 801 | 1080 | $all_data = json_decode($buffer,true); |
| 802 | 1081 | if (isset($all_data['missions'])) { |
@@ -804,8 +1083,11 @@ discard block |
||
| 804 | 1083 | $mission_user = $mission['usrname']; |
| 805 | 1084 | $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
| 806 | 1085 | if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
| 807 | - if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 808 | - else $racebuffer = ''; |
|
| 1086 | + if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
|
| 1087 | + $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 1088 | + } else { |
|
| 1089 | + $racebuffer = ''; |
|
| 1090 | + } |
|
| 809 | 1091 | $bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 810 | 1092 | } else { |
| 811 | 1093 | $bufferm = ''; |
@@ -869,7 +1151,9 @@ discard block |
||
| 869 | 1151 | $data['captain_id'] = $sail['usrnr']; |
| 870 | 1152 | $data['captain_name'] = $sail['usrname']; |
| 871 | 1153 | $data['race_id'] = $sail['misnr']; |
| 872 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
| 1154 | + if ($sail['rank'] != 'DNF') { |
|
| 1155 | + $data['race_rank'] = $sail['rank']; |
|
| 1156 | + } |
|
| 873 | 1157 | $data['race_time'] = $sail['racetime']; |
| 874 | 1158 | if ($mission_user != '') { |
| 875 | 1159 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -879,7 +1163,9 @@ discard block |
||
| 879 | 1163 | //$data['callsign'] = trim(substr($line,100,7); |
| 880 | 1164 | $data['format_source'] = 'sailaway'; |
| 881 | 1165 | $data['id_source'] = $id_source; |
| 882 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1166 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1167 | + $data['noarchive'] = true; |
|
| 1168 | + } |
|
| 883 | 1169 | //print_r($data); |
| 884 | 1170 | //if ($data['race_id'] == '48') print_r($data); |
| 885 | 1171 | //echo 'Add...'."\n"; |
@@ -921,16 +1207,28 @@ discard block |
||
| 921 | 1207 | $line = explode(':', $line); |
| 922 | 1208 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 923 | 1209 | $data = array(); |
| 924 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 925 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1210 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1211 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1212 | + } else { |
|
| 1213 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1214 | + } |
|
| 926 | 1215 | $data['pilot_id'] = $line[1]; |
| 927 | 1216 | $data['pilot_name'] = $line[2]; |
| 928 | 1217 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 929 | 1218 | $data['ident'] = $line[0]; // ident |
| 930 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1219 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1220 | + $data['altitude'] = $line[7]; |
|
| 1221 | + } |
|
| 1222 | + // altitude |
|
| 931 | 1223 | $data['speed'] = $line[8]; // speed |
| 932 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 933 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1224 | + if (isset($line[45])) { |
|
| 1225 | + $data['heading'] = $line[45]; |
|
| 1226 | + } |
|
| 1227 | + // heading |
|
| 1228 | + elseif (isset($line[38])) { |
|
| 1229 | + $data['heading'] = $line[38]; |
|
| 1230 | + } |
|
| 1231 | + // heading |
|
| 934 | 1232 | $data['latitude'] = $line[5]; // lat |
| 935 | 1233 | $data['longitude'] = $line[6]; // long |
| 936 | 1234 | $data['verticalrate'] = ''; // vertical rate |
@@ -946,7 +1244,9 @@ discard block |
||
| 946 | 1244 | $data['frequency'] = $line[4]; |
| 947 | 1245 | $data['type'] = $line[18]; |
| 948 | 1246 | $data['range'] = $line[19]; |
| 949 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1247 | + if (isset($line[35])) { |
|
| 1248 | + $data['info'] = $line[35]; |
|
| 1249 | + } |
|
| 950 | 1250 | $data['id_source'] = $id_source; |
| 951 | 1251 | //$data['arrival_airport_time'] = ; |
| 952 | 1252 | if ($line[9] != '') { |
@@ -960,27 +1260,47 @@ discard block |
||
| 960 | 1260 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 961 | 1261 | */ |
| 962 | 1262 | $data['format_source'] = $value['format']; |
| 963 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 964 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 965 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 966 | - elseif ($line[3] === 'ATC') { |
|
| 1263 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1264 | + $data['noarchive'] = true; |
|
| 1265 | + } |
|
| 1266 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1267 | + $data['source_name'] = $value['name']; |
|
| 1268 | + } |
|
| 1269 | + if ($line[3] === 'PILOT') { |
|
| 1270 | + $SI->add($data); |
|
| 1271 | + } elseif ($line[3] === 'ATC') { |
|
| 967 | 1272 | //print_r($data); |
| 968 | 1273 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 969 | 1274 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 970 | 1275 | $typec = substr($data['ident'],-3); |
| 971 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 972 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 973 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 974 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 975 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 976 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 977 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 978 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 979 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
| 980 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1276 | + if ($typec === 'APP') { |
|
| 1277 | + $data['type'] = 'Approach'; |
|
| 1278 | + } elseif ($typec === 'TWR') { |
|
| 1279 | + $data['type'] = 'Tower'; |
|
| 1280 | + } elseif ($typec === 'OBS') { |
|
| 1281 | + $data['type'] = 'Observer'; |
|
| 1282 | + } elseif ($typec === 'GND') { |
|
| 1283 | + $data['type'] = 'Ground'; |
|
| 1284 | + } elseif ($typec === 'DEL') { |
|
| 1285 | + $data['type'] = 'Delivery'; |
|
| 1286 | + } elseif ($typec === 'DEP') { |
|
| 1287 | + $data['type'] = 'Departure'; |
|
| 1288 | + } elseif ($typec === 'FSS') { |
|
| 1289 | + $data['type'] = 'Flight Service Station'; |
|
| 1290 | + } elseif ($typec === 'CTR') { |
|
| 1291 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1292 | + } elseif ($data['type'] === '') { |
|
| 1293 | + $data['type'] = 'Observer'; |
|
| 1294 | + } |
|
| 1295 | + if (!isset($data['source_name'])) { |
|
| 1296 | + $data['source_name'] = ''; |
|
| 1297 | + } |
|
| 981 | 1298 | if (isset($ATC)) { |
| 982 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 983 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1299 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1300 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1301 | + } else { |
|
| 1302 | + echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1303 | + } |
|
| 984 | 1304 | } |
| 985 | 1305 | } |
| 986 | 1306 | unset($data); |
@@ -1007,14 +1327,20 @@ discard block |
||
| 1007 | 1327 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 1008 | 1328 | $data['latitude'] = (float)$line['pktLatitude']; |
| 1009 | 1329 | $data['longitude'] = (float)$line['pktLongitude']; |
| 1010 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 1011 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1330 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1331 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1332 | + } |
|
| 1333 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1334 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1335 | + } |
|
| 1012 | 1336 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 1013 | 1337 | $data['altitude_relative'] = 'AMSL'; |
| 1014 | 1338 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 1015 | 1339 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 1016 | 1340 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 1017 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1341 | + if (isset($pilot_data[4])) { |
|
| 1342 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1343 | + } |
|
| 1018 | 1344 | $data['format_source'] = $value['format']; |
| 1019 | 1345 | $SI->add($data); |
| 1020 | 1346 | unset($data); |
@@ -1062,25 +1388,59 @@ discard block |
||
| 1062 | 1388 | foreach ($all_data['acList'] as $line) { |
| 1063 | 1389 | $data = array(); |
| 1064 | 1390 | $data['hex'] = $line['Icao']; // hex |
| 1065 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1066 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1067 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1068 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1069 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1070 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1391 | + if (isset($line['Call'])) { |
|
| 1392 | + $data['ident'] = $line['Call']; |
|
| 1393 | + } |
|
| 1394 | + // ident |
|
| 1395 | + if (isset($line['Alt'])) { |
|
| 1396 | + $data['altitude'] = $line['Alt']; |
|
| 1397 | + } |
|
| 1398 | + // altitude |
|
| 1399 | + if (isset($line['Spd'])) { |
|
| 1400 | + $data['speed'] = $line['Spd']; |
|
| 1401 | + } |
|
| 1402 | + // speed |
|
| 1403 | + if (isset($line['Trak'])) { |
|
| 1404 | + $data['heading'] = $line['Trak']; |
|
| 1405 | + } |
|
| 1406 | + // heading |
|
| 1407 | + if (isset($line['Lat'])) { |
|
| 1408 | + $data['latitude'] = $line['Lat']; |
|
| 1409 | + } |
|
| 1410 | + // lat |
|
| 1411 | + if (isset($line['Long'])) { |
|
| 1412 | + $data['longitude'] = $line['Long']; |
|
| 1413 | + } |
|
| 1414 | + // long |
|
| 1071 | 1415 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1072 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1416 | + if (isset($line['Sqk'])) { |
|
| 1417 | + $data['squawk'] = $line['Sqk']; |
|
| 1418 | + } |
|
| 1419 | + // squawk |
|
| 1073 | 1420 | $data['emergency'] = ''; // emergency |
| 1074 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1075 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1076 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1421 | + if (isset($line['Reg'])) { |
|
| 1422 | + $data['registration'] = $line['Reg']; |
|
| 1423 | + } |
|
| 1424 | + if (isset($line['PosTime'])) { |
|
| 1425 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1426 | + } else { |
|
| 1427 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1428 | + } |
|
| 1077 | 1429 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1078 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1430 | + if (isset($line['Type'])) { |
|
| 1431 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1432 | + } |
|
| 1079 | 1433 | $data['format_source'] = 'aircraftlistjson'; |
| 1080 | 1434 | $data['id_source'] = $id_source; |
| 1081 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1082 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1083 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1435 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1436 | + $data['source_name'] = $value['name']; |
|
| 1437 | + } |
|
| 1438 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1439 | + $data['noarchive'] = true; |
|
| 1440 | + } |
|
| 1441 | + if (isset($data['latitude'])) { |
|
| 1442 | + $SI->add($data); |
|
| 1443 | + } |
|
| 1084 | 1444 | unset($data); |
| 1085 | 1445 | } |
| 1086 | 1446 | } elseif (is_array($all_data)) { |
@@ -1097,17 +1457,26 @@ discard block |
||
| 1097 | 1457 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1098 | 1458 | $data['squawk'] = $line['squawk']; // squawk |
| 1099 | 1459 | $data['emergency'] = ''; // emergency |
| 1100 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1101 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1460 | + if (isset($line['PosTime'])) { |
|
| 1461 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1462 | + } else { |
|
| 1463 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1464 | + } |
|
| 1102 | 1465 | $data['format_source'] = 'aircraftlistjson'; |
| 1103 | 1466 | $data['id_source'] = $id_source; |
| 1104 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1105 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1467 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1468 | + $data['noarchive'] = true; |
|
| 1469 | + } |
|
| 1470 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1471 | + $data['source_name'] = $value['name']; |
|
| 1472 | + } |
|
| 1106 | 1473 | $SI->add($data); |
| 1107 | 1474 | unset($data); |
| 1108 | 1475 | } |
| 1109 | 1476 | } |
| 1110 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1477 | + } elseif ($globalDebug) { |
|
| 1478 | + echo 'No data'."\n"; |
|
| 1479 | + } |
|
| 1111 | 1480 | //$last_exec['aircraftlistjson'] = time(); |
| 1112 | 1481 | $last_exec[$id]['last'] = time(); |
| 1113 | 1482 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1143,8 +1512,12 @@ discard block |
||
| 1143 | 1512 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 1144 | 1513 | $data['format_source'] = 'planeupdatefaa'; |
| 1145 | 1514 | $data['id_source'] = $id_source; |
| 1146 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1147 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1515 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1516 | + $data['noarchive'] = true; |
|
| 1517 | + } |
|
| 1518 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1519 | + $data['source_name'] = $value['name']; |
|
| 1520 | + } |
|
| 1148 | 1521 | $SI->add($data); |
| 1149 | 1522 | unset($data); |
| 1150 | 1523 | } |
@@ -1178,7 +1551,9 @@ discard block |
||
| 1178 | 1551 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1179 | 1552 | $data['format_source'] = 'opensky'; |
| 1180 | 1553 | $data['id_source'] = $id_source; |
| 1181 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1554 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1555 | + $data['noarchive'] = true; |
|
| 1556 | + } |
|
| 1182 | 1557 | $SI->add($data); |
| 1183 | 1558 | unset($data); |
| 1184 | 1559 | } |
@@ -1198,15 +1573,42 @@ discard block |
||
| 1198 | 1573 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1199 | 1574 | $data = array(); |
| 1200 | 1575 | // add support for ground vehicule with ~ in front of hex |
| 1201 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1202 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1203 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1204 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1205 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1206 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1207 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1208 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1209 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1576 | + if (isset($line['hex'])) { |
|
| 1577 | + $data['hex'] = $line['hex']; |
|
| 1578 | + } |
|
| 1579 | + // hex |
|
| 1580 | + if (isset($line['flight'])) { |
|
| 1581 | + $data['ident'] = trim($line['flight']); |
|
| 1582 | + } |
|
| 1583 | + // ident |
|
| 1584 | + if (isset($line['altitude'])) { |
|
| 1585 | + $data['altitude'] = $line['altitude']; |
|
| 1586 | + } |
|
| 1587 | + // altitude |
|
| 1588 | + if (isset($line['speed'])) { |
|
| 1589 | + $data['speed'] = $line['speed']; |
|
| 1590 | + } |
|
| 1591 | + // speed |
|
| 1592 | + if (isset($line['track'])) { |
|
| 1593 | + $data['heading'] = $line['track']; |
|
| 1594 | + } |
|
| 1595 | + // heading |
|
| 1596 | + if (isset($line['lat'])) { |
|
| 1597 | + $data['latitude'] = $line['lat']; |
|
| 1598 | + } |
|
| 1599 | + // lat |
|
| 1600 | + if (isset($line['lon'])) { |
|
| 1601 | + $data['longitude'] = $line['lon']; |
|
| 1602 | + } |
|
| 1603 | + // long |
|
| 1604 | + if (isset($line['vert_rate'])) { |
|
| 1605 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1606 | + } |
|
| 1607 | + // verticale rate |
|
| 1608 | + if (isset($line['squawk'])) { |
|
| 1609 | + $data['squawk'] = $line['squawk']; |
|
| 1610 | + } |
|
| 1611 | + // squawk |
|
| 1210 | 1612 | //$data['emergency'] = ''; // emergency |
| 1211 | 1613 | //$data['registration'] = $line[2]; |
| 1212 | 1614 | //$data['aircraft_icao'] = $line[0]; |
@@ -1214,10 +1616,17 @@ discard block |
||
| 1214 | 1616 | $data['format_source'] = 'aircraftjson'; |
| 1215 | 1617 | $data['id_source'] = $id_source; |
| 1216 | 1618 | if (isset($value['name']) && $value['name'] != '') { |
| 1217 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1218 | - else $data['source_name'] = $value['name']; |
|
| 1219 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1619 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1620 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1621 | + } else { |
|
| 1622 | + $data['source_name'] = $value['name']; |
|
| 1623 | + } |
|
| 1624 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1625 | + $data['source_name'] = 'MLAT'; |
|
| 1626 | + } |
|
| 1627 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1628 | + $data['noarchive'] = true; |
|
| 1629 | + } |
|
| 1221 | 1630 | $SI->add($data); |
| 1222 | 1631 | unset($data); |
| 1223 | 1632 | } |
@@ -1237,22 +1646,54 @@ discard block |
||
| 1237 | 1646 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1238 | 1647 | $data = array(); |
| 1239 | 1648 | $data['hex'] = $key; // hex |
| 1240 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1241 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1242 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1243 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1244 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1245 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1246 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1247 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1649 | + if (isset($line['callsign'])) { |
|
| 1650 | + $data['ident'] = trim($line['callsign']); |
|
| 1651 | + } |
|
| 1652 | + // ident |
|
| 1653 | + if (isset($line['altitude'])) { |
|
| 1654 | + $data['altitude'] = $line['altitude']; |
|
| 1655 | + } |
|
| 1656 | + // altitude |
|
| 1657 | + if (isset($line['speed'])) { |
|
| 1658 | + $data['speed'] = $line['speed']; |
|
| 1659 | + } |
|
| 1660 | + // speed |
|
| 1661 | + if (isset($line['heading'])) { |
|
| 1662 | + $data['heading'] = $line['heading']; |
|
| 1663 | + } |
|
| 1664 | + // heading |
|
| 1665 | + if (isset($line['lat'])) { |
|
| 1666 | + $data['latitude'] = $line['lat']; |
|
| 1667 | + } |
|
| 1668 | + // lat |
|
| 1669 | + if (isset($line['lon'])) { |
|
| 1670 | + $data['longitude'] = $line['lon']; |
|
| 1671 | + } |
|
| 1672 | + // long |
|
| 1673 | + if (isset($line['vert_rate'])) { |
|
| 1674 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1675 | + } |
|
| 1676 | + // verticale rate |
|
| 1677 | + if (isset($line['squawk'])) { |
|
| 1678 | + $data['squawk'] = $line['squawk']; |
|
| 1679 | + } |
|
| 1680 | + // squawk |
|
| 1248 | 1681 | //$data['emergency'] = ''; // emergency |
| 1249 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1250 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1682 | + if (isset($line['reg'])) { |
|
| 1683 | + $data['registration'] = $line['reg']; |
|
| 1684 | + } |
|
| 1685 | + if (isset($line['type'])) { |
|
| 1686 | + $data['aircraft_icao'] = $line['type']; |
|
| 1687 | + } |
|
| 1251 | 1688 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
| 1252 | 1689 | $data['format_source'] = 'planefinderclient'; |
| 1253 | 1690 | $data['id_source'] = $id_source; |
| 1254 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1255 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1691 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1692 | + $data['source_name'] = $value['name']; |
|
| 1693 | + } |
|
| 1694 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1695 | + $data['noarchive'] = true; |
|
| 1696 | + } |
|
| 1256 | 1697 | $SI->add($data); |
| 1257 | 1698 | unset($data); |
| 1258 | 1699 | } |
@@ -1268,7 +1709,9 @@ discard block |
||
| 1268 | 1709 | //$buffer = $Common->getData($hosts[$id]); |
| 1269 | 1710 | $buffer = $Common->getData($value['host']); |
| 1270 | 1711 | $all_data = json_decode($buffer,true); |
| 1271 | - if (!empty($all_data)) $reset = 0; |
|
| 1712 | + if (!empty($all_data)) { |
|
| 1713 | + $reset = 0; |
|
| 1714 | + } |
|
| 1272 | 1715 | foreach ($all_data as $key => $line) { |
| 1273 | 1716 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1274 | 1717 | $data = array(); |
@@ -1289,8 +1732,12 @@ discard block |
||
| 1289 | 1732 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1290 | 1733 | $data['format_source'] = 'fr24json'; |
| 1291 | 1734 | $data['id_source'] = $id_source; |
| 1292 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1293 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1735 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1736 | + $data['noarchive'] = true; |
|
| 1737 | + } |
|
| 1738 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1739 | + $data['source_name'] = $value['name']; |
|
| 1740 | + } |
|
| 1294 | 1741 | $SI->add($data); |
| 1295 | 1742 | unset($data); |
| 1296 | 1743 | } |
@@ -1319,24 +1766,42 @@ discard block |
||
| 1319 | 1766 | if (isset($line['inf'])) { |
| 1320 | 1767 | $data = array(); |
| 1321 | 1768 | $data['hex'] = $line['inf']['ia']; |
| 1322 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1769 | + if (isset($line['inf']['cs'])) { |
|
| 1770 | + $data['ident'] = $line['inf']['cs']; |
|
| 1771 | + } |
|
| 1772 | + //$line[13] |
|
| 1323 | 1773 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1324 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1325 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1774 | + if (isset($line['inf']['gs'])) { |
|
| 1775 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1776 | + } |
|
| 1777 | + // speed |
|
| 1778 | + if (isset($line['inf']['tr'])) { |
|
| 1779 | + $data['heading'] = $line['inf']['tr']; |
|
| 1780 | + } |
|
| 1781 | + // heading |
|
| 1326 | 1782 | $data['latitude'] = $line['pt'][0]; // lat |
| 1327 | 1783 | $data['longitude'] = $line['pt'][1]; // long |
| 1328 | 1784 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1329 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1785 | + if (isset($line['inf']['sq'])) { |
|
| 1786 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1787 | + } |
|
| 1788 | + // squawk |
|
| 1330 | 1789 | //$data['aircraft_icao'] = $line[8]; |
| 1331 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1790 | + if (isset($line['inf']['rc'])) { |
|
| 1791 | + $data['registration'] = $line['inf']['rc']; |
|
| 1792 | + } |
|
| 1332 | 1793 | //$data['departure_airport_iata'] = $line[11]; |
| 1333 | 1794 | //$data['arrival_airport_iata'] = $line[12]; |
| 1334 | 1795 | //$data['emergency'] = ''; // emergency |
| 1335 | 1796 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1336 | 1797 | $data['format_source'] = 'radarvirtueljson'; |
| 1337 | 1798 | $data['id_source'] = $id_source; |
| 1338 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1339 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1799 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1800 | + $data['noarchive'] = true; |
|
| 1801 | + } |
|
| 1802 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1803 | + $data['source_name'] = $value['name']; |
|
| 1804 | + } |
|
| 1340 | 1805 | $SI->add($data); |
| 1341 | 1806 | unset($data); |
| 1342 | 1807 | } |
@@ -1362,30 +1827,65 @@ discard block |
||
| 1362 | 1827 | $data['id'] = $line['id']; |
| 1363 | 1828 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1364 | 1829 | $data['ident'] = $line['callsign']; // ident |
| 1365 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1366 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1367 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1368 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1369 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1370 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1830 | + if (isset($line['pilotid'])) { |
|
| 1831 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1832 | + } |
|
| 1833 | + // pilot id |
|
| 1834 | + if (isset($line['name'])) { |
|
| 1835 | + $data['pilot_name'] = $line['name']; |
|
| 1836 | + } |
|
| 1837 | + // pilot name |
|
| 1838 | + if (isset($line['alt'])) { |
|
| 1839 | + $data['altitude'] = $line['alt']; |
|
| 1840 | + } |
|
| 1841 | + // altitude |
|
| 1842 | + if (isset($line['gs'])) { |
|
| 1843 | + $data['speed'] = $line['gs']; |
|
| 1844 | + } |
|
| 1845 | + // speed |
|
| 1846 | + if (isset($line['heading'])) { |
|
| 1847 | + $data['heading'] = $line['heading']; |
|
| 1848 | + } |
|
| 1849 | + // heading |
|
| 1850 | + if (isset($line['route'])) { |
|
| 1851 | + $data['waypoints'] = $line['route']; |
|
| 1852 | + } |
|
| 1853 | + // route |
|
| 1371 | 1854 | $data['latitude'] = $line['lat']; // lat |
| 1372 | 1855 | $data['longitude'] = $line['lon']; // long |
| 1373 | 1856 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1374 | 1857 | //$data['squawk'] = $line['squawk']; // squawk |
| 1375 | 1858 | //$data['emergency'] = ''; // emergency |
| 1376 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1377 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1378 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1859 | + if (isset($line['depicao'])) { |
|
| 1860 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1861 | + } |
|
| 1862 | + if (isset($line['deptime'])) { |
|
| 1863 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1864 | + } |
|
| 1865 | + if (isset($line['arricao'])) { |
|
| 1866 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1867 | + } |
|
| 1379 | 1868 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1380 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1381 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1382 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1383 | - else $data['info'] = ''; |
|
| 1869 | + if (isset($line['aircraft'])) { |
|
| 1870 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1871 | + } |
|
| 1872 | + if (isset($line['transponder'])) { |
|
| 1873 | + $data['squawk'] = $line['transponder']; |
|
| 1874 | + } |
|
| 1875 | + if (isset($line['atis'])) { |
|
| 1876 | + $data['info'] = $line['atis']; |
|
| 1877 | + } else { |
|
| 1878 | + $data['info'] = ''; |
|
| 1879 | + } |
|
| 1384 | 1880 | $data['format_source'] = 'pireps'; |
| 1385 | 1881 | $data['id_source'] = $id_source; |
| 1386 | 1882 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1387 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1388 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1883 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1884 | + $data['noarchive'] = true; |
|
| 1885 | + } |
|
| 1886 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1887 | + $data['source_name'] = $value['name']; |
|
| 1888 | + } |
|
| 1389 | 1889 | if ($line['icon'] === 'plane') { |
| 1390 | 1890 | $SI->add($data); |
| 1391 | 1891 | // print_r($data); |
@@ -1394,16 +1894,28 @@ discard block |
||
| 1394 | 1894 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1395 | 1895 | $typec = substr($data['ident'],-3); |
| 1396 | 1896 | $data['type'] = ''; |
| 1397 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1398 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1399 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1400 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1401 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1402 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1403 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1404 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1405 | - else $data['type'] = 'Observer'; |
|
| 1406 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1897 | + if ($typec === 'APP') { |
|
| 1898 | + $data['type'] = 'Approach'; |
|
| 1899 | + } elseif ($typec === 'TWR') { |
|
| 1900 | + $data['type'] = 'Tower'; |
|
| 1901 | + } elseif ($typec === 'OBS') { |
|
| 1902 | + $data['type'] = 'Observer'; |
|
| 1903 | + } elseif ($typec === 'GND') { |
|
| 1904 | + $data['type'] = 'Ground'; |
|
| 1905 | + } elseif ($typec === 'DEL') { |
|
| 1906 | + $data['type'] = 'Delivery'; |
|
| 1907 | + } elseif ($typec === 'DEP') { |
|
| 1908 | + $data['type'] = 'Departure'; |
|
| 1909 | + } elseif ($typec === 'FSS') { |
|
| 1910 | + $data['type'] = 'Flight Service Station'; |
|
| 1911 | + } elseif ($typec === 'CTR') { |
|
| 1912 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1913 | + } else { |
|
| 1914 | + $data['type'] = 'Observer'; |
|
| 1915 | + } |
|
| 1916 | + if (isset($ATC)) { |
|
| 1917 | + echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1918 | + } |
|
| 1407 | 1919 | } |
| 1408 | 1920 | unset($data); |
| 1409 | 1921 | } |
@@ -1418,7 +1930,9 @@ discard block |
||
| 1418 | 1930 | ) |
| 1419 | 1931 | ) { |
| 1420 | 1932 | //$buffer = $Common->getData($hosts[$id]); |
| 1421 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1933 | + if ($globalDebug) { |
|
| 1934 | + echo 'Get Data...'."\n"; |
|
| 1935 | + } |
|
| 1422 | 1936 | $buffer = $Common->getData($value['host']); |
| 1423 | 1937 | $all_data = json_decode($buffer,true); |
| 1424 | 1938 | if ($buffer != '' && is_array($all_data)) { |
@@ -1426,10 +1940,16 @@ discard block |
||
| 1426 | 1940 | foreach ($all_data as $line) { |
| 1427 | 1941 | $data = array(); |
| 1428 | 1942 | //$data['id'] = $line['id']; // id not usable |
| 1429 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1943 | + if (isset($line['pilotid'])) { |
|
| 1944 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1945 | + } |
|
| 1430 | 1946 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1431 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1432 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1947 | + if (isset($line['pilotname'])) { |
|
| 1948 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1949 | + } |
|
| 1950 | + if (isset($line['pilotid'])) { |
|
| 1951 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1952 | + } |
|
| 1433 | 1953 | $data['ident'] = $line['flightnum']; // ident |
| 1434 | 1954 | $data['altitude'] = $line['alt']; // altitude |
| 1435 | 1955 | $data['speed'] = $line['gs']; // speed |
@@ -1445,7 +1965,9 @@ discard block |
||
| 1445 | 1965 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1446 | 1966 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1447 | 1967 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1448 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1968 | + } else { |
|
| 1969 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1970 | + } |
|
| 1449 | 1971 | $data['departure_airport_icao'] = $line['depicao']; |
| 1450 | 1972 | $data['departure_airport_time'] = $line['deptime']; |
| 1451 | 1973 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1453,29 +1975,47 @@ discard block |
||
| 1453 | 1975 | if (isset($line['registration'])) { |
| 1454 | 1976 | $data['registration'] = $line['registration']; |
| 1455 | 1977 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1456 | - } else $data['registration'] = $line['aircraft']; |
|
| 1457 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1458 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1978 | + } else { |
|
| 1979 | + $data['registration'] = $line['aircraft']; |
|
| 1980 | + } |
|
| 1981 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1982 | + $data['noarchive'] = true; |
|
| 1983 | + } |
|
| 1984 | + if (isset($line['route'])) { |
|
| 1985 | + $data['waypoints'] = $line['route']; |
|
| 1986 | + } |
|
| 1987 | + // route |
|
| 1459 | 1988 | if (isset($line['aircraftname'])) { |
| 1460 | 1989 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1461 | 1990 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1462 | 1991 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1463 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1464 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1465 | - else { |
|
| 1992 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1993 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1994 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1995 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1996 | + } else { |
|
| 1466 | 1997 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1467 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1468 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1998 | + if (isset($aircraft_data[1])) { |
|
| 1999 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 2000 | + } else { |
|
| 2001 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2002 | + } |
|
| 1469 | 2003 | } |
| 1470 | 2004 | } |
| 1471 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 2005 | + if (isset($line['route'])) { |
|
| 2006 | + $data['waypoints'] = $line['route']; |
|
| 2007 | + } |
|
| 1472 | 2008 | $data['id_source'] = $id_source; |
| 1473 | 2009 | $data['format_source'] = 'phpvmacars'; |
| 1474 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2010 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2011 | + $data['source_name'] = $value['name']; |
|
| 2012 | + } |
|
| 1475 | 2013 | $SI->add($data); |
| 1476 | 2014 | unset($data); |
| 1477 | 2015 | } |
| 1478 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2016 | + if ($globalDebug) { |
|
| 2017 | + echo 'No more data...'."\n"; |
|
| 2018 | + } |
|
| 1479 | 2019 | unset($buffer); |
| 1480 | 2020 | unset($all_data); |
| 1481 | 2021 | } |
@@ -1488,7 +2028,9 @@ discard block |
||
| 1488 | 2028 | ) |
| 1489 | 2029 | ) { |
| 1490 | 2030 | //$buffer = $Common->getData($hosts[$id]); |
| 1491 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2031 | + if ($globalDebug) { |
|
| 2032 | + echo 'Get Data...'."\n"; |
|
| 2033 | + } |
|
| 1492 | 2034 | $buffer = $Common->getData($value['host']); |
| 1493 | 2035 | $all_data = json_decode($buffer,true); |
| 1494 | 2036 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1499,10 +2041,16 @@ discard block |
||
| 1499 | 2041 | //$data['id'] = $line['id']; // id not usable |
| 1500 | 2042 | $data['id'] = $line['id']; |
| 1501 | 2043 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1502 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1503 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 2044 | + if (isset($line['user']['username'])) { |
|
| 2045 | + $data['pilot_name'] = $line['user']['username']; |
|
| 2046 | + } |
|
| 2047 | + if (isset($line['user_id'])) { |
|
| 2048 | + $data['pilot_id'] = $line['user_id']; |
|
| 2049 | + } |
|
| 1504 | 2050 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1505 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2051 | + if (is_numeric($data['ident'])) { |
|
| 2052 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2053 | + } |
|
| 1506 | 2054 | $data['altitude'] = $line['altitude']; // altitude |
| 1507 | 2055 | $data['speed'] = $line['groundspeed']; // speed |
| 1508 | 2056 | $data['heading'] = $line['heading']; // heading |
@@ -1515,7 +2063,9 @@ discard block |
||
| 1515 | 2063 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1516 | 2064 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1517 | 2065 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1518 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2066 | + } else { |
|
| 2067 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2068 | + } |
|
| 1519 | 2069 | |
| 1520 | 2070 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1521 | 2071 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1523,17 +2073,26 @@ discard block |
||
| 1523 | 2073 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1524 | 2074 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1525 | 2075 | |
| 1526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1527 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 2076 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2077 | + $data['noarchive'] = true; |
|
| 2078 | + } |
|
| 2079 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 2080 | + $data['waypoints'] = $line['bid']['route']; |
|
| 2081 | + } |
|
| 2082 | + // route |
|
| 1528 | 2083 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1529 | 2084 | |
| 1530 | 2085 | $data['id_source'] = $id_source; |
| 1531 | 2086 | $data['format_source'] = 'vaos'; |
| 1532 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2087 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2088 | + $data['source_name'] = $value['name']; |
|
| 2089 | + } |
|
| 1533 | 2090 | $SI->add($data); |
| 1534 | 2091 | unset($data); |
| 1535 | 2092 | } |
| 1536 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2093 | + if ($globalDebug) { |
|
| 2094 | + echo 'No more data...'."\n"; |
|
| 2095 | + } |
|
| 1537 | 2096 | unset($buffer); |
| 1538 | 2097 | unset($all_data); |
| 1539 | 2098 | } |
@@ -1546,7 +2105,9 @@ discard block |
||
| 1546 | 2105 | ) |
| 1547 | 2106 | ) { |
| 1548 | 2107 | //$buffer = $Common->getData($hosts[$id]); |
| 1549 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2108 | + if ($globalDebug) { |
|
| 2109 | + echo 'Get Data...'."\n"; |
|
| 2110 | + } |
|
| 1550 | 2111 | $buffer = $Common->getData($value['host']); |
| 1551 | 2112 | $all_data = json_decode($buffer,true); |
| 1552 | 2113 | if ($buffer != '' && is_array($all_data)) { |
@@ -1575,16 +2136,25 @@ discard block |
||
| 1575 | 2136 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1576 | 2137 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1577 | 2138 | //$data['registration'] = $line['aircraft']; |
| 1578 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2139 | + if (isset($line['route'])) { |
|
| 2140 | + $data['waypoints'] = $line['route']; |
|
| 2141 | + } |
|
| 2142 | + // route |
|
| 1579 | 2143 | $data['aircraft_icao'] = $line['plane_type']; |
| 1580 | 2144 | $data['id_source'] = $id_source; |
| 1581 | 2145 | $data['format_source'] = 'vam'; |
| 1582 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1583 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2146 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2147 | + $data['noarchive'] = true; |
|
| 2148 | + } |
|
| 2149 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2150 | + $data['source_name'] = $value['name']; |
|
| 2151 | + } |
|
| 1584 | 2152 | $SI->add($data); |
| 1585 | 2153 | unset($data); |
| 1586 | 2154 | } |
| 1587 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2155 | + if ($globalDebug) { |
|
| 2156 | + echo 'No more data...'."\n"; |
|
| 2157 | + } |
|
| 1588 | 2158 | unset($buffer); |
| 1589 | 2159 | unset($all_data); |
| 1590 | 2160 | } |
@@ -1597,7 +2167,9 @@ discard block |
||
| 1597 | 2167 | ) |
| 1598 | 2168 | ) { |
| 1599 | 2169 | //$buffer = $Common->getData($hosts[$id]); |
| 1600 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2170 | + if ($globalDebug) { |
|
| 2171 | + echo 'Get Data...'."\n"; |
|
| 2172 | + } |
|
| 1601 | 2173 | $buffer = $Common->getData($value['host']); |
| 1602 | 2174 | $all_data = json_decode($buffer,true); |
| 1603 | 2175 | if ($buffer != '') { |
@@ -1615,12 +2187,16 @@ discard block |
||
| 1615 | 2187 | $data['id_source'] = $id_source; |
| 1616 | 2188 | $data['format_source'] = 'blitzortung'; |
| 1617 | 2189 | $SI->add($data); |
| 1618 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2190 | + if ($globalDebug) { |
|
| 2191 | + echo '☈ Lightning added'."\n"; |
|
| 2192 | + } |
|
| 1619 | 2193 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1620 | 2194 | unset($data); |
| 1621 | 2195 | } |
| 1622 | 2196 | } |
| 1623 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2197 | + if ($globalDebug) { |
|
| 2198 | + echo 'No more data...'."\n"; |
|
| 2199 | + } |
|
| 1624 | 2200 | unset($buffer); |
| 1625 | 2201 | } |
| 1626 | 2202 | $last_exec[$id]['last'] = time(); |
@@ -1649,10 +2225,15 @@ discard block |
||
| 1649 | 2225 | } |
| 1650 | 2226 | } else { |
| 1651 | 2227 | $format = $value['format']; |
| 1652 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1653 | - else $tt[$format] = 0; |
|
| 2228 | + if (isset($tt[$format])) { |
|
| 2229 | + $tt[$format]++; |
|
| 2230 | + } else { |
|
| 2231 | + $tt[$format] = 0; |
|
| 2232 | + } |
|
| 1654 | 2233 | if ($tt[$format] > 30) { |
| 1655 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 2234 | + if ($globalDebug) { |
|
| 2235 | + echo 'Reconnect...'."\n"; |
|
| 2236 | + } |
|
| 1656 | 2237 | sleep(2); |
| 1657 | 2238 | //$sourceeen[] = $value; |
| 1658 | 2239 | //connect_all($sourceeen); |
@@ -1669,7 +2250,9 @@ discard block |
||
| 1669 | 2250 | $write = NULL; |
| 1670 | 2251 | $e = NULL; |
| 1671 | 2252 | $n = socket_select($read, $write, $e, $timeout); |
| 1672 | - if ($e != NULL) var_dump($e); |
|
| 2253 | + if ($e != NULL) { |
|
| 2254 | + var_dump($e); |
|
| 2255 | + } |
|
| 1673 | 2256 | if ($n > 0) { |
| 1674 | 2257 | $reset = 0; |
| 1675 | 2258 | foreach ($read as $nb => $r) { |
@@ -1691,13 +2274,17 @@ discard block |
||
| 1691 | 2274 | if ($buffer !== FALSE) { |
| 1692 | 2275 | if ($format === 'vrstcp') { |
| 1693 | 2276 | $buffer = explode('},{',$buffer); |
| 1694 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2277 | + } else { |
|
| 2278 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2279 | + } |
|
| 1695 | 2280 | } |
| 1696 | 2281 | // SBS format is CSV format |
| 1697 | 2282 | if ($buffer !== FALSE && $buffer !== '') { |
| 1698 | 2283 | $tt[$format] = 0; |
| 1699 | 2284 | if ($format === 'acarssbs3') { |
| 1700 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2285 | + if ($globalDebug) { |
|
| 2286 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2287 | + } |
|
| 1701 | 2288 | $ACARS->add(trim($buffer)); |
| 1702 | 2289 | $ACARS->deleteLiveAcarsData(); |
| 1703 | 2290 | } elseif ($format === 'raw') { |
@@ -1707,9 +2294,15 @@ discard block |
||
| 1707 | 2294 | //if (!empty($data)) print_r($data); |
| 1708 | 2295 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1709 | 2296 | $data['format_source'] = 'raw'; |
| 1710 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1711 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1712 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2297 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2298 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2299 | + } |
|
| 2300 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2301 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2302 | + } |
|
| 2303 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2304 | + $data['noarchive'] = true; |
|
| 2305 | + } |
|
| 1713 | 2306 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1714 | 2307 | $SI->add($data); |
| 1715 | 2308 | unset($data); |
@@ -1717,22 +2310,54 @@ discard block |
||
| 1717 | 2310 | } elseif ($format === 'ais') { |
| 1718 | 2311 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1719 | 2312 | $data = array(); |
| 1720 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1721 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1722 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1723 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1724 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1725 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1726 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1727 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1728 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1729 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1730 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1731 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1732 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1733 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1734 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1735 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2313 | + if (isset($ais_data['ident'])) { |
|
| 2314 | + $data['ident'] = $ais_data['ident']; |
|
| 2315 | + } |
|
| 2316 | + if (isset($ais_data['mmsi'])) { |
|
| 2317 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 2318 | + } |
|
| 2319 | + if (isset($ais_data['speed'])) { |
|
| 2320 | + $data['speed'] = $ais_data['speed']; |
|
| 2321 | + } |
|
| 2322 | + if (isset($ais_data['heading'])) { |
|
| 2323 | + $data['heading'] = $ais_data['heading']; |
|
| 2324 | + } |
|
| 2325 | + if (isset($ais_data['latitude'])) { |
|
| 2326 | + $data['latitude'] = $ais_data['latitude']; |
|
| 2327 | + } |
|
| 2328 | + if (isset($ais_data['longitude'])) { |
|
| 2329 | + $data['longitude'] = $ais_data['longitude']; |
|
| 2330 | + } |
|
| 2331 | + if (isset($ais_data['status'])) { |
|
| 2332 | + $data['status'] = $ais_data['status']; |
|
| 2333 | + } |
|
| 2334 | + if (isset($ais_data['statusid'])) { |
|
| 2335 | + $data['status_id'] = $ais_data['statusid']; |
|
| 2336 | + } |
|
| 2337 | + if (isset($ais_data['type'])) { |
|
| 2338 | + $data['type'] = $ais_data['type']; |
|
| 2339 | + } |
|
| 2340 | + if (isset($ais_data['imo'])) { |
|
| 2341 | + $data['imo'] = $ais_data['imo']; |
|
| 2342 | + } |
|
| 2343 | + if (isset($ais_data['callsign'])) { |
|
| 2344 | + $data['callsign'] = $ais_data['callsign']; |
|
| 2345 | + } |
|
| 2346 | + if (isset($ais_data['destination'])) { |
|
| 2347 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 2348 | + } |
|
| 2349 | + if (isset($ais_data['eta_ts'])) { |
|
| 2350 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 2351 | + } |
|
| 2352 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2353 | + $data['noarchive'] = true; |
|
| 2354 | + } |
|
| 2355 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2356 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2357 | + } |
|
| 2358 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2359 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2360 | + } |
|
| 1736 | 2361 | |
| 1737 | 2362 | if (isset($ais_data['timestamp'])) { |
| 1738 | 2363 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1741,7 +2366,9 @@ discard block |
||
| 1741 | 2366 | } |
| 1742 | 2367 | $data['format_source'] = 'aisnmea'; |
| 1743 | 2368 | $data['id_source'] = $id_source; |
| 1744 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 2369 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 2370 | + $MI->add($data); |
|
| 2371 | + } |
|
| 1745 | 2372 | unset($data); |
| 1746 | 2373 | } elseif ($format === 'flightgearsp') { |
| 1747 | 2374 | //echo $buffer."\n"; |
@@ -1759,12 +2386,18 @@ discard block |
||
| 1759 | 2386 | $data['speed'] = round($line[5]*1.94384); |
| 1760 | 2387 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1761 | 2388 | $data['format_source'] = 'flightgearsp'; |
| 1762 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1763 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2389 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2390 | + $data['noarchive'] = true; |
|
| 2391 | + } |
|
| 2392 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2393 | + $SI->add($data); |
|
| 2394 | + } |
|
| 1764 | 2395 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1765 | 2396 | } |
| 1766 | 2397 | } elseif ($format === 'acars') { |
| 1767 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2398 | + if ($globalDebug) { |
|
| 2399 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2400 | + } |
|
| 1768 | 2401 | $ACARS->add(trim($buffer)); |
| 1769 | 2402 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1770 | 2403 | $ACARS->deleteLiveAcarsData(); |
@@ -1785,8 +2418,12 @@ discard block |
||
| 1785 | 2418 | $aircraft_type = $line[10]; |
| 1786 | 2419 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1787 | 2420 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1788 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1789 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2421 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2422 | + $data['noarchive'] = true; |
|
| 2423 | + } |
|
| 2424 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2425 | + $SI->add($data); |
|
| 2426 | + } |
|
| 1790 | 2427 | } |
| 1791 | 2428 | } |
| 1792 | 2429 | } elseif ($format === 'beast') { |
@@ -1796,28 +2433,62 @@ discard block |
||
| 1796 | 2433 | foreach($buffer as $all_data) { |
| 1797 | 2434 | $line = json_decode('{'.$all_data.'}',true); |
| 1798 | 2435 | $data = array(); |
| 1799 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1800 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1801 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1802 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1803 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1804 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1805 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2436 | + if (isset($line['Icao'])) { |
|
| 2437 | + $data['hex'] = $line['Icao']; |
|
| 2438 | + } |
|
| 2439 | + // hex |
|
| 2440 | + if (isset($line['Call'])) { |
|
| 2441 | + $data['ident'] = $line['Call']; |
|
| 2442 | + } |
|
| 2443 | + // ident |
|
| 2444 | + if (isset($line['Alt'])) { |
|
| 2445 | + $data['altitude'] = $line['Alt']; |
|
| 2446 | + } |
|
| 2447 | + // altitude |
|
| 2448 | + if (isset($line['Spd'])) { |
|
| 2449 | + $data['speed'] = $line['Spd']; |
|
| 2450 | + } |
|
| 2451 | + // speed |
|
| 2452 | + if (isset($line['Trak'])) { |
|
| 2453 | + $data['heading'] = $line['Trak']; |
|
| 2454 | + } |
|
| 2455 | + // heading |
|
| 2456 | + if (isset($line['Lat'])) { |
|
| 2457 | + $data['latitude'] = $line['Lat']; |
|
| 2458 | + } |
|
| 2459 | + // lat |
|
| 2460 | + if (isset($line['Long'])) { |
|
| 2461 | + $data['longitude'] = $line['Long']; |
|
| 2462 | + } |
|
| 2463 | + // long |
|
| 1806 | 2464 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1807 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2465 | + if (isset($line['Sqk'])) { |
|
| 2466 | + $data['squawk'] = $line['Sqk']; |
|
| 2467 | + } |
|
| 2468 | + // squawk |
|
| 1808 | 2469 | $data['emergency'] = ''; // emergency |
| 1809 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2470 | + if (isset($line['Reg'])) { |
|
| 2471 | + $data['registration'] = $line['Reg']; |
|
| 2472 | + } |
|
| 1810 | 2473 | /* |
| 1811 | 2474 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1812 | 2475 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1813 | 2476 | */ |
| 1814 | 2477 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1815 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2478 | + if (isset($line['Type'])) { |
|
| 2479 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2480 | + } |
|
| 1816 | 2481 | $data['format_source'] = 'vrstcp'; |
| 1817 | 2482 | $data['id_source'] = $id_source; |
| 1818 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1819 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1820 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2483 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2484 | + $data['noarchive'] = true; |
|
| 2485 | + } |
|
| 2486 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2487 | + $data['source_name'] = $value['name']; |
|
| 2488 | + } |
|
| 2489 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2490 | + $SI->add($data); |
|
| 2491 | + } |
|
| 1821 | 2492 | unset($data); |
| 1822 | 2493 | } |
| 1823 | 2494 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1830,22 +2501,46 @@ discard block |
||
| 1830 | 2501 | $data['hex'] = $lined['hexid']; |
| 1831 | 2502 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1832 | 2503 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1833 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1834 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1835 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1836 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1837 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1838 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1839 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2504 | + if (isset($lined['ident'])) { |
|
| 2505 | + $data['ident'] = $lined['ident']; |
|
| 2506 | + } |
|
| 2507 | + if (isset($lined['lat'])) { |
|
| 2508 | + $data['latitude'] = $lined['lat']; |
|
| 2509 | + } |
|
| 2510 | + if (isset($lined['lon'])) { |
|
| 2511 | + $data['longitude'] = $lined['lon']; |
|
| 2512 | + } |
|
| 2513 | + if (isset($lined['speed'])) { |
|
| 2514 | + $data['speed'] = $lined['speed']; |
|
| 2515 | + } |
|
| 2516 | + if (isset($lined['squawk'])) { |
|
| 2517 | + $data['squawk'] = $lined['squawk']; |
|
| 2518 | + } |
|
| 2519 | + if (isset($lined['alt'])) { |
|
| 2520 | + $data['altitude'] = $lined['alt']; |
|
| 2521 | + } |
|
| 2522 | + if (isset($lined['heading'])) { |
|
| 2523 | + $data['heading'] = $lined['heading']; |
|
| 2524 | + } |
|
| 1840 | 2525 | $data['id_source'] = $id_source; |
| 1841 | 2526 | $data['format_source'] = 'tsv'; |
| 1842 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1843 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1844 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1845 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2527 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2528 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2529 | + } |
|
| 2530 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2531 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2532 | + } |
|
| 2533 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2534 | + $data['noarchive'] = true; |
|
| 2535 | + } |
|
| 2536 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2537 | + $SI->add($data); |
|
| 2538 | + } |
|
| 1846 | 2539 | unset($lined); |
| 1847 | 2540 | unset($data); |
| 1848 | - } else $error = true; |
|
| 2541 | + } else { |
|
| 2542 | + $error = true; |
|
| 2543 | + } |
|
| 1849 | 2544 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1850 | 2545 | if ($aprs_connect === 0) { |
| 1851 | 2546 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1871,47 +2566,96 @@ discard block |
||
| 1871 | 2566 | $aprs_last_tx = time(); |
| 1872 | 2567 | $data = array(); |
| 1873 | 2568 | //print_r($line); |
| 1874 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1875 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1876 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1877 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1878 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1879 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1880 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1881 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1882 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1883 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2569 | + if (isset($line['address'])) { |
|
| 2570 | + $data['hex'] = $line['address']; |
|
| 2571 | + } |
|
| 2572 | + if (isset($line['mmsi'])) { |
|
| 2573 | + $data['mmsi'] = $line['mmsi']; |
|
| 2574 | + } |
|
| 2575 | + if (isset($line['imo'])) { |
|
| 2576 | + $data['imo'] = $line['imo']; |
|
| 2577 | + } |
|
| 2578 | + if (isset($line['squawk'])) { |
|
| 2579 | + $data['squawk'] = $line['squawk']; |
|
| 2580 | + } |
|
| 2581 | + if (isset($line['arrival_code'])) { |
|
| 2582 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2583 | + } |
|
| 2584 | + if (isset($line['arrival_date'])) { |
|
| 2585 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2586 | + } |
|
| 2587 | + if (isset($line['typeid'])) { |
|
| 2588 | + $data['type_id'] = $line['typeid']; |
|
| 2589 | + } |
|
| 2590 | + if (isset($line['statusid'])) { |
|
| 2591 | + $data['status_id'] = $line['statusid']; |
|
| 2592 | + } |
|
| 2593 | + if (isset($line['timestamp'])) { |
|
| 2594 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2595 | + } else { |
|
| 2596 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2597 | + } |
|
| 1884 | 2598 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1885 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2599 | + if (isset($line['ident'])) { |
|
| 2600 | + $data['ident'] = $line['ident']; |
|
| 2601 | + } |
|
| 1886 | 2602 | $data['latitude'] = $line['latitude']; |
| 1887 | 2603 | $data['longitude'] = $line['longitude']; |
| 1888 | 2604 | //$data['verticalrate'] = $line[16]; |
| 1889 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2605 | + if (isset($line['speed'])) { |
|
| 2606 | + $data['speed'] = $line['speed']; |
|
| 2607 | + } |
|
| 1890 | 2608 | //else $data['speed'] = 0; |
| 1891 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1892 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1893 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2609 | + if (isset($line['altitude'])) { |
|
| 2610 | + $data['altitude'] = $line['altitude']; |
|
| 2611 | + } |
|
| 2612 | + if (isset($line['comment'])) { |
|
| 2613 | + $data['comment'] = $line['comment']; |
|
| 2614 | + } |
|
| 2615 | + if (isset($line['symbol'])) { |
|
| 2616 | + $data['type'] = $line['symbol']; |
|
| 2617 | + } |
|
| 1894 | 2618 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1895 | 2619 | |
| 1896 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2620 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2621 | + $data['heading'] = $line['heading']; |
|
| 2622 | + } |
|
| 1897 | 2623 | //else echo 'No heading...'."\n"; |
| 1898 | 2624 | //else $data['heading'] = 0; |
| 1899 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2625 | + if (isset($line['stealth'])) { |
|
| 2626 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2627 | + } |
|
| 1900 | 2628 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1901 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1902 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1903 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1904 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2629 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2630 | + $data['noarchive'] = true; |
|
| 2631 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2632 | + $data['noarchive'] = false; |
|
| 2633 | + } |
|
| 2634 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2635 | + $data['noarchive'] = true; |
|
| 2636 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2637 | + $data['noarchive'] = false; |
|
| 2638 | + } |
|
| 1905 | 2639 | $data['id_source'] = $id_source; |
| 1906 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1907 | - else $data['format_source'] = 'aprs'; |
|
| 2640 | + if (isset($line['format_source'])) { |
|
| 2641 | + $data['format_source'] = $line['format_source']; |
|
| 2642 | + } else { |
|
| 2643 | + $data['format_source'] = 'aprs'; |
|
| 2644 | + } |
|
| 1908 | 2645 | $data['source_name'] = $line['source']; |
| 1909 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1910 | - else $data['source_type'] = 'flarm'; |
|
| 1911 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2646 | + if (isset($line['source_type'])) { |
|
| 2647 | + $data['source_type'] = $line['source_type']; |
|
| 2648 | + } else { |
|
| 2649 | + $data['source_type'] = 'flarm'; |
|
| 2650 | + } |
|
| 2651 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2652 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2653 | + } |
|
| 1912 | 2654 | $currentdate = date('Y-m-d H:i:s'); |
| 1913 | 2655 | $aprsdate = strtotime($data['datetime']); |
| 1914 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2656 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2657 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2658 | + } |
|
| 1915 | 2659 | // Accept data if time <= system time + 20s |
| 1916 | 2660 | //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1917 | 2661 | if ( |
@@ -1923,7 +2667,9 @@ discard block |
||
| 1923 | 2667 | $send = $SI->add($data); |
| 1924 | 2668 | } elseif ($data['source_type'] === 'ais') { |
| 1925 | 2669 | $data['type'] = ''; |
| 1926 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2670 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2671 | + $send = $MI->add($data); |
|
| 2672 | + } |
|
| 1927 | 2673 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
| 1928 | 2674 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1929 | 2675 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1931,8 +2677,12 @@ discard block |
||
| 1931 | 2677 | $line['symbol'] === 'Glider' || |
| 1932 | 2678 | $line['symbol'] === 'No. Plane' || |
| 1933 | 2679 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
| 1934 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1935 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2680 | + if ($line['symbol'] === 'Ballon') { |
|
| 2681 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2682 | + } |
|
| 2683 | + if ($line['symbol'] === 'Glider') { |
|
| 2684 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2685 | + } |
|
| 1936 | 2686 | $send = $SI->add($data); |
| 1937 | 2687 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1938 | 2688 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1963,9 +2713,13 @@ discard block |
||
| 1963 | 2713 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1964 | 2714 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1965 | 2715 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1966 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2716 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2717 | + $send = $TI->add($data); |
|
| 2718 | + } |
|
| 1967 | 2719 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1968 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2720 | + if (!isset($data['altitude'])) { |
|
| 2721 | + $data['altitude'] = 0; |
|
| 2722 | + } |
|
| 1969 | 2723 | $Source->deleteOldLocationByType('gs'); |
| 1970 | 2724 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 1971 | 2725 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1974,7 +2728,9 @@ discard block |
||
| 1974 | 2728 | } |
| 1975 | 2729 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 1976 | 2730 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1977 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2731 | + if ($globalDebug) { |
|
| 2732 | + echo '# Weather Station added'."\n"; |
|
| 2733 | + } |
|
| 1978 | 2734 | $Source->deleteOldLocationByType('wx'); |
| 1979 | 2735 | $weather_data = json_encode($line); |
| 1980 | 2736 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1984,7 +2740,9 @@ discard block |
||
| 1984 | 2740 | } |
| 1985 | 2741 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 1986 | 2742 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1987 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2743 | + if ($globalDebug) { |
|
| 2744 | + echo '☈ Lightning added'."\n"; |
|
| 2745 | + } |
|
| 1988 | 2746 | $Source->deleteOldLocationByType('lightning'); |
| 1989 | 2747 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 1990 | 2748 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1996,8 +2754,7 @@ discard block |
||
| 1996 | 2754 | print_r($line); |
| 1997 | 2755 | } |
| 1998 | 2756 | unset($data); |
| 1999 | - } |
|
| 2000 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2757 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2001 | 2758 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 2002 | 2759 | } |
| 2003 | 2760 | /* |
@@ -2006,7 +2763,9 @@ discard block |
||
| 2006 | 2763 | } |
| 2007 | 2764 | */ |
| 2008 | 2765 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 2009 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2766 | + elseif ($line === true && $globalDebug) { |
|
| 2767 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2768 | + } |
|
| 2010 | 2769 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 2011 | 2770 | $Source->deleteOldLocationByType('lightning'); |
| 2012 | 2771 | $Source->deleteOldLocationByType('wx'); |
@@ -2043,27 +2802,47 @@ discard block |
||
| 2043 | 2802 | $data['ground'] = $line[21]; |
| 2044 | 2803 | $data['emergency'] = $line[19]; |
| 2045 | 2804 | $data['format_source'] = 'sbs'; |
| 2046 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2047 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
| 2048 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2049 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2805 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2806 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2807 | + } elseif ($line[0] == 'MLAT') { |
|
| 2808 | + $data['source_name'] = 'MLAT'; |
|
| 2809 | + } |
|
| 2810 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2811 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2812 | + } |
|
| 2813 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2814 | + $data['noarchive'] = true; |
|
| 2815 | + } |
|
| 2050 | 2816 | $data['id_source'] = $id_source; |
| 2051 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2052 | - else $error = true; |
|
| 2817 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2818 | + $send = $SI->add($data); |
|
| 2819 | + } else { |
|
| 2820 | + $error = true; |
|
| 2821 | + } |
|
| 2053 | 2822 | unset($data); |
| 2054 | - } else $error = true; |
|
| 2823 | + } else { |
|
| 2824 | + $error = true; |
|
| 2825 | + } |
|
| 2055 | 2826 | if ($error) { |
| 2056 | 2827 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 2057 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2828 | + if ($globalDebug) { |
|
| 2829 | + echo "Not a message. Ignoring... \n"; |
|
| 2830 | + } |
|
| 2058 | 2831 | } else { |
| 2059 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2832 | + if ($globalDebug) { |
|
| 2833 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2834 | + } |
|
| 2060 | 2835 | if ($globalDebug) { |
| 2061 | 2836 | echo $buffer; |
| 2062 | 2837 | //print_r($line); |
| 2063 | 2838 | } |
| 2064 | 2839 | //socket_close($r); |
| 2065 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 2066 | - if ($format === 'aprs') $aprs_connect = 0; |
|
| 2840 | + if ($globalDebug) { |
|
| 2841 | + echo "Reconnect after an error...\n"; |
|
| 2842 | + } |
|
| 2843 | + if ($format === 'aprs') { |
|
| 2844 | + $aprs_connect = 0; |
|
| 2845 | + } |
|
| 2067 | 2846 | $sourceer[$nb] = $globalSources[$nb]; |
| 2068 | 2847 | connect_all($sourceer); |
| 2069 | 2848 | $sourceer = array(); |
@@ -2071,10 +2850,14 @@ discard block |
||
| 2071 | 2850 | } |
| 2072 | 2851 | } |
| 2073 | 2852 | // Sleep for xxx microseconds |
| 2074 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2853 | + if (isset($globalSBSSleep)) { |
|
| 2854 | + usleep($globalSBSSleep); |
|
| 2855 | + } |
|
| 2075 | 2856 | } else { |
| 2076 | 2857 | if ($format === 'flightgearmp') { |
| 2077 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2858 | + if ($globalDebug) { |
|
| 2859 | + echo "Reconnect FlightGear MP..."; |
|
| 2860 | + } |
|
| 2078 | 2861 | //@socket_close($r); |
| 2079 | 2862 | sleep($globalMinFetch); |
| 2080 | 2863 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2083,10 +2866,15 @@ discard block |
||
| 2083 | 2866 | break; |
| 2084 | 2867 | |
| 2085 | 2868 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2086 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2087 | - else $tt[$format] = 0; |
|
| 2869 | + if (isset($tt[$format])) { |
|
| 2870 | + $tt[$format]++; |
|
| 2871 | + } else { |
|
| 2872 | + $tt[$format] = 0; |
|
| 2873 | + } |
|
| 2088 | 2874 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 2089 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2875 | + if ($globalDebug) { |
|
| 2876 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2877 | + } |
|
| 2090 | 2878 | //@socket_close($r); |
| 2091 | 2879 | sleep(2); |
| 2092 | 2880 | $aprs_connect = 0; |
@@ -2104,11 +2892,17 @@ discard block |
||
| 2104 | 2892 | } else { |
| 2105 | 2893 | $error = socket_strerror(socket_last_error()); |
| 2106 | 2894 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2107 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2108 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2895 | + if ($globalDebug) { |
|
| 2896 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2897 | + } |
|
| 2898 | + if (isset($globalDebug)) { |
|
| 2899 | + echo "Restarting...\n"; |
|
| 2900 | + } |
|
| 2109 | 2901 | // Restart the script if possible |
| 2110 | 2902 | if (is_array($sockets)) { |
| 2111 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2903 | + if ($globalDebug) { |
|
| 2904 | + echo "Shutdown all sockets..."; |
|
| 2905 | + } |
|
| 2112 | 2906 | |
| 2113 | 2907 | foreach ($sockets as $sock) { |
| 2114 | 2908 | @socket_shutdown($sock,2); |
@@ -2116,25 +2910,45 @@ discard block |
||
| 2116 | 2910 | } |
| 2117 | 2911 | |
| 2118 | 2912 | } |
| 2119 | - if ($globalDebug) echo "Waiting..."; |
|
| 2913 | + if ($globalDebug) { |
|
| 2914 | + echo "Waiting..."; |
|
| 2915 | + } |
|
| 2120 | 2916 | sleep(2); |
| 2121 | 2917 | $time = time(); |
| 2122 | 2918 | //connect_all($hosts); |
| 2123 | 2919 | $aprs_connect = 0; |
| 2124 | - if ($reset%5 === 0) sleep(20); |
|
| 2125 | - if ($reset%10 === 0) sleep(100); |
|
| 2126 | - if ($reset%20 === 0) sleep(200); |
|
| 2127 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 2128 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2920 | + if ($reset%5 === 0) { |
|
| 2921 | + sleep(20); |
|
| 2922 | + } |
|
| 2923 | + if ($reset%10 === 0) { |
|
| 2924 | + sleep(100); |
|
| 2925 | + } |
|
| 2926 | + if ($reset%20 === 0) { |
|
| 2927 | + sleep(200); |
|
| 2928 | + } |
|
| 2929 | + if ($reset > 100) { |
|
| 2930 | + exit('Too many attempts...'); |
|
| 2931 | + } |
|
| 2932 | + if ($globalDebug) { |
|
| 2933 | + echo "Restart all connections..."; |
|
| 2934 | + } |
|
| 2129 | 2935 | connect_all($globalSources); |
| 2130 | 2936 | } |
| 2131 | 2937 | } |
| 2132 | 2938 | } |
| 2133 | 2939 | if ($globalDaemon === false) { |
| 2134 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2135 | - if (isset($SI)) $SI->checkAll(); |
|
| 2136 | - if (isset($TI)) $TI->checkAll(); |
|
| 2137 | - if (isset($MI)) $MI->checkAll(); |
|
| 2940 | + if ($globalDebug) { |
|
| 2941 | + echo 'Check all...'."\n"; |
|
| 2942 | + } |
|
| 2943 | + if (isset($SI)) { |
|
| 2944 | + $SI->checkAll(); |
|
| 2945 | + } |
|
| 2946 | + if (isset($TI)) { |
|
| 2947 | + $TI->checkAll(); |
|
| 2948 | + } |
|
| 2949 | + if (isset($MI)) { |
|
| 2950 | + $MI->checkAll(); |
|
| 2951 | + } |
|
| 2138 | 2952 | } |
| 2139 | 2953 | } |
| 2140 | 2954 | } |
@@ -4,12 +4,22 @@ discard block |
||
| 4 | 4 | if (isset($_SESSION['error'])) { |
| 5 | 5 | header('Content-Encoding: none;'); |
| 6 | 6 | echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.'; |
| 7 | - if (isset($_SESSION['error'])) unset($_SESSION['error']); |
|
| 8 | - if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']); |
|
| 9 | - if (isset($_SESSION['next'])) unset($_SESSION['next']); |
|
| 10 | - if (isset($_SESSION['install'])) unset($_SESSION['install']); |
|
| 11 | - if (isset($_SESSION['identitied'])) unset($_SESSION['identified']); |
|
| 12 | -} |
|
| 7 | + if (isset($_SESSION['error'])) { |
|
| 8 | + unset($_SESSION['error']); |
|
| 9 | + } |
|
| 10 | + if (isset($_SESSION['errorlst'])) { |
|
| 11 | + unset($_SESSION['errorlst']); |
|
| 12 | + } |
|
| 13 | + if (isset($_SESSION['next'])) { |
|
| 14 | + unset($_SESSION['next']); |
|
| 15 | + } |
|
| 16 | + if (isset($_SESSION['install'])) { |
|
| 17 | + unset($_SESSION['install']); |
|
| 18 | + } |
|
| 19 | + if (isset($_SESSION['identitied'])) { |
|
| 20 | + unset($_SESSION['identified']); |
|
| 21 | + } |
|
| 22 | + } |
|
| 13 | 23 | /* |
| 14 | 24 | if (isset($_SESSION['errorlst'])) { |
| 15 | 25 | header('Content-Encoding: none;'); |
@@ -131,7 +141,9 @@ discard block |
||
| 131 | 141 | if (count($alllng) != count($availablelng)) { |
| 132 | 142 | $notavailable = array(); |
| 133 | 143 | foreach($alllng as $lng) { |
| 134 | - if (!isset($availablelng[$lng])) $notavailable[] = $lng; |
|
| 144 | + if (!isset($availablelng[$lng])) { |
|
| 145 | + $notavailable[] = $lng; |
|
| 146 | + } |
|
| 135 | 147 | } |
| 136 | 148 | print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>'; |
| 137 | 149 | } |
@@ -170,7 +182,10 @@ discard block |
||
| 170 | 182 | <legend>Install script configuration</legend> |
| 171 | 183 | <p> |
| 172 | 184 | <label for="installpass">Install password</label> |
| 173 | - <input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" /> |
|
| 185 | + <input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) { |
|
| 186 | + print $globalInstallPassword; |
|
| 187 | +} |
|
| 188 | +?>" /> |
|
| 174 | 189 | </p> |
| 175 | 190 | <p class="help-block">Password needed to access this install script. If empty, to access this script, you will need to change the $globalInstalled setting in require/settings.php to FALSE</p> |
| 176 | 191 | </fieldset> |
@@ -200,31 +215,49 @@ discard block |
||
| 200 | 215 | </div> |
| 201 | 216 | <p> |
| 202 | 217 | <label for="dbhost">Database hostname</label> |
| 203 | - <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" /> |
|
| 218 | + <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) { |
|
| 219 | + print $globalDBhost; |
|
| 220 | +} |
|
| 221 | +?>" /> |
|
| 204 | 222 | </p> |
| 205 | 223 | <p> |
| 206 | 224 | <label for="dbport">Database port</label> |
| 207 | - <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" /> |
|
| 225 | + <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) { |
|
| 226 | + print $globalDBport; |
|
| 227 | +} |
|
| 228 | +?>" /> |
|
| 208 | 229 | <p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p> |
| 209 | 230 | </p> |
| 210 | 231 | <p> |
| 211 | 232 | <label for="dbname">Database name</label> |
| 212 | - <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" /> |
|
| 233 | + <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) { |
|
| 234 | + print $globalDBname; |
|
| 235 | +} |
|
| 236 | +?>" /> |
|
| 213 | 237 | </p> |
| 214 | 238 | <p> |
| 215 | 239 | <label for="dbuser">Database user</label> |
| 216 | - <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" /> |
|
| 240 | + <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) { |
|
| 241 | + print $globalDBuser; |
|
| 242 | +} |
|
| 243 | +?>" /> |
|
| 217 | 244 | </p> |
| 218 | 245 | <p> |
| 219 | 246 | <label for="dbuserpass">Database user password</label> |
| 220 | - <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" /> |
|
| 247 | + <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) { |
|
| 248 | + print $globalDBpass; |
|
| 249 | +} |
|
| 250 | +?>" /> |
|
| 221 | 251 | </p> |
| 222 | 252 | </fieldset> |
| 223 | 253 | <fieldset id="site"> |
| 224 | 254 | <legend>Site configuration</legend> |
| 225 | 255 | <p> |
| 226 | 256 | <label for="sitename">Site name</label> |
| 227 | - <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" /> |
|
| 257 | + <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) { |
|
| 258 | + print $globalName; |
|
| 259 | +} |
|
| 260 | +?>" /> |
|
| 228 | 261 | </p> |
| 229 | 262 | <p> |
| 230 | 263 | <label for="siteurl">Site directory</label> |
@@ -237,18 +270,27 @@ discard block |
||
| 237 | 270 | } |
| 238 | 271 | } |
| 239 | 272 | ?> |
| 240 | - <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" /> |
|
| 273 | + <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) { |
|
| 274 | + print $globalURL; |
|
| 275 | +} |
|
| 276 | +?>" /> |
|
| 241 | 277 | <p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p> |
| 242 | 278 | <p class="help-block">Can be empty</p> |
| 243 | 279 | </p> |
| 244 | 280 | <p> |
| 245 | 281 | <label for="timezone">Timezone</label> |
| 246 | - <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" /> |
|
| 282 | + <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) { |
|
| 283 | + print $globalTimezone; |
|
| 284 | +} |
|
| 285 | +?>" /> |
|
| 247 | 286 | <p class="help-block">ex : UTC, Europe/Paris,...</p> |
| 248 | 287 | </p> |
| 249 | 288 | <p> |
| 250 | 289 | <label for="language">Language</label> |
| 251 | - <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" /> |
|
| 290 | + <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) { |
|
| 291 | + print $globalLanguage; |
|
| 292 | +} |
|
| 293 | +?>" /> |
|
| 252 | 294 | <p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p> |
| 253 | 295 | </p> |
| 254 | 296 | </fieldset> |
@@ -268,11 +310,17 @@ discard block |
||
| 268 | 310 | <div id="mapbox_data"> |
| 269 | 311 | <p> |
| 270 | 312 | <label for="mapboxid">Mapbox id</label> |
| 271 | - <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" /> |
|
| 313 | + <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) { |
|
| 314 | + print $globalMapboxId; |
|
| 315 | +} |
|
| 316 | +?>" /> |
|
| 272 | 317 | </p> |
| 273 | 318 | <p> |
| 274 | 319 | <label for="mapboxtoken">Mapbox token</label> |
| 275 | - <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" /> |
|
| 320 | + <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) { |
|
| 321 | + print $globalMapboxToken; |
|
| 322 | +} |
|
| 323 | +?>" /> |
|
| 276 | 324 | </p> |
| 277 | 325 | <p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p> |
| 278 | 326 | </div> |
@@ -280,7 +328,10 @@ discard block |
||
| 280 | 328 | <div id="google_data"> |
| 281 | 329 | <p> |
| 282 | 330 | <label for="googlekey">Google API key</label> |
| 283 | - <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" /> |
|
| 331 | + <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) { |
|
| 332 | + print $globalGoogleAPIKey; |
|
| 333 | +} |
|
| 334 | +?>" /> |
|
| 284 | 335 | <p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p> |
| 285 | 336 | </p> |
| 286 | 337 | </div> |
@@ -288,7 +339,10 @@ discard block |
||
| 288 | 339 | <div id="bing_data"> |
| 289 | 340 | <p> |
| 290 | 341 | <label for="bingkey">Bing Map key</label> |
| 291 | - <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" /> |
|
| 342 | + <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) { |
|
| 343 | + print $globalBingMapKey; |
|
| 344 | +} |
|
| 345 | +?>" /> |
|
| 292 | 346 | <p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p> |
| 293 | 347 | </p> |
| 294 | 348 | </div> |
@@ -296,7 +350,10 @@ discard block |
||
| 296 | 350 | <div id="mapquest_data"> |
| 297 | 351 | <p> |
| 298 | 352 | <label for="mapquestkey">MapQuest key</label> |
| 299 | - <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" /> |
|
| 353 | + <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) { |
|
| 354 | + print $globalMapQuestKey; |
|
| 355 | +} |
|
| 356 | +?>" /> |
|
| 300 | 357 | <p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p> |
| 301 | 358 | </p> |
| 302 | 359 | </div> |
@@ -304,11 +361,17 @@ discard block |
||
| 304 | 361 | <div id="here_data"> |
| 305 | 362 | <p> |
| 306 | 363 | <label for="hereappid">Here App_Id</label> |
| 307 | - <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" /> |
|
| 364 | + <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) { |
|
| 365 | + print $globalHereappId; |
|
| 366 | +} |
|
| 367 | +?>" /> |
|
| 308 | 368 | </p> |
| 309 | 369 | <p> |
| 310 | 370 | <label for="hereappcode">Here App_Code</label> |
| 311 | - <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" /> |
|
| 371 | + <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) { |
|
| 372 | + print $globalHereappCode; |
|
| 373 | +} |
|
| 374 | +?>" /> |
|
| 312 | 375 | </p> |
| 313 | 376 | <p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p> |
| 314 | 377 | </div> |
@@ -316,7 +379,10 @@ discard block |
||
| 316 | 379 | <div id="openweathermap_data"> |
| 317 | 380 | <p> |
| 318 | 381 | <label for="openweathermapkey">OpenWeatherMap key (weather layer)</label> |
| 319 | - <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" /> |
|
| 382 | + <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) { |
|
| 383 | + print $globalOpenWeatherMapKey; |
|
| 384 | +} |
|
| 385 | +?>" /> |
|
| 320 | 386 | <p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p> |
| 321 | 387 | </p> |
| 322 | 388 | </div> |
@@ -345,42 +411,86 @@ discard block |
||
| 345 | 411 | <legend>Coverage area</legend> |
| 346 | 412 | <p> |
| 347 | 413 | <label for="latitudemax">The maximum latitude (north)</label> |
| 348 | - <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" /> |
|
| 414 | + <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) { |
|
| 415 | + print $globalLatitudeMax; |
|
| 416 | +} |
|
| 417 | +?>" /> |
|
| 349 | 418 | </p> |
| 350 | 419 | <p> |
| 351 | 420 | <label for="latitudemin">The minimum latitude (south)</label> |
| 352 | - <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" /> |
|
| 421 | + <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) { |
|
| 422 | + print $globalLatitudeMin; |
|
| 423 | +} |
|
| 424 | +?>" /> |
|
| 353 | 425 | </p> |
| 354 | 426 | <p> |
| 355 | 427 | <label for="longitudemax">The maximum longitude (west)</label> |
| 356 | - <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" /> |
|
| 428 | + <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) { |
|
| 429 | + print $globalLongitudeMax; |
|
| 430 | +} |
|
| 431 | +?>" /> |
|
| 357 | 432 | </p> |
| 358 | 433 | <p> |
| 359 | 434 | <label for="longitudemin">The minimum longitude (east)</label> |
| 360 | - <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" /> |
|
| 435 | + <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) { |
|
| 436 | + print $globalLongitudeMin; |
|
| 437 | +} |
|
| 438 | +?>" /> |
|
| 361 | 439 | </p> |
| 362 | 440 | <p> |
| 363 | 441 | <label for="latitudecenter">The latitude center</label> |
| 364 | - <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" /> |
|
| 442 | + <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) { |
|
| 443 | + print $globalCenterLatitude; |
|
| 444 | +} |
|
| 445 | +?>" /> |
|
| 365 | 446 | </p> |
| 366 | 447 | <p> |
| 367 | 448 | <label for="longitudecenter">The longitude center</label> |
| 368 | - <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" /> |
|
| 449 | + <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) { |
|
| 450 | + print $globalCenterLongitude; |
|
| 451 | +} |
|
| 452 | +?>" /> |
|
| 369 | 453 | </p> |
| 370 | 454 | <p> |
| 371 | 455 | <label for="livezoom">Default Zoom on live map</label> |
| 372 | - <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" /> |
|
| 456 | + <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) { |
|
| 457 | + print $globalLiveZoom; |
|
| 458 | +} else { |
|
| 459 | + print '9'; |
|
| 460 | +} |
|
| 461 | +?>" /> |
|
| 373 | 462 | </p> |
| 374 | 463 | <p> |
| 375 | 464 | <label for="squawk_country">Country for squawk usage</label> |
| 376 | 465 | <select name="squawk_country" id="squawk_country"> |
| 377 | - <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option> |
|
| 378 | - <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option> |
|
| 379 | - <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option> |
|
| 380 | - <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option> |
|
| 381 | - <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option> |
|
| 382 | - <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option> |
|
| 383 | - <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option> |
|
| 466 | + <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') { |
|
| 467 | + print ' selected '; |
|
| 468 | +} |
|
| 469 | +?>>UK</option> |
|
| 470 | + <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') { |
|
| 471 | + print ' selected '; |
|
| 472 | +} |
|
| 473 | +?>>NZ</option> |
|
| 474 | + <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') { |
|
| 475 | + print ' selected '; |
|
| 476 | +} |
|
| 477 | +?>>US</option> |
|
| 478 | + <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') { |
|
| 479 | + print ' selected '; |
|
| 480 | +} |
|
| 481 | +?>>AU</option> |
|
| 482 | + <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') { |
|
| 483 | + print ' selected '; |
|
| 484 | +} |
|
| 485 | +?>>NL</option> |
|
| 486 | + <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') { |
|
| 487 | + print ' selected '; |
|
| 488 | +} |
|
| 489 | +?>>FR</option> |
|
| 490 | + <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') { |
|
| 491 | + print ' selected '; |
|
| 492 | +} |
|
| 493 | +?>>TR</option> |
|
| 384 | 494 | </select> |
| 385 | 495 | </p> |
| 386 | 496 | </fieldset> |
@@ -389,15 +499,24 @@ discard block |
||
| 389 | 499 | <p><i>Only put in DB flights that are inside a circle</i></p> |
| 390 | 500 | <p> |
| 391 | 501 | <label for="latitude">Center latitude</label> |
| 392 | - <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" /> |
|
| 502 | + <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) { |
|
| 503 | + echo $globalDistanceIgnore['latitude']; |
|
| 504 | +} |
|
| 505 | +?>" /> |
|
| 393 | 506 | </p> |
| 394 | 507 | <p> |
| 395 | 508 | <label for="longitude">Center longitude</label> |
| 396 | - <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" /> |
|
| 509 | + <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) { |
|
| 510 | + echo $globalDistanceIgnore['longitude']; |
|
| 511 | +} |
|
| 512 | +?>" /> |
|
| 397 | 513 | </p> |
| 398 | 514 | <p> |
| 399 | 515 | <label for="Distance">Distance (in km)</label> |
| 400 | - <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" /> |
|
| 516 | + <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) { |
|
| 517 | + echo $globalDistanceIgnore['distance']; |
|
| 518 | +} |
|
| 519 | +?>" /> |
|
| 401 | 520 | </p> |
| 402 | 521 | </fieldset> |
| 403 | 522 | <fieldset id="sourceloc"> |
@@ -523,22 +642,34 @@ discard block |
||
| 523 | 642 | <div id="flightaware_data"> |
| 524 | 643 | <p> |
| 525 | 644 | <label for="flightawareusername">FlightAware username</label> |
| 526 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
| 645 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
| 646 | + print $globalFlightAwareUsername; |
|
| 647 | +} |
|
| 648 | +?>" /> |
|
| 527 | 649 | </p> |
| 528 | 650 | <p> |
| 529 | 651 | <label for="flightawarepassword">FlightAware password/API key</label> |
| 530 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
| 652 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
| 653 | + print $globalFlightAwarePassword; |
|
| 654 | +} |
|
| 655 | +?>" /> |
|
| 531 | 656 | </p> |
| 532 | 657 | </div> |
| 533 | 658 | --> |
| 534 | 659 | <div id="sailaway_data"> |
| 535 | 660 | <p> |
| 536 | 661 | <label for="sailawayemail">Sailaway email</label> |
| 537 | - <input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" /> |
|
| 662 | + <input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) { |
|
| 663 | + print $globalSailaway['email']; |
|
| 664 | +} |
|
| 665 | +?>" /> |
|
| 538 | 666 | </p> |
| 539 | 667 | <p> |
| 540 | 668 | <label for="sailawaypassword">Sailaway password</label> |
| 541 | - <input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" /> |
|
| 669 | + <input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) { |
|
| 670 | + print $globalSailaway['password']; |
|
| 671 | +} |
|
| 672 | +?>" /> |
|
| 542 | 673 | </p> |
| 543 | 674 | </div> |
| 544 | 675 | |
@@ -580,7 +711,10 @@ discard block |
||
| 580 | 711 | if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
| 581 | 712 | ?> |
| 582 | 713 | <td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td> |
| 583 | - <td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
|
| 714 | + <td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) { |
|
| 715 | + print $source['port']; |
|
| 716 | +} |
|
| 717 | +?>" /></td> |
|
| 584 | 718 | <?php |
| 585 | 719 | } else { |
| 586 | 720 | $hostport = explode(':',$source['host']); |
@@ -599,39 +733,126 @@ discard block |
||
| 599 | 733 | ?> |
| 600 | 734 | <td> |
| 601 | 735 | <select name="format[]"> |
| 602 | - <option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option> |
|
| 603 | - <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option> |
|
| 604 | - <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option> |
|
| 605 | - <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option> |
|
| 606 | - <option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option> |
|
| 607 | - <option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option> |
|
| 608 | - <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option> |
|
| 609 | - <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option> |
|
| 610 | - <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') print 'selected'; ?>>Radarcape json</option> |
|
| 611 | - <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option> |
|
| 612 | - <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option> |
|
| 613 | - <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option> |
|
| 614 | - <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option> |
|
| 615 | - <option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option> |
|
| 616 | - <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option> |
|
| 617 | - <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option> |
|
| 618 | - <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option> |
|
| 619 | - <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option> |
|
| 620 | - <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
| 621 | - <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option> |
|
| 622 | - <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json</option> |
|
| 623 | - <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option> |
|
| 624 | - <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option> |
|
| 625 | - <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option> |
|
| 626 | - <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option> |
|
| 627 | - <option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option> |
|
| 736 | + <option value="auto" <?php if (!isset($source['format'])) { |
|
| 737 | + print 'selected'; |
|
| 738 | +} |
|
| 739 | +?>>Auto</option> |
|
| 740 | + <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') { |
|
| 741 | + print 'selected'; |
|
| 742 | +} |
|
| 743 | +?>>SBS</option> |
|
| 744 | + <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') { |
|
| 745 | + print 'selected'; |
|
| 746 | +} |
|
| 747 | +?>>TSV</option> |
|
| 748 | + <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') { |
|
| 749 | + print 'selected'; |
|
| 750 | +} |
|
| 751 | +?>>Raw</option> |
|
| 752 | + <option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') { |
|
| 753 | + print 'selected'; |
|
| 754 | +} |
|
| 755 | +?>>Dump1090 aircraft.json</option> |
|
| 756 | + <option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') { |
|
| 757 | + print 'selected'; |
|
| 758 | +} |
|
| 759 | +?>>Planefinder client</option> |
|
| 760 | + <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 761 | + print 'selected'; |
|
| 762 | +} |
|
| 763 | +?>>APRS</option> |
|
| 764 | + <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') { |
|
| 765 | + print 'selected'; |
|
| 766 | +} |
|
| 767 | +?>>Radarcape deltadb.txt</option> |
|
| 768 | + <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') { |
|
| 769 | + print 'selected'; |
|
| 770 | +} |
|
| 771 | +?>>Radarcape json</option> |
|
| 772 | + <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') { |
|
| 773 | + print 'selected'; |
|
| 774 | +} |
|
| 775 | +?>>Vatsim</option> |
|
| 776 | + <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') { |
|
| 777 | + print 'selected'; |
|
| 778 | +} |
|
| 779 | +?>>Virtual Radar Server AircraftList.json</option> |
|
| 780 | + <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') { |
|
| 781 | + print 'selected'; |
|
| 782 | +} |
|
| 783 | +?>>Virtual Radar Server TCP</option> |
|
| 784 | + <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
| 785 | + print 'selected'; |
|
| 786 | +} |
|
| 787 | +?>>phpVMS</option> |
|
| 788 | + <option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
| 789 | + print 'selected'; |
|
| 790 | +} |
|
| 791 | +?>>Virtual Airline Operations System (VAOS)</option> |
|
| 792 | + <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') { |
|
| 793 | + print 'selected'; |
|
| 794 | +} |
|
| 795 | +?>>Virtual Airlines Manager</option> |
|
| 796 | + <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') { |
|
| 797 | + print 'selected'; |
|
| 798 | +} |
|
| 799 | +?>>IVAO</option> |
|
| 800 | + <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') { |
|
| 801 | + print 'selected'; |
|
| 802 | +} |
|
| 803 | +?>>FlightGear Multiplayer</option> |
|
| 804 | + <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') { |
|
| 805 | + print 'selected'; |
|
| 806 | +} |
|
| 807 | +?>>FlightGear Singleplayer</option> |
|
| 808 | + <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') { |
|
| 809 | + print 'selected'; |
|
| 810 | +} |
|
| 811 | +?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
| 812 | + <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') { |
|
| 813 | + print 'selected'; |
|
| 814 | +} |
|
| 815 | +?>>ACARS SBS-3 over TCP</option> |
|
| 816 | + <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') { |
|
| 817 | + print 'selected'; |
|
| 818 | +} |
|
| 819 | +?>>ACARS from acarsdec json</option> |
|
| 820 | + <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') { |
|
| 821 | + print 'selected'; |
|
| 822 | +} |
|
| 823 | +?>>NMEA AIS over TCP</option> |
|
| 824 | + <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') { |
|
| 825 | + print 'selected'; |
|
| 826 | +} |
|
| 827 | +?>>AirWhere website</option> |
|
| 828 | + <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') { |
|
| 829 | + print 'selected'; |
|
| 830 | +} |
|
| 831 | +?>>HidnSeek Callback</option> |
|
| 832 | + <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') { |
|
| 833 | + print 'selected'; |
|
| 834 | +} |
|
| 835 | +?>>Blitzortung</option> |
|
| 836 | + <option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') { |
|
| 837 | + print 'selected'; |
|
| 838 | +} |
|
| 839 | +?>>Sailaway</option> |
|
| 628 | 840 | </select> |
| 629 | 841 | </td> |
| 630 | 842 | <td> |
| 631 | - <input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" /> |
|
| 843 | + <input type="text" name="name[]" value="<?php if (isset($source['name'])) { |
|
| 844 | + print $source['name']; |
|
| 845 | +} |
|
| 846 | +?>" /> |
|
| 632 | 847 | </td> |
| 633 | - <td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td> |
|
| 634 | - <td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td> |
|
| 848 | + <td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) { |
|
| 849 | + print 'checked'; |
|
| 850 | +} |
|
| 851 | +?> /></td> |
|
| 852 | + <td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) { |
|
| 853 | + print 'checked'; |
|
| 854 | +} |
|
| 855 | +?> /></td> |
|
| 635 | 856 | <td> |
| 636 | 857 | <select name="timezones[]"> |
| 637 | 858 | <?php |
@@ -641,7 +862,9 @@ discard block |
||
| 641 | 862 | print '<option selected>'.$timezones.'</option>'; |
| 642 | 863 | } elseif (!isset($source['timezone']) && $timezones == 'UTC') { |
| 643 | 864 | print '<option selected>'.$timezones.'</option>'; |
| 644 | - } else print '<option>'.$timezones.'</option>'; |
|
| 865 | + } else { |
|
| 866 | + print '<option>'.$timezones.'</option>'; |
|
| 867 | + } |
|
| 645 | 868 | } |
| 646 | 869 | ?> |
| 647 | 870 | </select> |
@@ -697,7 +920,9 @@ discard block |
||
| 697 | 920 | foreach($timezonelist as $timezones){ |
| 698 | 921 | if ($timezones == 'UTC') { |
| 699 | 922 | print '<option selected>'.$timezones.'</option>'; |
| 700 | - } else print '<option>'.$timezones.'</option>'; |
|
| 923 | + } else { |
|
| 924 | + print '<option>'.$timezones.'</option>'; |
|
| 925 | + } |
|
| 701 | 926 | } |
| 702 | 927 | ?> |
| 703 | 928 | </select> |
@@ -722,11 +947,17 @@ discard block |
||
| 722 | 947 | <p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p> |
| 723 | 948 | <p> |
| 724 | 949 | <label for="acarshost">ACARS UDP host</label> |
| 725 | - <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" /> |
|
| 950 | + <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) { |
|
| 951 | + print $globalACARSHost; |
|
| 952 | +} |
|
| 953 | +?>" /> |
|
| 726 | 954 | </p> |
| 727 | 955 | <p> |
| 728 | 956 | <label for="acarsport">ACARS UDP port</label> |
| 729 | - <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" /> |
|
| 957 | + <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) { |
|
| 958 | + print $globalACARSPort; |
|
| 959 | +} |
|
| 960 | +?>" /> |
|
| 730 | 961 | </p> |
| 731 | 962 | <p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p> |
| 732 | 963 | </fieldset> |
@@ -753,17 +984,38 @@ discard block |
||
| 753 | 984 | <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td> |
| 754 | 985 | <td> |
| 755 | 986 | <select name="newslang[]"> |
| 756 | - <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option> |
|
| 757 | - <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option> |
|
| 987 | + <option value="en"<?php if ($lng == 'en') { |
|
| 988 | + print ' selected'; |
|
| 989 | +} |
|
| 990 | +?>>English</option> |
|
| 991 | + <option value="fr"<?php if ($lng == 'fr') { |
|
| 992 | + print ' selected'; |
|
| 993 | +} |
|
| 994 | +?>>French</option> |
|
| 758 | 995 | </select> |
| 759 | 996 | </td> |
| 760 | 997 | <td> |
| 761 | 998 | <select name="newstype[]"> |
| 762 | - <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option> |
|
| 763 | - <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option> |
|
| 764 | - <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option> |
|
| 765 | - <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option> |
|
| 766 | - <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option> |
|
| 999 | + <option value="global"<?php if ($type == 'global') { |
|
| 1000 | + print ' selected'; |
|
| 1001 | +} |
|
| 1002 | +?>>Global</option> |
|
| 1003 | + <option value="aircraft"<?php if ($type == 'aircraft') { |
|
| 1004 | + print ' selected'; |
|
| 1005 | +} |
|
| 1006 | +?>>Aircraft</option> |
|
| 1007 | + <option value="marine"<?php if ($type == 'marine') { |
|
| 1008 | + print ' selected'; |
|
| 1009 | +} |
|
| 1010 | +?>>Marine</option> |
|
| 1011 | + <option value="tracker"<?php if ($type == 'tracker') { |
|
| 1012 | + print ' selected'; |
|
| 1013 | +} |
|
| 1014 | +?>>Tracker</option> |
|
| 1015 | + <option value="satellite"<?php if ($type == 'Satellite') { |
|
| 1016 | + print ' selected'; |
|
| 1017 | +} |
|
| 1018 | +?>>Satellite</option> |
|
| 767 | 1019 | </select> |
| 768 | 1020 | </td> |
| 769 | 1021 | <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td> |
@@ -847,7 +1099,10 @@ discard block |
||
| 847 | 1099 | </p> |
| 848 | 1100 | <p> |
| 849 | 1101 | <label for="corsproxy">CORS proxy</label> |
| 850 | - <input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" /> |
|
| 1102 | + <input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) { |
|
| 1103 | + print $globalCORSproxy; |
|
| 1104 | +} else { |
|
| 1105 | + print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" /> |
|
| 851 | 1106 | <p class="help-block">CORS proxy used for some WMS servers</p> |
| 852 | 1107 | </p> |
| 853 | 1108 | <!-- |
@@ -910,13 +1165,18 @@ discard block |
||
| 910 | 1165 | <div id="schedules_options"> |
| 911 | 1166 | <p> |
| 912 | 1167 | <label for="britishairways">British Airways API Key</label> |
| 913 | - <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" /> |
|
| 1168 | + <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; |
|
| 1169 | +} |
|
| 1170 | +?>" /> |
|
| 914 | 1171 | <p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p> |
| 915 | 1172 | </p> |
| 916 | 1173 | <!-- |
| 917 | 1174 | <p> |
| 918 | 1175 | <label for="transavia">Transavia Test API Consumer Key</label> |
| 919 | - <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" /> |
|
| 1176 | + <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) { |
|
| 1177 | + print $globalTransaviaKey; |
|
| 1178 | +} |
|
| 1179 | +?>" /> |
|
| 920 | 1180 | <p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p> |
| 921 | 1181 | </p> |
| 922 | 1182 | --> |
@@ -925,10 +1185,16 @@ discard block |
||
| 925 | 1185 | <b>Lufthansa API Key</b> |
| 926 | 1186 | <p> |
| 927 | 1187 | <label for="lufthansakey">Key</label> |
| 928 | - <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" /> |
|
| 1188 | + <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) { |
|
| 1189 | + print $globalLufthansaKey['key']; |
|
| 1190 | +} |
|
| 1191 | +?>" /> |
|
| 929 | 1192 | </p><p> |
| 930 | 1193 | <label for="lufthansasecret">Secret</label> |
| 931 | - <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" /> |
|
| 1194 | + <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) { |
|
| 1195 | + print $globalLufthansaKey['secret']; |
|
| 1196 | +} |
|
| 1197 | +?>" /> |
|
| 932 | 1198 | </p> |
| 933 | 1199 | </div> |
| 934 | 1200 | <p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p> |
@@ -938,11 +1204,17 @@ discard block |
||
| 938 | 1204 | <b>FlightAware API Key</b> |
| 939 | 1205 | <p> |
| 940 | 1206 | <label for="flightawareusername">Username</label> |
| 941 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
| 1207 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
| 1208 | + print $globalFlightAwareUsername; |
|
| 1209 | +} |
|
| 1210 | +?>" /> |
|
| 942 | 1211 | </p> |
| 943 | 1212 | <p> |
| 944 | 1213 | <label for="flightawarepassword">API key</label> |
| 945 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
| 1214 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
| 1215 | + print $globalFlightAwarePassword; |
|
| 1216 | +} |
|
| 1217 | +?>" /> |
|
| 946 | 1218 | </p> |
| 947 | 1219 | </div> |
| 948 | 1220 | <p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p> |
@@ -959,10 +1231,22 @@ discard block |
||
| 959 | 1231 | <p> |
| 960 | 1232 | <label for="mapmatchingsource">Map Matching source</label> |
| 961 | 1233 | <select name="mapmatchingsource" id="mapmatchingsource"> |
| 962 | - <option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option> |
|
| 963 | - <option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option> |
|
| 964 | - <option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option> |
|
| 965 | - <option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option> |
|
| 1234 | + <option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) { |
|
| 1235 | + print 'selected="selected" '; |
|
| 1236 | +} |
|
| 1237 | +?>>FlightAirMap Map Matching</option> |
|
| 1238 | + <option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') { |
|
| 1239 | + print 'selected="selected" '; |
|
| 1240 | +} |
|
| 1241 | +?>>GraphHopper</option> |
|
| 1242 | + <option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') { |
|
| 1243 | + print 'selected="selected" '; |
|
| 1244 | +} |
|
| 1245 | +?>>OSMR</option> |
|
| 1246 | + <option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') { |
|
| 1247 | + print 'selected="selected" '; |
|
| 1248 | +} |
|
| 1249 | +?>>Mapbox</option> |
|
| 966 | 1250 | </select> |
| 967 | 1251 | <p class="help-block">Mapbox need the API Key defined in map section.</p> |
| 968 | 1252 | <p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p> |
@@ -970,7 +1254,10 @@ discard block |
||
| 970 | 1254 | <br /> |
| 971 | 1255 | <p> |
| 972 | 1256 | <label for="graphhopper">GraphHopper API Key</label> |
| 973 | - <input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" /> |
|
| 1257 | + <input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) { |
|
| 1258 | + print $globalGraphHopperKey; |
|
| 1259 | +} |
|
| 1260 | +?>" /> |
|
| 974 | 1261 | <p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p> |
| 975 | 1262 | </p> |
| 976 | 1263 | </div> |
@@ -988,7 +1275,10 @@ discard block |
||
| 988 | 1275 | </p> |
| 989 | 1276 | <p> |
| 990 | 1277 | <label for="notamsource">URL of your feed from notaminfo.com</label> |
| 991 | - <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" /> |
|
| 1278 | + <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) { |
|
| 1279 | + print $globalNOTAMSource; |
|
| 1280 | +} |
|
| 1281 | +?>" /> |
|
| 992 | 1282 | <p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p> |
| 993 | 1283 | </p> |
| 994 | 1284 | <br /> |
@@ -1004,14 +1294,20 @@ discard block |
||
| 1004 | 1294 | <div id="metarsrc"> |
| 1005 | 1295 | <p> |
| 1006 | 1296 | <label for="metarsource">URL of your METAR source</label> |
| 1007 | - <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" /> |
|
| 1297 | + <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) { |
|
| 1298 | + print $globalMETARurl; |
|
| 1299 | +} |
|
| 1300 | +?>" /> |
|
| 1008 | 1301 | <p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p> |
| 1009 | 1302 | </p> |
| 1010 | 1303 | </div> |
| 1011 | 1304 | <br /> |
| 1012 | 1305 | <p> |
| 1013 | 1306 | <label for="bitly">Bit.ly access token api (used in search page)</label> |
| 1014 | - <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" /> |
|
| 1307 | + <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) { |
|
| 1308 | + print $globalBitlyAccessToken; |
|
| 1309 | +} |
|
| 1310 | +?>" /> |
|
| 1015 | 1311 | </p> |
| 1016 | 1312 | <br /> |
| 1017 | 1313 | <p> |
@@ -1027,11 +1323,26 @@ discard block |
||
| 1027 | 1323 | <p> |
| 1028 | 1324 | <label for="geoid_source">Geoid Source</label> |
| 1029 | 1325 | <select name="geoid_source" id="geoid_source"> |
| 1030 | - <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option> |
|
| 1031 | - <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option> |
|
| 1032 | - <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option> |
|
| 1033 | - <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option> |
|
| 1034 | - <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option> |
|
| 1326 | + <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') { |
|
| 1327 | + print ' selected="selected"'; |
|
| 1328 | +} |
|
| 1329 | +?>>EGM96 15' (2.1MB)</option> |
|
| 1330 | + <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') { |
|
| 1331 | + print ' selected="selected"'; |
|
| 1332 | +} |
|
| 1333 | +?>>EGM96 5' (19MB)</option> |
|
| 1334 | + <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') { |
|
| 1335 | + print ' selected="selected"'; |
|
| 1336 | +} |
|
| 1337 | +?>>EGM2008 5' (19MB)</option> |
|
| 1338 | + <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') { |
|
| 1339 | + print ' selected="selected"'; |
|
| 1340 | +} |
|
| 1341 | +?>>EGM2008 2.5' (75MB)</option> |
|
| 1342 | + <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') { |
|
| 1343 | + print ' selected="selected"'; |
|
| 1344 | +} |
|
| 1345 | +?>>EGM2008 1' (470MB)</option> |
|
| 1035 | 1346 | </select> |
| 1036 | 1347 | <p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p> |
| 1037 | 1348 | </p> |
@@ -1053,7 +1364,12 @@ discard block |
||
| 1053 | 1364 | </p> |
| 1054 | 1365 | <p> |
| 1055 | 1366 | <label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label> |
| 1056 | - <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" /> |
|
| 1367 | + <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) { |
|
| 1368 | + print $globalArchiveMonths; |
|
| 1369 | +} else { |
|
| 1370 | + echo '1'; |
|
| 1371 | +} |
|
| 1372 | +?>" /> |
|
| 1057 | 1373 | <p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p> |
| 1058 | 1374 | </p> |
| 1059 | 1375 | <p> |
@@ -1063,12 +1379,22 @@ discard block |
||
| 1063 | 1379 | </p> |
| 1064 | 1380 | <p> |
| 1065 | 1381 | <label for="archivekeepmonths">Keep flights data for xx months in archive</label> |
| 1066 | - <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" /> |
|
| 1382 | + <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) { |
|
| 1383 | + print $globalArchiveKeepMonths; |
|
| 1384 | +} else { |
|
| 1385 | + echo '1'; |
|
| 1386 | +} |
|
| 1387 | +?>" /> |
|
| 1067 | 1388 | <p class="help-block">0 to disable</p> |
| 1068 | 1389 | </p> |
| 1069 | 1390 | <p> |
| 1070 | 1391 | <label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label> |
| 1071 | - <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" /> |
|
| 1392 | + <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) { |
|
| 1393 | + print $globalArchiveKeepTrackMonths; |
|
| 1394 | +} else { |
|
| 1395 | + echo '1'; |
|
| 1396 | +} |
|
| 1397 | +?>" /> |
|
| 1072 | 1398 | <p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p> |
| 1073 | 1399 | </p> |
| 1074 | 1400 | <br /> |
@@ -1078,7 +1404,12 @@ discard block |
||
| 1078 | 1404 | <p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p> |
| 1079 | 1405 | <div id="cronends"> |
| 1080 | 1406 | <label for="cronend">Run script for xx seconds</label> |
| 1081 | - <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" /> |
|
| 1407 | + <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) { |
|
| 1408 | + print $globalCronEnd; |
|
| 1409 | +} else { |
|
| 1410 | + print '0'; |
|
| 1411 | +} |
|
| 1412 | +?>" /> |
|
| 1082 | 1413 | <p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p> |
| 1083 | 1414 | </div> |
| 1084 | 1415 | </p> |
@@ -1137,20 +1468,40 @@ discard block |
||
| 1137 | 1468 | <br /> |
| 1138 | 1469 | <p> |
| 1139 | 1470 | <label for="refresh">Show flights detected since xxx seconds</label> |
| 1140 | - <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" /> |
|
| 1471 | + <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) { |
|
| 1472 | + echo $globalLiveInterval; |
|
| 1473 | +} else { |
|
| 1474 | + echo '200'; |
|
| 1475 | +} |
|
| 1476 | +?>" /> |
|
| 1141 | 1477 | </p> |
| 1142 | 1478 | <p> |
| 1143 | 1479 | <label for="maprefresh">Live map refresh (in seconds)</label> |
| 1144 | - <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" /> |
|
| 1480 | + <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) { |
|
| 1481 | + echo $globalMapRefresh; |
|
| 1482 | +} else { |
|
| 1483 | + echo '30'; |
|
| 1484 | +} |
|
| 1485 | +?>" /> |
|
| 1145 | 1486 | </p> |
| 1146 | 1487 | <p> |
| 1147 | 1488 | <label for="mapidle">Map idle timeout (in minutes)</label> |
| 1148 | - <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" /> |
|
| 1489 | + <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) { |
|
| 1490 | + echo $globalMapIdleTimeout; |
|
| 1491 | +} else { |
|
| 1492 | + echo '30'; |
|
| 1493 | +} |
|
| 1494 | +?>" /> |
|
| 1149 | 1495 | <p class="help-block">0 to disable</p> |
| 1150 | 1496 | </p> |
| 1151 | 1497 | <p> |
| 1152 | 1498 | <label for="minfetch">HTTP/file source fetch every xxx seconds</label> |
| 1153 | - <input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" /> |
|
| 1499 | + <input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) { |
|
| 1500 | + echo $globalMinFetch; |
|
| 1501 | +} else { |
|
| 1502 | + echo '20'; |
|
| 1503 | +} |
|
| 1504 | +?>" /> |
|
| 1154 | 1505 | </p> |
| 1155 | 1506 | <p> |
| 1156 | 1507 | <label for="bbox">Only display flights that we can see on screen (bounding box)</label> |
@@ -1169,12 +1520,20 @@ discard block |
||
| 1169 | 1520 | <br /> |
| 1170 | 1521 | <p> |
| 1171 | 1522 | <label for="closestmindist">Distance to airport set as arrival (in km)</label> |
| 1172 | - <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" /> |
|
| 1523 | + <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) { |
|
| 1524 | + echo $globalClosestMinDist; |
|
| 1525 | +} else { |
|
| 1526 | + echo '50'; |
|
| 1527 | +} |
|
| 1528 | +?>" /> |
|
| 1173 | 1529 | </p> |
| 1174 | 1530 | <br /> |
| 1175 | 1531 | <p> |
| 1176 | 1532 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
| 1177 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
| 1533 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) { |
|
| 1534 | + echo $globalAircraftSize; |
|
| 1535 | +} |
|
| 1536 | +?>" /> |
|
| 1178 | 1537 | </p> |
| 1179 | 1538 | <br /> |
| 1180 | 1539 | <p> |
@@ -1193,22 +1552,42 @@ discard block |
||
| 1193 | 1552 | <br /> |
| 1194 | 1553 | <p> |
| 1195 | 1554 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
| 1196 | - <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
|
| 1555 | + <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) { |
|
| 1556 | + echo $globalAircraftIconColor; |
|
| 1557 | +} else { |
|
| 1558 | + echo '1a3151'; |
|
| 1559 | +} |
|
| 1560 | +?>" /> |
|
| 1197 | 1561 | </p> |
| 1198 | 1562 | <br /> |
| 1199 | 1563 | <p> |
| 1200 | 1564 | <label for="marineiconcolor">Color of marine icon on map</label> |
| 1201 | - <input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" /> |
|
| 1565 | + <input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) { |
|
| 1566 | + echo $globalMarineIconColor; |
|
| 1567 | +} else { |
|
| 1568 | + echo '43d1d8'; |
|
| 1569 | +} |
|
| 1570 | +?>" /> |
|
| 1202 | 1571 | </p> |
| 1203 | 1572 | <br /> |
| 1204 | 1573 | <p> |
| 1205 | 1574 | <label for="trackericoncolor">Color of tracker icon on map</label> |
| 1206 | - <input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" /> |
|
| 1575 | + <input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) { |
|
| 1576 | + echo $globalTrackerIconColor; |
|
| 1577 | +} else { |
|
| 1578 | + echo '1a3151'; |
|
| 1579 | +} |
|
| 1580 | +?>" /> |
|
| 1207 | 1581 | </p> |
| 1208 | 1582 | <br /> |
| 1209 | 1583 | <p> |
| 1210 | 1584 | <label for="satelliteiconcolor">Color of satellite icon on map</label> |
| 1211 | - <input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" /> |
|
| 1585 | + <input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) { |
|
| 1586 | + echo $globalSatelliteIconColor; |
|
| 1587 | +} else { |
|
| 1588 | + echo '1a3151'; |
|
| 1589 | +} |
|
| 1590 | +?>" /> |
|
| 1212 | 1591 | </p> |
| 1213 | 1592 | <?php |
| 1214 | 1593 | if (!is_writable('../cache')) { |
@@ -1232,14 +1611,27 @@ discard block |
||
| 1232 | 1611 | <p> |
| 1233 | 1612 | <label for="airportzoom">Zoom level minimum to see airports icons</label> |
| 1234 | 1613 | <div class="range"> |
| 1235 | - <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" /> |
|
| 1236 | - <output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output> |
|
| 1614 | + <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) { |
|
| 1615 | + echo $globalAirportZoom; |
|
| 1616 | +} else { |
|
| 1617 | + echo '7'; |
|
| 1618 | +} |
|
| 1619 | +?>" /> |
|
| 1620 | + <output id="range"><?php if (isset($globalAirportZoom)) { |
|
| 1621 | + echo $globalAirportZoom; |
|
| 1622 | +} else { |
|
| 1623 | + echo '7'; |
|
| 1624 | +} |
|
| 1625 | +?></output> |
|
| 1237 | 1626 | </div> |
| 1238 | 1627 | </p> |
| 1239 | 1628 | <br /> |
| 1240 | 1629 | <p> |
| 1241 | 1630 | <label for="customcss">Custom CSS web path</label> |
| 1242 | - <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" /> |
|
| 1631 | + <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) { |
|
| 1632 | + echo $globalCustomCSS; |
|
| 1633 | +} |
|
| 1634 | +?>" /> |
|
| 1243 | 1635 | </p> |
| 1244 | 1636 | </fieldset> |
| 1245 | 1637 | <input type="submit" name="submit" value="Create/Update database & write setup" /> |
@@ -1269,8 +1661,12 @@ discard block |
||
| 1269 | 1661 | $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
| 1270 | 1662 | $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
| 1271 | 1663 | |
| 1272 | - if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
|
| 1273 | - if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
| 1664 | + if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) { |
|
| 1665 | + $error .= 'Mysql driver for PDO must be loaded'; |
|
| 1666 | + } |
|
| 1667 | + if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) { |
|
| 1668 | + $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
| 1669 | + } |
|
| 1274 | 1670 | |
| 1275 | 1671 | $_SESSION['database_root'] = $dbroot; |
| 1276 | 1672 | $_SESSION['database_rootpass'] = $dbrootpass; |
@@ -1348,15 +1744,23 @@ discard block |
||
| 1348 | 1744 | $source_city = $_POST['source_city']; |
| 1349 | 1745 | $source_country = $_POST['source_country']; |
| 1350 | 1746 | $source_ref = $_POST['source_ref']; |
| 1351 | - if (isset($source_id)) $source_id = $_POST['source_id']; |
|
| 1352 | - else $source_id = array(); |
|
| 1747 | + if (isset($source_id)) { |
|
| 1748 | + $source_id = $_POST['source_id']; |
|
| 1749 | + } else { |
|
| 1750 | + $source_id = array(); |
|
| 1751 | + } |
|
| 1353 | 1752 | |
| 1354 | 1753 | $sources = array(); |
| 1355 | 1754 | foreach ($source_name as $keys => $name) { |
| 1356 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 1357 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 1755 | + if (isset($source_id[$keys])) { |
|
| 1756 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 1757 | + } else { |
|
| 1758 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 1759 | + } |
|
| 1760 | + } |
|
| 1761 | + if (count($sources) > 0) { |
|
| 1762 | + $_SESSION['sources'] = $sources; |
|
| 1358 | 1763 | } |
| 1359 | - if (count($sources) > 0) $_SESSION['sources'] = $sources; |
|
| 1360 | 1764 | |
| 1361 | 1765 | $newsurl = $_POST['newsurl']; |
| 1362 | 1766 | $newslng = $_POST['newslang']; |
@@ -1369,7 +1773,9 @@ discard block |
||
| 1369 | 1773 | $lng = $newslng[$newskey]; |
| 1370 | 1774 | if (isset($newsfeeds[$type][$lng])) { |
| 1371 | 1775 | $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url)); |
| 1372 | - } else $newsfeeds[$type][$lng] = array($url); |
|
| 1776 | + } else { |
|
| 1777 | + $newsfeeds[$type][$lng] = array($url); |
|
| 1778 | + } |
|
| 1373 | 1779 | } |
| 1374 | 1780 | } |
| 1375 | 1781 | $settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds)); |
@@ -1394,17 +1800,29 @@ discard block |
||
| 1394 | 1800 | $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
| 1395 | 1801 | |
| 1396 | 1802 | $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
| 1397 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
| 1398 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
| 1803 | + if ($globalaircraft == 'aircraft') { |
|
| 1804 | + $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
| 1805 | + } else { |
|
| 1806 | + $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
| 1807 | + } |
|
| 1399 | 1808 | $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
| 1400 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
| 1401 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
| 1809 | + if ($globaltracker == 'tracker') { |
|
| 1810 | + $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
| 1811 | + } else { |
|
| 1812 | + $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
| 1813 | + } |
|
| 1402 | 1814 | $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
| 1403 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
| 1404 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
| 1815 | + if ($globalmarine == 'marine') { |
|
| 1816 | + $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
| 1817 | + } else { |
|
| 1818 | + $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
| 1819 | + } |
|
| 1405 | 1820 | $globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING); |
| 1406 | - if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE')); |
|
| 1407 | - else $settings = array_merge($settings,array('globalSatellite' => 'FALSE')); |
|
| 1821 | + if ($globalsatellite == 'satellite') { |
|
| 1822 | + $settings = array_merge($settings,array('globalSatellite' => 'TRUE')); |
|
| 1823 | + } else { |
|
| 1824 | + $settings = array_merge($settings,array('globalSatellite' => 'FALSE')); |
|
| 1825 | + } |
|
| 1408 | 1826 | |
| 1409 | 1827 | /* |
| 1410 | 1828 | $globalSBS1Hosts = array(); |
@@ -1426,23 +1844,37 @@ discard block |
||
| 1426 | 1844 | $name = $_POST['name']; |
| 1427 | 1845 | $format = $_POST['format']; |
| 1428 | 1846 | $timezones = $_POST['timezones']; |
| 1429 | - if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats']; |
|
| 1430 | - else $sourcestats = array(); |
|
| 1431 | - if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive']; |
|
| 1432 | - else $noarchive = array(); |
|
| 1847 | + if (isset($_POST['sourcestats'])) { |
|
| 1848 | + $sourcestats = $_POST['sourcestats']; |
|
| 1849 | + } else { |
|
| 1850 | + $sourcestats = array(); |
|
| 1851 | + } |
|
| 1852 | + if (isset($_POST['noarchive'])) { |
|
| 1853 | + $noarchive = $_POST['noarchive']; |
|
| 1854 | + } else { |
|
| 1855 | + $noarchive = array(); |
|
| 1856 | + } |
|
| 1433 | 1857 | $gSources = array(); |
| 1434 | 1858 | $forcepilots = false; |
| 1435 | 1859 | foreach ($host as $key => $h) { |
| 1436 | - if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
|
| 1437 | - else $cov = 'FALSE'; |
|
| 1438 | - if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
|
| 1439 | - else $arch = 'FALSE'; |
|
| 1860 | + if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) { |
|
| 1861 | + $cov = 'TRUE'; |
|
| 1862 | + } else { |
|
| 1863 | + $cov = 'FALSE'; |
|
| 1864 | + } |
|
| 1865 | + if (isset($noarchive[$key]) && $noarchive[$key] == 1) { |
|
| 1866 | + $arch = 'TRUE'; |
|
| 1867 | + } else { |
|
| 1868 | + $arch = 'FALSE'; |
|
| 1869 | + } |
|
| 1440 | 1870 | if (strpos($format[$key],'_callback')) { |
| 1441 | 1871 | $gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE'); |
| 1442 | 1872 | } elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) { |
| 1443 | 1873 | $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE'); |
| 1444 | 1874 | } |
| 1445 | - if ($format[$key] == 'airwhere') $forcepilots = true; |
|
| 1875 | + if ($format[$key] == 'airwhere') { |
|
| 1876 | + $forcepilots = true; |
|
| 1877 | + } |
|
| 1446 | 1878 | } |
| 1447 | 1879 | $settings = array_merge($settings,array('globalSources' => $gSources)); |
| 1448 | 1880 | |
@@ -1473,7 +1905,9 @@ discard block |
||
| 1473 | 1905 | $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
| 1474 | 1906 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
| 1475 | 1907 | $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
| 1476 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 1908 | + } else { |
|
| 1909 | + $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 1910 | + } |
|
| 1477 | 1911 | |
| 1478 | 1912 | $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
| 1479 | 1913 | $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
@@ -1514,7 +1948,9 @@ discard block |
||
| 1514 | 1948 | |
| 1515 | 1949 | // Create in settings.php keys not yet configurable if not already here |
| 1516 | 1950 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
| 1517 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 1951 | + if (!isset($globalDebug)) { |
|
| 1952 | + $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 1953 | + } |
|
| 1518 | 1954 | |
| 1519 | 1955 | $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
| 1520 | 1956 | if ($resetyearstats == 'resetyearstats') { |
@@ -1557,37 +1993,56 @@ discard block |
||
| 1557 | 1993 | } |
| 1558 | 1994 | */ |
| 1559 | 1995 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
| 1560 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 1561 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 1562 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 1563 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 1996 | + if ($globalsbs == 'sbs') { |
|
| 1997 | + $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 1998 | + } else { |
|
| 1999 | + $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 2000 | + } |
|
| 2001 | + if ($globalaprs == 'aprs') { |
|
| 2002 | + $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 2003 | + } else { |
|
| 2004 | + $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 2005 | + } |
|
| 1564 | 2006 | $va = false; |
| 1565 | 2007 | if ($globalivao == 'ivao') { |
| 1566 | 2008 | $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
| 1567 | 2009 | $va = true; |
| 1568 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 2010 | + } else { |
|
| 2011 | + $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 2012 | + } |
|
| 1569 | 2013 | if ($globalvatsim == 'vatsim') { |
| 1570 | 2014 | $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
| 1571 | 2015 | $va = true; |
| 1572 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 2016 | + } else { |
|
| 2017 | + $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 2018 | + } |
|
| 1573 | 2019 | if ($globalphpvms == 'phpvms') { |
| 1574 | 2020 | $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
| 1575 | 2021 | $va = true; |
| 1576 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 2022 | + } else { |
|
| 2023 | + $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 2024 | + } |
|
| 1577 | 2025 | if ($globalvam == 'vam') { |
| 1578 | 2026 | $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
| 1579 | 2027 | $va = true; |
| 1580 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 2028 | + } else { |
|
| 2029 | + $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 2030 | + } |
|
| 1581 | 2031 | if ($va) { |
| 1582 | 2032 | $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
| 1583 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 2033 | + } else { |
|
| 2034 | + $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 2035 | + } |
|
| 1584 | 2036 | if ($globalva == 'va' || $va) { |
| 1585 | 2037 | $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
| 1586 | 2038 | $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
| 1587 | 2039 | } else { |
| 1588 | 2040 | $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
| 1589 | - if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
| 1590 | - else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
| 2041 | + if ($forcepilots) { |
|
| 2042 | + $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
| 2043 | + } else { |
|
| 2044 | + $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
| 2045 | + } |
|
| 1591 | 2046 | } |
| 1592 | 2047 | if ($globalvm == 'vm') { |
| 1593 | 2048 | $settings = array_merge($settings,array('globalVM' => 'TRUE')); |
@@ -1847,7 +2302,9 @@ discard block |
||
| 1847 | 2302 | $graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING); |
| 1848 | 2303 | $settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper)); |
| 1849 | 2304 | |
| 1850 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 2305 | + if (!isset($globalTransaction)) { |
|
| 2306 | + $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 2307 | + } |
|
| 1851 | 2308 | |
| 1852 | 2309 | // Set some defaults values... |
| 1853 | 2310 | if (!isset($globalAircraftImageSources)) { |
@@ -1862,15 +2319,23 @@ discard block |
||
| 1862 | 2319 | |
| 1863 | 2320 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
| 1864 | 2321 | |
| 1865 | - if ($error == '') settings::modify_settings($settings); |
|
| 1866 | - if ($error == '') settings::comment_settings($settings_comment); |
|
| 2322 | + if ($error == '') { |
|
| 2323 | + settings::modify_settings($settings); |
|
| 2324 | + } |
|
| 2325 | + if ($error == '') { |
|
| 2326 | + settings::comment_settings($settings_comment); |
|
| 2327 | + } |
|
| 1867 | 2328 | if ($error != '') { |
| 1868 | 2329 | print '<div class="info column">'.$error.'</div>'; |
| 1869 | 2330 | require('../footer.php'); |
| 1870 | 2331 | exit; |
| 1871 | 2332 | } else { |
| 1872 | - if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1; |
|
| 1873 | - if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1; |
|
| 2333 | + if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') { |
|
| 2334 | + $_SESSION['waypoints'] = 1; |
|
| 2335 | + } |
|
| 2336 | + if (isset($_POST['owner']) && $_POST['owner'] == 'owner') { |
|
| 2337 | + $_SESSION['owner'] = 1; |
|
| 2338 | + } |
|
| 1874 | 2339 | if (isset($_POST['createdb'])) { |
| 1875 | 2340 | $_SESSION['install'] = 'database_create'; |
| 1876 | 2341 | } else { |
@@ -1907,10 +2372,18 @@ discard block |
||
| 1907 | 2372 | $popw = false; |
| 1908 | 2373 | foreach ($_SESSION['done'] as $done) { |
| 1909 | 2374 | print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
| 1910 | - if ($done == 'Create database') $pop = true; |
|
| 1911 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
| 1912 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
| 1913 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
| 2375 | + if ($done == 'Create database') { |
|
| 2376 | + $pop = true; |
|
| 2377 | + } |
|
| 2378 | + if ($_SESSION['install'] == 'database_create') { |
|
| 2379 | + $pop = true; |
|
| 2380 | + } |
|
| 2381 | + if ($_SESSION['install'] == 'database_import') { |
|
| 2382 | + $popi = true; |
|
| 2383 | + } |
|
| 2384 | + if ($_SESSION['install'] == 'waypoints') { |
|
| 2385 | + $popw = true; |
|
| 2386 | + } |
|
| 1914 | 2387 | } |
| 1915 | 2388 | if ($pop) { |
| 1916 | 2389 | sleep(5); |
@@ -1921,7 +2394,9 @@ discard block |
||
| 1921 | 2394 | } else if ($popw) { |
| 1922 | 2395 | sleep(5); |
| 1923 | 2396 | print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
| 1924 | - } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
| 2397 | + } else { |
|
| 2398 | + print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
| 2399 | + } |
|
| 1925 | 2400 | print '</div></ul>'; |
| 1926 | 2401 | print '<div id="error"></div>'; |
| 1927 | 2402 | /* foreach ($_SESSION['done'] as $done) { |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $limit_start = 0; |
| 15 | 15 | $limit_end = 25; |
| 16 | 16 | $absolute_difference = 25; |
| 17 | - } else { |
|
| 17 | + } else { |
|
| 18 | 18 | $limit_explode = explode(",", $_GET['limit']); |
| 19 | 19 | $limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT); |
| 20 | 20 | $limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT); |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | $title = sprintf(_("Detailed View for %s (%s)"),$airline_info[0]['name'],$airline_info[0]['icao']); |
| 56 | 56 | } elseif (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) { |
| 57 | 57 | $title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
| 58 | - } else $title = ''; |
|
| 58 | + } else { |
|
| 59 | + $title = ''; |
|
| 60 | + } |
|
| 59 | 61 | } |
| 60 | 62 | require_once('header.php'); |
| 61 | 63 | |
@@ -76,7 +78,9 @@ discard block |
||
| 76 | 78 | } |
| 77 | 79 | $Stats = new Stats(); |
| 78 | 80 | $airline_names = $Stats->getAllAirlineNames(); |
| 79 | - if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
|
| 81 | + if (empty($airline_names)) { |
|
| 82 | + $airline_names = $Spotter->getAllAirlineNames(); |
|
| 83 | + } |
|
| 80 | 84 | foreach($airline_names as $airline_name) |
| 81 | 85 | { |
| 82 | 86 | if($airline == $airline_name['airline_icao']) |
@@ -108,12 +112,22 @@ discard block |
||
| 108 | 112 | print '<div><span class="label">'._("Name").'</span>'.$airline_info[0]['name'].'</div>'; |
| 109 | 113 | print '<div><span class="label">'._("Country").'</span>'.$airline_info[0]['country'].'</div>'; |
| 110 | 114 | print '<div><span class="label">'._("ICAO").'</span>'.$airline_info[0]['icao'].'</div>'; |
| 111 | - if ($airline_info[0]['iata'] != '') print '<div><span class="label">'._("IATA").'</span>'.$airline_info[0]['iata'].'</div>'; |
|
| 112 | - if ($airline_info[0]['callsign'] != '') print '<div><span class="label">'._("Callsign").'</span>'.$airline_info[0]['callsign'].'</div>'; |
|
| 115 | + if ($airline_info[0]['iata'] != '') { |
|
| 116 | + print '<div><span class="label">'._("IATA").'</span>'.$airline_info[0]['iata'].'</div>'; |
|
| 117 | + } |
|
| 118 | + if ($airline_info[0]['callsign'] != '') { |
|
| 119 | + print '<div><span class="label">'._("Callsign").'</span>'.$airline_info[0]['callsign'].'</div>'; |
|
| 120 | + } |
|
| 113 | 121 | print '<div><span class="label">'._("Type").'</span>'.ucwords($airline_info[0]['type']).'</div>'; |
| 114 | - if (isset($airline_info[0]['home_link']) && $airline_info[0]['home_link'] != '') print '<div><a href="'.$airline_info[0]['home_link'].'"><i class="fa fa-home"></i></a></div>'; |
|
| 115 | - if (isset($airline_info[0]['wikipedia_link']) && $airline_info[0]['wikipedia_link'] != '') print '<div><a href="'.$airline_info[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>'; |
|
| 116 | - if (isset($airline_info[0]['ban_eu']) && $airline_info[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>'; |
|
| 122 | + if (isset($airline_info[0]['home_link']) && $airline_info[0]['home_link'] != '') { |
|
| 123 | + print '<div><a href="'.$airline_info[0]['home_link'].'"><i class="fa fa-home"></i></a></div>'; |
|
| 124 | + } |
|
| 125 | + if (isset($airline_info[0]['wikipedia_link']) && $airline_info[0]['wikipedia_link'] != '') { |
|
| 126 | + print '<div><a href="'.$airline_info[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>'; |
|
| 127 | + } |
|
| 128 | + if (isset($airline_info[0]['ban_eu']) && $airline_info[0]['ban_eu'] == 1) { |
|
| 129 | + print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>'; |
|
| 130 | + } |
|
| 117 | 131 | print '</div>'; |
| 118 | 132 | |
| 119 | 133 | } else { |
@@ -129,10 +143,16 @@ discard block |
||
| 129 | 143 | print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>'; |
| 130 | 144 | print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>'; |
| 131 | 145 | print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>'; |
| 132 | - if (isset($spotter_array[0]['airline_iata']) && $spotter_array[0]['airline_iata'] != '') print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
|
| 133 | - if (isset($spotter_array[0]['airline_callsign']) && $spotter_array[0]['airline_callsign'] != '') print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
|
| 146 | + if (isset($spotter_array[0]['airline_iata']) && $spotter_array[0]['airline_iata'] != '') { |
|
| 147 | + print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
|
| 148 | + } |
|
| 149 | + if (isset($spotter_array[0]['airline_callsign']) && $spotter_array[0]['airline_callsign'] != '') { |
|
| 150 | + print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
|
| 151 | + } |
|
| 134 | 152 | print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>'; |
| 135 | - if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>'; |
|
| 153 | + if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) { |
|
| 154 | + print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>'; |
|
| 155 | + } |
|
| 136 | 156 | print '</div>'; |
| 137 | 157 | } |
| 138 | 158 | } else { |