@@ -75,7 +75,9 @@ discard block |
||
| 75 | 75 | if ($error != '') { |
| 76 | 76 | $_SESSION['error'] = $error; |
| 77 | 77 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database')); |
| 78 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
| 78 | + } else { |
|
| 79 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
| 80 | + } |
|
| 79 | 81 | $_SESSION['install'] = 'database_import'; |
| 80 | 82 | $_SESSION['next'] = 'Create and import tables'; |
| 81 | 83 | $result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -93,7 +95,9 @@ discard block |
||
| 93 | 95 | if ($error != '') { |
| 94 | 96 | $_SESSION['error'] = $error; |
| 95 | 97 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
| 96 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
| 98 | + } else { |
|
| 99 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
| 100 | + } |
|
| 97 | 101 | if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
| 98 | 102 | $_SESSION['install'] = 'populate'; |
| 99 | 103 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
@@ -107,7 +111,9 @@ discard block |
||
| 107 | 111 | $error .= $check_version; |
| 108 | 112 | $_SESSION['error'] = $error; |
| 109 | 113 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
| 110 | - if (!isset($_SESSION['next'])) $_SESSION['next'] = ''; |
|
| 114 | + if (!isset($_SESSION['next'])) { |
|
| 115 | + $_SESSION['next'] = ''; |
|
| 116 | + } |
|
| 111 | 117 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
| 112 | 118 | print json_encode($result); |
| 113 | 119 | } else { |
@@ -115,7 +121,9 @@ discard block |
||
| 115 | 121 | if ($error != '') { |
| 116 | 122 | $_SESSION['error'] = $error; |
| 117 | 123 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed')); |
| 118 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
| 124 | + } else { |
|
| 125 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
| 126 | + } |
|
| 119 | 127 | $_SESSION['install'] = 'sources'; |
| 120 | 128 | $_SESSION['next'] = 'Insert data in source table'; |
| 121 | 129 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -128,8 +136,10 @@ discard block |
||
| 128 | 136 | if ($error != '') { |
| 129 | 137 | $_SESSION['error'] = $error; |
| 130 | 138 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database')); |
| 131 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
| 132 | -/* |
|
| 139 | + } else { |
|
| 140 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
| 141 | + } |
|
| 142 | + /* |
|
| 133 | 143 | $_SESSION['install'] = 'airspace'; |
| 134 | 144 | $_SESSION['next'] = 'Populate airspace table'; |
| 135 | 145 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -154,7 +164,9 @@ discard block |
||
| 154 | 164 | if ($error != '') { |
| 155 | 165 | $_SESSION['error'] = $error; |
| 156 | 166 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
| 157 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
| 167 | + } else { |
|
| 168 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
| 169 | + } |
|
| 158 | 170 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
| 159 | 171 | $_SESSION['install'] = 'notam'; |
| 160 | 172 | $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
@@ -188,7 +200,9 @@ discard block |
||
| 188 | 200 | if ($error != '') { |
| 189 | 201 | $_SESSION['error'] = $error; |
| 190 | 202 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
| 191 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 203 | + } else { |
|
| 204 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
| 205 | + } |
|
| 192 | 206 | $_SESSION['install'] = 'populate_flarm'; |
| 193 | 207 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM'; |
| 194 | 208 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -209,18 +223,26 @@ discard block |
||
| 209 | 223 | if ($error != '') { |
| 210 | 224 | $_SESSION['error'] = $error; |
| 211 | 225 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
| 212 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 226 | + } else { |
|
| 227 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
| 228 | + } |
|
| 213 | 229 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
| 214 | 230 | $_SESSION['install'] = 'vatsim'; |
| 215 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 216 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 231 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 232 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 233 | + } else { |
|
| 234 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 235 | + } |
|
| 217 | 236 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 218 | 237 | $_SESSION['install'] = 'vatsim'; |
| 219 | 238 | $_SESSION['next'] = 'Insert VATSIM data'; |
| 220 | 239 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 221 | 240 | $_SESSION['install'] = 'vatsim'; |
| 222 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 223 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 241 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 242 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 243 | + } else { |
|
| 244 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 245 | + } |
|
| 224 | 246 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 225 | 247 | $_SESSION['install'] = 'vatsim'; |
| 226 | 248 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -245,7 +267,9 @@ discard block |
||
| 245 | 267 | if ($error != '') { |
| 246 | 268 | $_SESSION['error'] = $error; |
| 247 | 269 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data')); |
| 248 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
| 270 | + } else { |
|
| 271 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
| 272 | + } |
|
| 249 | 273 | $_SESSION['install'] = 'translation'; |
| 250 | 274 | $_SESSION['next'] = 'Populate translation table with externals data'; |
| 251 | 275 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -265,7 +289,9 @@ discard block |
||
| 265 | 289 | if ($error != '') { |
| 266 | 290 | $_SESSION['error'] = $error; |
| 267 | 291 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
| 268 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
| 292 | + } else { |
|
| 293 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
| 294 | + } |
|
| 269 | 295 | if ($_SESSION['waypoints'] == 1) { |
| 270 | 296 | $_SESSION['install'] = 'waypoints'; |
| 271 | 297 | $_SESSION['next'] = 'Populate waypoints table'; |
@@ -300,7 +326,9 @@ discard block |
||
| 300 | 326 | if ($error != '') { |
| 301 | 327 | $_SESSION['error'] = $error; |
| 302 | 328 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
| 303 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
| 329 | + } else { |
|
| 330 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
| 331 | + } |
|
| 304 | 332 | $_SESSION['install'] = 'sources'; |
| 305 | 333 | $_SESSION['next'] = 'Insert data in source table'; |
| 306 | 334 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -321,12 +349,16 @@ discard block |
||
| 321 | 349 | if ($error != '') { |
| 322 | 350 | $_SESSION['error'] = $error; |
| 323 | 351 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
| 324 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
| 352 | + } else { |
|
| 353 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
| 354 | + } |
|
| 325 | 355 | } else { |
| 326 | 356 | if ($error != '') { |
| 327 | 357 | $_SESSION['error'] = $error; |
| 328 | 358 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)')); |
| 329 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
| 359 | + } else { |
|
| 360 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
| 361 | + } |
|
| 330 | 362 | } |
| 331 | 363 | /* |
| 332 | 364 | if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -376,7 +408,9 @@ discard block |
||
| 376 | 408 | $Source = new Source(); |
| 377 | 409 | $Source->deleteAllLocation(); |
| 378 | 410 | foreach ($sources as $src) { |
| 379 | - if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
| 411 | + if (isset($src['latitude']) && $src['latitude'] != '') { |
|
| 412 | + $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
| 413 | + } |
|
| 380 | 414 | } |
| 381 | 415 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table')); |
| 382 | 416 | unset($_SESSION['sources']); |
@@ -387,15 +421,21 @@ discard block |
||
| 387 | 421 | */ |
| 388 | 422 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
| 389 | 423 | $_SESSION['install'] = 'vatsim'; |
| 390 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 391 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 424 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 425 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 426 | + } else { |
|
| 427 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
| 428 | + } |
|
| 392 | 429 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 393 | 430 | $_SESSION['install'] = 'vatsim'; |
| 394 | 431 | $_SESSION['next'] = 'Insert VATSIM data'; |
| 395 | 432 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 396 | 433 | $_SESSION['install'] = 'vatsim'; |
| 397 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
| 398 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 434 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
| 435 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
| 436 | + } else { |
|
| 437 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
| 438 | + } |
|
| 399 | 439 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 400 | 440 | $_SESSION['install'] = 'vatsim'; |
| 401 | 441 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -416,33 +456,43 @@ discard block |
||
| 416 | 456 | if ($error != '') { |
| 417 | 457 | $_SESSION['error'] = $error; |
| 418 | 458 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
| 419 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 459 | + } else { |
|
| 460 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 461 | + } |
|
| 420 | 462 | } else { |
| 421 | 463 | $error .= update_db::update_vatsim(); |
| 422 | 464 | if ($error != '') { |
| 423 | 465 | $_SESSION['error'] = $error; |
| 424 | 466 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
| 425 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 467 | + } else { |
|
| 468 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 469 | + } |
|
| 426 | 470 | } |
| 427 | 471 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
| 428 | 472 | $error .= update_db::update_vatsim(); |
| 429 | 473 | if ($error != '') { |
| 430 | 474 | $_SESSION['error'] = $error; |
| 431 | 475 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
| 432 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 476 | + } else { |
|
| 477 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
| 478 | + } |
|
| 433 | 479 | } elseif (isset($globalIVAO) && $globalIVAO) { |
| 434 | 480 | if (file_exists('tmp/ivae_feb2013.zip')) { |
| 435 | 481 | $error .= update_db::update_IVAO(); |
| 436 | 482 | if ($error != '') { |
| 437 | 483 | $_SESSION['error'] = $error; |
| 438 | 484 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
| 439 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 485 | + } else { |
|
| 486 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
| 487 | + } |
|
| 440 | 488 | } else { |
| 441 | 489 | $error .= update_db::update_vatsim(); |
| 442 | 490 | if ($error != '') { |
| 443 | 491 | $_SESSION['error'] = $error; |
| 444 | 492 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)')); |
| 445 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
| 493 | + } else { |
|
| 494 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
| 495 | + } |
|
| 446 | 496 | } |
| 447 | 497 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
| 448 | 498 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data')); |
@@ -258,7 +258,9 @@ discard block |
||
| 258 | 258 | // Update table countries |
| 259 | 259 | if ($Connection->tableExists('airspace')) { |
| 260 | 260 | $error .= update_db::update_countries(); |
| 261 | - if ($error != '') return $error; |
|
| 261 | + if ($error != '') { |
|
| 262 | + return $error; |
|
| 263 | + } |
|
| 262 | 264 | } |
| 263 | 265 | // Update schema_version to 7 |
| 264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
| 314 | 316 | $error = ''; |
| 315 | 317 | // Update table aircraft |
| 316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
| 317 | - if ($error != '') return $error; |
|
| 319 | + if ($error != '') { |
|
| 320 | + return $error; |
|
| 321 | + } |
|
| 318 | 322 | // Update schema_version to 6 |
| 319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
| 320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
| 331 | 335 | $error = ''; |
| 332 | 336 | // Update table aircraft |
| 333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
| 334 | - if ($error != '') return $error; |
|
| 338 | + if ($error != '') { |
|
| 339 | + return $error; |
|
| 340 | + } |
|
| 335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
| 336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
| 337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
| 365 | 371 | $error = ''; |
| 366 | 372 | // Update table atc |
| 367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
| 368 | - if ($error != '') return $error; |
|
| 374 | + if ($error != '') { |
|
| 375 | + return $error; |
|
| 376 | + } |
|
| 369 | 377 | |
| 370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
| 371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
| 389 | 397 | $error = ''; |
| 390 | 398 | // Add tables |
| 391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
| 392 | - if ($error != '') return $error; |
|
| 400 | + if ($error != '') { |
|
| 401 | + return $error; |
|
| 402 | + } |
|
| 393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
| 394 | - if ($error != '') return $error; |
|
| 404 | + if ($error != '') { |
|
| 405 | + return $error; |
|
| 406 | + } |
|
| 395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
| 396 | - if ($error != '') return $error; |
|
| 408 | + if ($error != '') { |
|
| 409 | + return $error; |
|
| 410 | + } |
|
| 397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
| 398 | - if ($error != '') return $error; |
|
| 412 | + if ($error != '') { |
|
| 413 | + return $error; |
|
| 414 | + } |
|
| 399 | 415 | |
| 400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
| 401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
| 469 | 485 | $error = ''; |
| 470 | 486 | // Add tables |
| 471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
| 472 | - if ($error != '') return $error; |
|
| 488 | + if ($error != '') { |
|
| 489 | + return $error; |
|
| 490 | + } |
|
| 473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
| 474 | - if ($error != '') return $error; |
|
| 492 | + if ($error != '') { |
|
| 493 | + return $error; |
|
| 494 | + } |
|
| 475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
| 476 | - if ($error != '') return $error; |
|
| 496 | + if ($error != '') { |
|
| 497 | + return $error; |
|
| 498 | + } |
|
| 477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
| 478 | - if ($error != '') return $error; |
|
| 500 | + if ($error != '') { |
|
| 501 | + return $error; |
|
| 502 | + } |
|
| 479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
| 480 | - if ($error != '') return $error; |
|
| 504 | + if ($error != '') { |
|
| 505 | + return $error; |
|
| 506 | + } |
|
| 481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
| 482 | - if ($error != '') return $error; |
|
| 508 | + if ($error != '') { |
|
| 509 | + return $error; |
|
| 510 | + } |
|
| 483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
| 484 | - if ($error != '') return $error; |
|
| 512 | + if ($error != '') { |
|
| 513 | + return $error; |
|
| 514 | + } |
|
| 485 | 515 | |
| 486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
| 487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
| 521 | 551 | // Add tables |
| 522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
| 523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
| 524 | - if ($error != '') return $error; |
|
| 554 | + if ($error != '') { |
|
| 555 | + return $error; |
|
| 556 | + } |
|
| 525 | 557 | } |
| 526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
| 527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
| 545 | 577 | } catch(PDOException $e) { |
| 546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 547 | 579 | } |
| 548 | - if ($error != '') return $error; |
|
| 580 | + if ($error != '') { |
|
| 581 | + return $error; |
|
| 582 | + } |
|
| 549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
| 550 | 584 | try { |
| 551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
| 566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
| 567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
| 568 | 602 | } |
| 569 | - if ($error != '') return $error; |
|
| 603 | + if ($error != '') { |
|
| 604 | + return $error; |
|
| 605 | + } |
|
| 570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
| 571 | 607 | try { |
| 572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
| 584 | 620 | if (!$Connection->tableExists('stats_country')) { |
| 585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
| 586 | 622 | } |
| 587 | - if ($error != '') return $error; |
|
| 623 | + if ($error != '') { |
|
| 624 | + return $error; |
|
| 625 | + } |
|
| 588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
| 589 | 627 | try { |
| 590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
| 607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 608 | 646 | } |
| 609 | 647 | } |
| 610 | - if ($error != '') return $error; |
|
| 648 | + if ($error != '') { |
|
| 649 | + return $error; |
|
| 650 | + } |
|
| 611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
| 612 | 652 | try { |
| 613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
| 623 | 663 | $error = ''; |
| 624 | 664 | // Update airport table |
| 625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
| 626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
| 666 | + if ($error != '') { |
|
| 667 | + return 'Import airport.sql : '.$error; |
|
| 668 | + } |
|
| 627 | 669 | // Remove primary key on Spotter_Archive |
| 628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
| 629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
| 699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 700 | 742 | } |
| 701 | 743 | } |
| 702 | - if ($error != '') return $error; |
|
| 744 | + if ($error != '') { |
|
| 745 | + return $error; |
|
| 746 | + } |
|
| 703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
| 704 | 748 | try { |
| 705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
| 717 | 761 | // Update airline table |
| 718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
| 719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
| 720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
| 764 | + if ($error != '') { |
|
| 765 | + return 'Import airlines.sql : '.$error; |
|
| 766 | + } |
|
| 721 | 767 | } |
| 722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
| 723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
| 729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 730 | 776 | } |
| 731 | 777 | } |
| 732 | - if ($error != '') return $error; |
|
| 778 | + if ($error != '') { |
|
| 779 | + return $error; |
|
| 780 | + } |
|
| 733 | 781 | /* |
| 734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
| 735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
| 759 | 807 | } catch(PDOException $e) { |
| 760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
| 761 | 809 | } |
| 762 | - if ($error != '') return $error; |
|
| 810 | + if ($error != '') { |
|
| 811 | + return $error; |
|
| 812 | + } |
|
| 763 | 813 | } |
| 764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
| 765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
| 782 | 832 | } else { |
| 783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
| 784 | 834 | } |
| 785 | - if ($error != '') return $error; |
|
| 835 | + if ($error != '') { |
|
| 836 | + return $error; |
|
| 837 | + } |
|
| 786 | 838 | } |
| 787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
| 788 | 840 | try { |
@@ -803,12 +855,16 @@ discard block |
||
| 803 | 855 | if ($globalDBdriver == 'mysql') { |
| 804 | 856 | if (!$Connection->tableExists('tle')) { |
| 805 | 857 | $error .= create_db::import_file('../db/tle.sql'); |
| 806 | - if ($error != '') return $error; |
|
| 858 | + if ($error != '') { |
|
| 859 | + return $error; |
|
| 860 | + } |
|
| 807 | 861 | } |
| 808 | 862 | } else { |
| 809 | 863 | if (!$Connection->tableExists('tle')) { |
| 810 | 864 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
| 811 | - if ($error != '') return $error; |
|
| 865 | + if ($error != '') { |
|
| 866 | + return $error; |
|
| 867 | + } |
|
| 812 | 868 | } |
| 813 | 869 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
| 814 | 870 | try { |
@@ -848,7 +904,9 @@ discard block |
||
| 848 | 904 | } else { |
| 849 | 905 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
| 850 | 906 | } |
| 851 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
| 907 | + if ($error != '') { |
|
| 908 | + return 'Import airlines.sql : '.$error; |
|
| 909 | + } |
|
| 852 | 910 | if (!$Connection->checkColumnName('airlines','forsource')) { |
| 853 | 911 | // Add forsource to airlines |
| 854 | 912 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1331,20 +1389,28 @@ discard block |
||
| 1331 | 1389 | } |
| 1332 | 1390 | if ($globalDBdriver == 'mysql') { |
| 1333 | 1391 | $error .= create_db::import_file('../db/airlines.sql'); |
| 1334 | - if ($error != '') return $error; |
|
| 1392 | + if ($error != '') { |
|
| 1393 | + return $error; |
|
| 1394 | + } |
|
| 1335 | 1395 | } else { |
| 1336 | 1396 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
| 1337 | - if ($error != '') return $error; |
|
| 1397 | + if ($error != '') { |
|
| 1398 | + return $error; |
|
| 1399 | + } |
|
| 1338 | 1400 | } |
| 1339 | 1401 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
| 1340 | 1402 | include_once(dirname(__FILE__).'/class.update_db.php'); |
| 1341 | 1403 | if (isset($globalVATSIM) && $globalVATSIM) { |
| 1342 | 1404 | $error .= update_db::update_vatsim(); |
| 1343 | - if ($error != '') return $error; |
|
| 1405 | + if ($error != '') { |
|
| 1406 | + return $error; |
|
| 1407 | + } |
|
| 1344 | 1408 | } |
| 1345 | 1409 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
| 1346 | 1410 | $error .= update_db::update_IVAO(); |
| 1347 | - if ($error != '') return $error; |
|
| 1411 | + if ($error != '') { |
|
| 1412 | + return $error; |
|
| 1413 | + } |
|
| 1348 | 1414 | } |
| 1349 | 1415 | } |
| 1350 | 1416 | |
@@ -1607,41 +1673,65 @@ discard block |
||
| 1607 | 1673 | if ($globalDBdriver == 'mysql') { |
| 1608 | 1674 | if (!$Connection->tableExists('tracker_output')) { |
| 1609 | 1675 | $error .= create_db::import_file('../db/tracker_output.sql'); |
| 1610 | - if ($error != '') return $error; |
|
| 1676 | + if ($error != '') { |
|
| 1677 | + return $error; |
|
| 1678 | + } |
|
| 1611 | 1679 | } |
| 1612 | 1680 | if (!$Connection->tableExists('tracker_live')) { |
| 1613 | 1681 | $error .= create_db::import_file('../db/tracker_live.sql'); |
| 1614 | - if ($error != '') return $error; |
|
| 1682 | + if ($error != '') { |
|
| 1683 | + return $error; |
|
| 1684 | + } |
|
| 1615 | 1685 | } |
| 1616 | 1686 | if (!$Connection->tableExists('marine_output')) { |
| 1617 | 1687 | $error .= create_db::import_file('../db/marine_output.sql'); |
| 1618 | - if ($error != '') return $error; |
|
| 1688 | + if ($error != '') { |
|
| 1689 | + return $error; |
|
| 1690 | + } |
|
| 1619 | 1691 | } |
| 1620 | 1692 | if (!$Connection->tableExists('marine_live')) { |
| 1621 | 1693 | $error .= create_db::import_file('../db/marine_live.sql'); |
| 1622 | - if ($error != '') return $error; |
|
| 1694 | + if ($error != '') { |
|
| 1695 | + return $error; |
|
| 1696 | + } |
|
| 1623 | 1697 | } |
| 1624 | 1698 | if (!$Connection->tableExists('marine_identity')) { |
| 1625 | 1699 | $error .= create_db::import_file('../db/marine_identity.sql'); |
| 1626 | - if ($error != '') return $error; |
|
| 1700 | + if ($error != '') { |
|
| 1701 | + return $error; |
|
| 1702 | + } |
|
| 1627 | 1703 | } |
| 1628 | 1704 | if (!$Connection->tableExists('marine_mid')) { |
| 1629 | 1705 | $error .= create_db::import_file('../db/marine_mid.sql'); |
| 1630 | - if ($error != '') return $error; |
|
| 1706 | + if ($error != '') { |
|
| 1707 | + return $error; |
|
| 1708 | + } |
|
| 1631 | 1709 | } |
| 1632 | 1710 | } else { |
| 1633 | 1711 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
| 1634 | - if ($error != '') return $error; |
|
| 1712 | + if ($error != '') { |
|
| 1713 | + return $error; |
|
| 1714 | + } |
|
| 1635 | 1715 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
| 1636 | - if ($error != '') return $error; |
|
| 1716 | + if ($error != '') { |
|
| 1717 | + return $error; |
|
| 1718 | + } |
|
| 1637 | 1719 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
| 1638 | - if ($error != '') return $error; |
|
| 1720 | + if ($error != '') { |
|
| 1721 | + return $error; |
|
| 1722 | + } |
|
| 1639 | 1723 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
| 1640 | - if ($error != '') return $error; |
|
| 1724 | + if ($error != '') { |
|
| 1725 | + return $error; |
|
| 1726 | + } |
|
| 1641 | 1727 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
| 1642 | - if ($error != '') return $error; |
|
| 1728 | + if ($error != '') { |
|
| 1729 | + return $error; |
|
| 1730 | + } |
|
| 1643 | 1731 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
| 1644 | - if ($error != '') return $error; |
|
| 1732 | + if ($error != '') { |
|
| 1733 | + return $error; |
|
| 1734 | + } |
|
| 1645 | 1735 | } |
| 1646 | 1736 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
| 1647 | 1737 | try { |
@@ -1660,39 +1750,61 @@ discard block |
||
| 1660 | 1750 | if ($globalDBdriver == 'mysql') { |
| 1661 | 1751 | if (!$Connection->tableExists('marine_image')) { |
| 1662 | 1752 | $error .= create_db::import_file('../db/marine_image.sql'); |
| 1663 | - if ($error != '') return $error; |
|
| 1753 | + if ($error != '') { |
|
| 1754 | + return $error; |
|
| 1755 | + } |
|
| 1664 | 1756 | } |
| 1665 | 1757 | if (!$Connection->tableExists('marine_archive')) { |
| 1666 | 1758 | $error .= create_db::import_file('../db/marine_archive.sql'); |
| 1667 | - if ($error != '') return $error; |
|
| 1759 | + if ($error != '') { |
|
| 1760 | + return $error; |
|
| 1761 | + } |
|
| 1668 | 1762 | } |
| 1669 | 1763 | if (!$Connection->tableExists('marine_archive_output')) { |
| 1670 | 1764 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
| 1671 | - if ($error != '') return $error; |
|
| 1765 | + if ($error != '') { |
|
| 1766 | + return $error; |
|
| 1767 | + } |
|
| 1672 | 1768 | } |
| 1673 | 1769 | if (!$Connection->tableExists('tracker_archive')) { |
| 1674 | 1770 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
| 1675 | - if ($error != '') return $error; |
|
| 1771 | + if ($error != '') { |
|
| 1772 | + return $error; |
|
| 1773 | + } |
|
| 1676 | 1774 | } |
| 1677 | 1775 | if (!$Connection->tableExists('tracker_archive_output')) { |
| 1678 | 1776 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
| 1679 | - if ($error != '') return $error; |
|
| 1777 | + if ($error != '') { |
|
| 1778 | + return $error; |
|
| 1779 | + } |
|
| 1680 | 1780 | } |
| 1681 | 1781 | if (!$Connection->tableExists('marine_archive_output')) { |
| 1682 | 1782 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
| 1683 | - if ($error != '') return $error; |
|
| 1783 | + if ($error != '') { |
|
| 1784 | + return $error; |
|
| 1785 | + } |
|
| 1684 | 1786 | } |
| 1685 | 1787 | } else { |
| 1686 | 1788 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
| 1687 | - if ($error != '') return $error; |
|
| 1789 | + if ($error != '') { |
|
| 1790 | + return $error; |
|
| 1791 | + } |
|
| 1688 | 1792 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
| 1689 | - if ($error != '') return $error; |
|
| 1793 | + if ($error != '') { |
|
| 1794 | + return $error; |
|
| 1795 | + } |
|
| 1690 | 1796 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
| 1691 | - if ($error != '') return $error; |
|
| 1797 | + if ($error != '') { |
|
| 1798 | + return $error; |
|
| 1799 | + } |
|
| 1692 | 1800 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
| 1693 | - if ($error != '') return $error; |
|
| 1801 | + if ($error != '') { |
|
| 1802 | + return $error; |
|
| 1803 | + } |
|
| 1694 | 1804 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
| 1695 | - if ($error != '') return $error; |
|
| 1805 | + if ($error != '') { |
|
| 1806 | + return $error; |
|
| 1807 | + } |
|
| 1696 | 1808 | } |
| 1697 | 1809 | if ($globalDBdriver == 'mysql') { |
| 1698 | 1810 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
@@ -2063,7 +2175,9 @@ discard block |
||
| 2063 | 2175 | if ($globalDBdriver == 'mysql') { |
| 2064 | 2176 | if (!$Connection->tableExists('tracker_archive_output')) { |
| 2065 | 2177 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
| 2066 | - if ($error != '') return $error; |
|
| 2178 | + if ($error != '') { |
|
| 2179 | + return $error; |
|
| 2180 | + } |
|
| 2067 | 2181 | } |
| 2068 | 2182 | $query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;"; |
| 2069 | 2183 | } else { |
@@ -2091,14 +2205,22 @@ discard block |
||
| 2091 | 2205 | $error = ''; |
| 2092 | 2206 | if ($globalDBdriver == 'mysql') { |
| 2093 | 2207 | $error .= create_db::import_file('../db/airport.sql'); |
| 2094 | - if ($error != '') return $error; |
|
| 2208 | + if ($error != '') { |
|
| 2209 | + return $error; |
|
| 2210 | + } |
|
| 2095 | 2211 | $error .= create_db::import_file('../db/airlines.sql'); |
| 2096 | - if ($error != '') return $error; |
|
| 2212 | + if ($error != '') { |
|
| 2213 | + return $error; |
|
| 2214 | + } |
|
| 2097 | 2215 | } else { |
| 2098 | 2216 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
| 2099 | - if ($error != '') return $error; |
|
| 2217 | + if ($error != '') { |
|
| 2218 | + return $error; |
|
| 2219 | + } |
|
| 2100 | 2220 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
| 2101 | - if ($error != '') return $error; |
|
| 2221 | + if ($error != '') { |
|
| 2222 | + return $error; |
|
| 2223 | + } |
|
| 2102 | 2224 | } |
| 2103 | 2225 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
| 2104 | 2226 | if (file_exists('tmp/ivae_feb2013.zip')) { |
@@ -2115,7 +2237,9 @@ discard block |
||
| 2115 | 2237 | $error .= update_db::update_vatsim(); |
| 2116 | 2238 | } |
| 2117 | 2239 | } |
| 2118 | - if ($error != '') return $error; |
|
| 2240 | + if ($error != '') { |
|
| 2241 | + return $error; |
|
| 2242 | + } |
|
| 2119 | 2243 | $query = "UPDATE config SET value = '45' WHERE name = 'schema_version'"; |
| 2120 | 2244 | try { |
| 2121 | 2245 | $sth = $Connection->db->prepare($query); |
@@ -2133,10 +2257,14 @@ discard block |
||
| 2133 | 2257 | if (!$Connection->tableExists('satellite')) { |
| 2134 | 2258 | if ($globalDBdriver == 'mysql') { |
| 2135 | 2259 | $error .= create_db::import_file('../db/satellite.sql'); |
| 2136 | - if ($error != '') return $error; |
|
| 2260 | + if ($error != '') { |
|
| 2261 | + return $error; |
|
| 2262 | + } |
|
| 2137 | 2263 | } else { |
| 2138 | 2264 | $error .= create_db::import_file('../db/pgsql/satellite.sql'); |
| 2139 | - if ($error != '') return $error; |
|
| 2265 | + if ($error != '') { |
|
| 2266 | + return $error; |
|
| 2267 | + } |
|
| 2140 | 2268 | } |
| 2141 | 2269 | } |
| 2142 | 2270 | $query = "UPDATE config SET value = '46' WHERE name = 'schema_version'"; |
@@ -2156,37 +2284,53 @@ discard block |
||
| 2156 | 2284 | if (!$Connection->tableExists('stats_marine')) { |
| 2157 | 2285 | if ($globalDBdriver == 'mysql') { |
| 2158 | 2286 | $error .= create_db::import_file('../db/stats_marine.sql'); |
| 2159 | - if ($error != '') return $error; |
|
| 2287 | + if ($error != '') { |
|
| 2288 | + return $error; |
|
| 2289 | + } |
|
| 2160 | 2290 | } else { |
| 2161 | 2291 | $error .= create_db::import_file('../db/pgsql/stats_marine.sql'); |
| 2162 | - if ($error != '') return $error; |
|
| 2292 | + if ($error != '') { |
|
| 2293 | + return $error; |
|
| 2294 | + } |
|
| 2163 | 2295 | } |
| 2164 | 2296 | } |
| 2165 | 2297 | if (!$Connection->tableExists('stats_marine_country')) { |
| 2166 | 2298 | if ($globalDBdriver == 'mysql') { |
| 2167 | 2299 | $error .= create_db::import_file('../db/stats_marine_country.sql'); |
| 2168 | - if ($error != '') return $error; |
|
| 2300 | + if ($error != '') { |
|
| 2301 | + return $error; |
|
| 2302 | + } |
|
| 2169 | 2303 | } else { |
| 2170 | 2304 | $error .= create_db::import_file('../db/pgsql/stats_marine_country.sql'); |
| 2171 | - if ($error != '') return $error; |
|
| 2305 | + if ($error != '') { |
|
| 2306 | + return $error; |
|
| 2307 | + } |
|
| 2172 | 2308 | } |
| 2173 | 2309 | } |
| 2174 | 2310 | if (!$Connection->tableExists('stats_tracker')) { |
| 2175 | 2311 | if ($globalDBdriver == 'mysql') { |
| 2176 | 2312 | $error .= create_db::import_file('../db/stats_tracker.sql'); |
| 2177 | - if ($error != '') return $error; |
|
| 2313 | + if ($error != '') { |
|
| 2314 | + return $error; |
|
| 2315 | + } |
|
| 2178 | 2316 | } else { |
| 2179 | 2317 | $error .= create_db::import_file('../db/pgsql/stats_tracker.sql'); |
| 2180 | - if ($error != '') return $error; |
|
| 2318 | + if ($error != '') { |
|
| 2319 | + return $error; |
|
| 2320 | + } |
|
| 2181 | 2321 | } |
| 2182 | 2322 | } |
| 2183 | 2323 | if (!$Connection->tableExists('stats_tracker_country')) { |
| 2184 | 2324 | if ($globalDBdriver == 'mysql') { |
| 2185 | 2325 | $error .= create_db::import_file('../db/stats_tracker_country.sql'); |
| 2186 | - if ($error != '') return $error; |
|
| 2326 | + if ($error != '') { |
|
| 2327 | + return $error; |
|
| 2328 | + } |
|
| 2187 | 2329 | } else { |
| 2188 | 2330 | $error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql'); |
| 2189 | - if ($error != '') return $error; |
|
| 2331 | + if ($error != '') { |
|
| 2332 | + return $error; |
|
| 2333 | + } |
|
| 2190 | 2334 | } |
| 2191 | 2335 | } |
| 2192 | 2336 | $query = "UPDATE config SET value = '47' WHERE name = 'schema_version'"; |
@@ -2206,10 +2350,14 @@ discard block |
||
| 2206 | 2350 | if (!$Connection->tableExists('stats_marine_type')) { |
| 2207 | 2351 | if ($globalDBdriver == 'mysql') { |
| 2208 | 2352 | $error .= create_db::import_file('../db/stats_marine_type.sql'); |
| 2209 | - if ($error != '') return $error; |
|
| 2353 | + if ($error != '') { |
|
| 2354 | + return $error; |
|
| 2355 | + } |
|
| 2210 | 2356 | } else { |
| 2211 | 2357 | $error .= create_db::import_file('../db/pgsql/stats_marine_type.sql'); |
| 2212 | - if ($error != '') return $error; |
|
| 2358 | + if ($error != '') { |
|
| 2359 | + return $error; |
|
| 2360 | + } |
|
| 2213 | 2361 | } |
| 2214 | 2362 | } |
| 2215 | 2363 | $query = "UPDATE config SET value = '48' WHERE name = 'schema_version'"; |
@@ -2229,10 +2377,14 @@ discard block |
||
| 2229 | 2377 | if (!$Connection->tableExists('stats_tracker_type')) { |
| 2230 | 2378 | if ($globalDBdriver == 'mysql') { |
| 2231 | 2379 | $error .= create_db::import_file('../db/stats_tracker_type.sql'); |
| 2232 | - if ($error != '') return $error; |
|
| 2380 | + if ($error != '') { |
|
| 2381 | + return $error; |
|
| 2382 | + } |
|
| 2233 | 2383 | } else { |
| 2234 | 2384 | $error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql'); |
| 2235 | - if ($error != '') return $error; |
|
| 2385 | + if ($error != '') { |
|
| 2386 | + return $error; |
|
| 2387 | + } |
|
| 2236 | 2388 | } |
| 2237 | 2389 | } |
| 2238 | 2390 | $query = "UPDATE config SET value = '49' WHERE name = 'schema_version'"; |
@@ -2251,10 +2403,14 @@ discard block |
||
| 2251 | 2403 | $error = ''; |
| 2252 | 2404 | if ($globalDBdriver == 'mysql') { |
| 2253 | 2405 | $error .= create_db::import_file('../db/airport.sql'); |
| 2254 | - if ($error != '') return $error; |
|
| 2406 | + if ($error != '') { |
|
| 2407 | + return $error; |
|
| 2408 | + } |
|
| 2255 | 2409 | } else { |
| 2256 | 2410 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
| 2257 | - if ($error != '') return $error; |
|
| 2411 | + if ($error != '') { |
|
| 2412 | + return $error; |
|
| 2413 | + } |
|
| 2258 | 2414 | } |
| 2259 | 2415 | $query = "UPDATE config SET value = '50' WHERE name = 'schema_version'"; |
| 2260 | 2416 | try { |
@@ -2276,8 +2432,11 @@ discard block |
||
| 2276 | 2432 | if ($Connection->tableExists('aircraft')) { |
| 2277 | 2433 | if (!$Connection->tableExists('config')) { |
| 2278 | 2434 | $version = '1'; |
| 2279 | - if ($update) return self::update_from_1(); |
|
| 2280 | - else return $version; |
|
| 2435 | + if ($update) { |
|
| 2436 | + return self::update_from_1(); |
|
| 2437 | + } else { |
|
| 2438 | + return $version; |
|
| 2439 | + } |
|
| 2281 | 2440 | } else { |
| 2282 | 2441 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
| 2283 | 2442 | try { |
@@ -2290,203 +2449,354 @@ discard block |
||
| 2290 | 2449 | if ($update) { |
| 2291 | 2450 | if ($result['value'] == '2') { |
| 2292 | 2451 | $error = self::update_from_2(); |
| 2293 | - if ($error != '') return $error; |
|
| 2294 | - else return self::check_version(true); |
|
| 2452 | + if ($error != '') { |
|
| 2453 | + return $error; |
|
| 2454 | + } else { |
|
| 2455 | + return self::check_version(true); |
|
| 2456 | + } |
|
| 2295 | 2457 | } elseif ($result['value'] == '3') { |
| 2296 | 2458 | $error = self::update_from_3(); |
| 2297 | - if ($error != '') return $error; |
|
| 2298 | - else return self::check_version(true); |
|
| 2459 | + if ($error != '') { |
|
| 2460 | + return $error; |
|
| 2461 | + } else { |
|
| 2462 | + return self::check_version(true); |
|
| 2463 | + } |
|
| 2299 | 2464 | } elseif ($result['value'] == '4') { |
| 2300 | 2465 | $error = self::update_from_4(); |
| 2301 | - if ($error != '') return $error; |
|
| 2302 | - else return self::check_version(true); |
|
| 2466 | + if ($error != '') { |
|
| 2467 | + return $error; |
|
| 2468 | + } else { |
|
| 2469 | + return self::check_version(true); |
|
| 2470 | + } |
|
| 2303 | 2471 | } elseif ($result['value'] == '5') { |
| 2304 | 2472 | $error = self::update_from_5(); |
| 2305 | - if ($error != '') return $error; |
|
| 2306 | - else return self::check_version(true); |
|
| 2473 | + if ($error != '') { |
|
| 2474 | + return $error; |
|
| 2475 | + } else { |
|
| 2476 | + return self::check_version(true); |
|
| 2477 | + } |
|
| 2307 | 2478 | } elseif ($result['value'] == '6') { |
| 2308 | 2479 | $error = self::update_from_6(); |
| 2309 | - if ($error != '') return $error; |
|
| 2310 | - else return self::check_version(true); |
|
| 2480 | + if ($error != '') { |
|
| 2481 | + return $error; |
|
| 2482 | + } else { |
|
| 2483 | + return self::check_version(true); |
|
| 2484 | + } |
|
| 2311 | 2485 | } elseif ($result['value'] == '7') { |
| 2312 | 2486 | $error = self::update_from_7(); |
| 2313 | - if ($error != '') return $error; |
|
| 2314 | - else return self::check_version(true); |
|
| 2487 | + if ($error != '') { |
|
| 2488 | + return $error; |
|
| 2489 | + } else { |
|
| 2490 | + return self::check_version(true); |
|
| 2491 | + } |
|
| 2315 | 2492 | } elseif ($result['value'] == '8') { |
| 2316 | 2493 | $error = self::update_from_8(); |
| 2317 | - if ($error != '') return $error; |
|
| 2318 | - else return self::check_version(true); |
|
| 2494 | + if ($error != '') { |
|
| 2495 | + return $error; |
|
| 2496 | + } else { |
|
| 2497 | + return self::check_version(true); |
|
| 2498 | + } |
|
| 2319 | 2499 | } elseif ($result['value'] == '9') { |
| 2320 | 2500 | $error = self::update_from_9(); |
| 2321 | - if ($error != '') return $error; |
|
| 2322 | - else return self::check_version(true); |
|
| 2501 | + if ($error != '') { |
|
| 2502 | + return $error; |
|
| 2503 | + } else { |
|
| 2504 | + return self::check_version(true); |
|
| 2505 | + } |
|
| 2323 | 2506 | } elseif ($result['value'] == '10') { |
| 2324 | 2507 | $error = self::update_from_10(); |
| 2325 | - if ($error != '') return $error; |
|
| 2326 | - else return self::check_version(true); |
|
| 2508 | + if ($error != '') { |
|
| 2509 | + return $error; |
|
| 2510 | + } else { |
|
| 2511 | + return self::check_version(true); |
|
| 2512 | + } |
|
| 2327 | 2513 | } elseif ($result['value'] == '11') { |
| 2328 | 2514 | $error = self::update_from_11(); |
| 2329 | - if ($error != '') return $error; |
|
| 2330 | - else return self::check_version(true); |
|
| 2515 | + if ($error != '') { |
|
| 2516 | + return $error; |
|
| 2517 | + } else { |
|
| 2518 | + return self::check_version(true); |
|
| 2519 | + } |
|
| 2331 | 2520 | } elseif ($result['value'] == '12') { |
| 2332 | 2521 | $error = self::update_from_12(); |
| 2333 | - if ($error != '') return $error; |
|
| 2334 | - else return self::check_version(true); |
|
| 2522 | + if ($error != '') { |
|
| 2523 | + return $error; |
|
| 2524 | + } else { |
|
| 2525 | + return self::check_version(true); |
|
| 2526 | + } |
|
| 2335 | 2527 | } elseif ($result['value'] == '13') { |
| 2336 | 2528 | $error = self::update_from_13(); |
| 2337 | - if ($error != '') return $error; |
|
| 2338 | - else return self::check_version(true); |
|
| 2529 | + if ($error != '') { |
|
| 2530 | + return $error; |
|
| 2531 | + } else { |
|
| 2532 | + return self::check_version(true); |
|
| 2533 | + } |
|
| 2339 | 2534 | } elseif ($result['value'] == '14') { |
| 2340 | 2535 | $error = self::update_from_14(); |
| 2341 | - if ($error != '') return $error; |
|
| 2342 | - else return self::check_version(true); |
|
| 2536 | + if ($error != '') { |
|
| 2537 | + return $error; |
|
| 2538 | + } else { |
|
| 2539 | + return self::check_version(true); |
|
| 2540 | + } |
|
| 2343 | 2541 | } elseif ($result['value'] == '15') { |
| 2344 | 2542 | $error = self::update_from_15(); |
| 2345 | - if ($error != '') return $error; |
|
| 2346 | - else return self::check_version(true); |
|
| 2543 | + if ($error != '') { |
|
| 2544 | + return $error; |
|
| 2545 | + } else { |
|
| 2546 | + return self::check_version(true); |
|
| 2547 | + } |
|
| 2347 | 2548 | } elseif ($result['value'] == '16') { |
| 2348 | 2549 | $error = self::update_from_16(); |
| 2349 | - if ($error != '') return $error; |
|
| 2350 | - else return self::check_version(true); |
|
| 2550 | + if ($error != '') { |
|
| 2551 | + return $error; |
|
| 2552 | + } else { |
|
| 2553 | + return self::check_version(true); |
|
| 2554 | + } |
|
| 2351 | 2555 | } elseif ($result['value'] == '17') { |
| 2352 | 2556 | $error = self::update_from_17(); |
| 2353 | - if ($error != '') return $error; |
|
| 2354 | - else return self::check_version(true); |
|
| 2557 | + if ($error != '') { |
|
| 2558 | + return $error; |
|
| 2559 | + } else { |
|
| 2560 | + return self::check_version(true); |
|
| 2561 | + } |
|
| 2355 | 2562 | } elseif ($result['value'] == '18') { |
| 2356 | 2563 | $error = self::update_from_18(); |
| 2357 | - if ($error != '') return $error; |
|
| 2358 | - else return self::check_version(true); |
|
| 2564 | + if ($error != '') { |
|
| 2565 | + return $error; |
|
| 2566 | + } else { |
|
| 2567 | + return self::check_version(true); |
|
| 2568 | + } |
|
| 2359 | 2569 | } elseif ($result['value'] == '19') { |
| 2360 | 2570 | $error = self::update_from_19(); |
| 2361 | - if ($error != '') return $error; |
|
| 2362 | - else return self::check_version(true); |
|
| 2571 | + if ($error != '') { |
|
| 2572 | + return $error; |
|
| 2573 | + } else { |
|
| 2574 | + return self::check_version(true); |
|
| 2575 | + } |
|
| 2363 | 2576 | } elseif ($result['value'] == '20') { |
| 2364 | 2577 | $error = self::update_from_20(); |
| 2365 | - if ($error != '') return $error; |
|
| 2366 | - else return self::check_version(true); |
|
| 2578 | + if ($error != '') { |
|
| 2579 | + return $error; |
|
| 2580 | + } else { |
|
| 2581 | + return self::check_version(true); |
|
| 2582 | + } |
|
| 2367 | 2583 | } elseif ($result['value'] == '21') { |
| 2368 | 2584 | $error = self::update_from_21(); |
| 2369 | - if ($error != '') return $error; |
|
| 2370 | - else return self::check_version(true); |
|
| 2585 | + if ($error != '') { |
|
| 2586 | + return $error; |
|
| 2587 | + } else { |
|
| 2588 | + return self::check_version(true); |
|
| 2589 | + } |
|
| 2371 | 2590 | } elseif ($result['value'] == '22') { |
| 2372 | 2591 | $error = self::update_from_22(); |
| 2373 | - if ($error != '') return $error; |
|
| 2374 | - else return self::check_version(true); |
|
| 2592 | + if ($error != '') { |
|
| 2593 | + return $error; |
|
| 2594 | + } else { |
|
| 2595 | + return self::check_version(true); |
|
| 2596 | + } |
|
| 2375 | 2597 | } elseif ($result['value'] == '23') { |
| 2376 | 2598 | $error = self::update_from_23(); |
| 2377 | - if ($error != '') return $error; |
|
| 2378 | - else return self::check_version(true); |
|
| 2599 | + if ($error != '') { |
|
| 2600 | + return $error; |
|
| 2601 | + } else { |
|
| 2602 | + return self::check_version(true); |
|
| 2603 | + } |
|
| 2379 | 2604 | } elseif ($result['value'] == '24') { |
| 2380 | 2605 | $error = self::update_from_24(); |
| 2381 | - if ($error != '') return $error; |
|
| 2382 | - else return self::check_version(true); |
|
| 2606 | + if ($error != '') { |
|
| 2607 | + return $error; |
|
| 2608 | + } else { |
|
| 2609 | + return self::check_version(true); |
|
| 2610 | + } |
|
| 2383 | 2611 | } elseif ($result['value'] == '25') { |
| 2384 | 2612 | $error = self::update_from_25(); |
| 2385 | - if ($error != '') return $error; |
|
| 2386 | - else return self::check_version(true); |
|
| 2613 | + if ($error != '') { |
|
| 2614 | + return $error; |
|
| 2615 | + } else { |
|
| 2616 | + return self::check_version(true); |
|
| 2617 | + } |
|
| 2387 | 2618 | } elseif ($result['value'] == '26') { |
| 2388 | 2619 | $error = self::update_from_26(); |
| 2389 | - if ($error != '') return $error; |
|
| 2390 | - else return self::check_version(true); |
|
| 2620 | + if ($error != '') { |
|
| 2621 | + return $error; |
|
| 2622 | + } else { |
|
| 2623 | + return self::check_version(true); |
|
| 2624 | + } |
|
| 2391 | 2625 | } elseif ($result['value'] == '27') { |
| 2392 | 2626 | $error = self::update_from_27(); |
| 2393 | - if ($error != '') return $error; |
|
| 2394 | - else return self::check_version(true); |
|
| 2627 | + if ($error != '') { |
|
| 2628 | + return $error; |
|
| 2629 | + } else { |
|
| 2630 | + return self::check_version(true); |
|
| 2631 | + } |
|
| 2395 | 2632 | } elseif ($result['value'] == '28') { |
| 2396 | 2633 | $error = self::update_from_28(); |
| 2397 | - if ($error != '') return $error; |
|
| 2398 | - else return self::check_version(true); |
|
| 2634 | + if ($error != '') { |
|
| 2635 | + return $error; |
|
| 2636 | + } else { |
|
| 2637 | + return self::check_version(true); |
|
| 2638 | + } |
|
| 2399 | 2639 | } elseif ($result['value'] == '29') { |
| 2400 | 2640 | $error = self::update_from_29(); |
| 2401 | - if ($error != '') return $error; |
|
| 2402 | - else return self::check_version(true); |
|
| 2641 | + if ($error != '') { |
|
| 2642 | + return $error; |
|
| 2643 | + } else { |
|
| 2644 | + return self::check_version(true); |
|
| 2645 | + } |
|
| 2403 | 2646 | } elseif ($result['value'] == '30') { |
| 2404 | 2647 | $error = self::update_from_30(); |
| 2405 | - if ($error != '') return $error; |
|
| 2406 | - else return self::check_version(true); |
|
| 2648 | + if ($error != '') { |
|
| 2649 | + return $error; |
|
| 2650 | + } else { |
|
| 2651 | + return self::check_version(true); |
|
| 2652 | + } |
|
| 2407 | 2653 | } elseif ($result['value'] == '31') { |
| 2408 | 2654 | $error = self::update_from_31(); |
| 2409 | - if ($error != '') return $error; |
|
| 2410 | - else return self::check_version(true); |
|
| 2655 | + if ($error != '') { |
|
| 2656 | + return $error; |
|
| 2657 | + } else { |
|
| 2658 | + return self::check_version(true); |
|
| 2659 | + } |
|
| 2411 | 2660 | } elseif ($result['value'] == '32') { |
| 2412 | 2661 | $error = self::update_from_32(); |
| 2413 | - if ($error != '') return $error; |
|
| 2414 | - else return self::check_version(true); |
|
| 2662 | + if ($error != '') { |
|
| 2663 | + return $error; |
|
| 2664 | + } else { |
|
| 2665 | + return self::check_version(true); |
|
| 2666 | + } |
|
| 2415 | 2667 | } elseif ($result['value'] == '33') { |
| 2416 | 2668 | $error = self::update_from_33(); |
| 2417 | - if ($error != '') return $error; |
|
| 2418 | - else return self::check_version(true); |
|
| 2669 | + if ($error != '') { |
|
| 2670 | + return $error; |
|
| 2671 | + } else { |
|
| 2672 | + return self::check_version(true); |
|
| 2673 | + } |
|
| 2419 | 2674 | } elseif ($result['value'] == '34') { |
| 2420 | 2675 | $error = self::update_from_34(); |
| 2421 | - if ($error != '') return $error; |
|
| 2422 | - else return self::check_version(true); |
|
| 2676 | + if ($error != '') { |
|
| 2677 | + return $error; |
|
| 2678 | + } else { |
|
| 2679 | + return self::check_version(true); |
|
| 2680 | + } |
|
| 2423 | 2681 | } elseif ($result['value'] == '35') { |
| 2424 | 2682 | $error = self::update_from_35(); |
| 2425 | - if ($error != '') return $error; |
|
| 2426 | - else return self::check_version(true); |
|
| 2683 | + if ($error != '') { |
|
| 2684 | + return $error; |
|
| 2685 | + } else { |
|
| 2686 | + return self::check_version(true); |
|
| 2687 | + } |
|
| 2427 | 2688 | } elseif ($result['value'] == '36') { |
| 2428 | 2689 | $error = self::update_from_36(); |
| 2429 | - if ($error != '') return $error; |
|
| 2430 | - else return self::check_version(true); |
|
| 2690 | + if ($error != '') { |
|
| 2691 | + return $error; |
|
| 2692 | + } else { |
|
| 2693 | + return self::check_version(true); |
|
| 2694 | + } |
|
| 2431 | 2695 | } elseif ($result['value'] == '37') { |
| 2432 | 2696 | $error = self::update_from_37(); |
| 2433 | - if ($error != '') return $error; |
|
| 2434 | - else return self::check_version(true); |
|
| 2697 | + if ($error != '') { |
|
| 2698 | + return $error; |
|
| 2699 | + } else { |
|
| 2700 | + return self::check_version(true); |
|
| 2701 | + } |
|
| 2435 | 2702 | } elseif ($result['value'] == '38') { |
| 2436 | 2703 | $error = self::update_from_38(); |
| 2437 | - if ($error != '') return $error; |
|
| 2438 | - else return self::check_version(true); |
|
| 2704 | + if ($error != '') { |
|
| 2705 | + return $error; |
|
| 2706 | + } else { |
|
| 2707 | + return self::check_version(true); |
|
| 2708 | + } |
|
| 2439 | 2709 | } elseif ($result['value'] == '39') { |
| 2440 | 2710 | $error = self::update_from_39(); |
| 2441 | - if ($error != '') return $error; |
|
| 2442 | - else return self::check_version(true); |
|
| 2711 | + if ($error != '') { |
|
| 2712 | + return $error; |
|
| 2713 | + } else { |
|
| 2714 | + return self::check_version(true); |
|
| 2715 | + } |
|
| 2443 | 2716 | } elseif ($result['value'] == '40') { |
| 2444 | 2717 | $error = self::update_from_40(); |
| 2445 | - if ($error != '') return $error; |
|
| 2446 | - else return self::check_version(true); |
|
| 2718 | + if ($error != '') { |
|
| 2719 | + return $error; |
|
| 2720 | + } else { |
|
| 2721 | + return self::check_version(true); |
|
| 2722 | + } |
|
| 2447 | 2723 | } elseif ($result['value'] == '41') { |
| 2448 | 2724 | $error = self::update_from_41(); |
| 2449 | - if ($error != '') return $error; |
|
| 2450 | - else return self::check_version(true); |
|
| 2725 | + if ($error != '') { |
|
| 2726 | + return $error; |
|
| 2727 | + } else { |
|
| 2728 | + return self::check_version(true); |
|
| 2729 | + } |
|
| 2451 | 2730 | } elseif ($result['value'] == '42') { |
| 2452 | 2731 | $error = self::update_from_42(); |
| 2453 | - if ($error != '') return $error; |
|
| 2454 | - else return self::check_version(true); |
|
| 2732 | + if ($error != '') { |
|
| 2733 | + return $error; |
|
| 2734 | + } else { |
|
| 2735 | + return self::check_version(true); |
|
| 2736 | + } |
|
| 2455 | 2737 | } elseif ($result['value'] == '43') { |
| 2456 | 2738 | $error = self::update_from_43(); |
| 2457 | - if ($error != '') return $error; |
|
| 2458 | - else return self::check_version(true); |
|
| 2739 | + if ($error != '') { |
|
| 2740 | + return $error; |
|
| 2741 | + } else { |
|
| 2742 | + return self::check_version(true); |
|
| 2743 | + } |
|
| 2459 | 2744 | } elseif ($result['value'] == '44') { |
| 2460 | 2745 | $error = self::update_from_44(); |
| 2461 | - if ($error != '') return $error; |
|
| 2462 | - else return self::check_version(true); |
|
| 2746 | + if ($error != '') { |
|
| 2747 | + return $error; |
|
| 2748 | + } else { |
|
| 2749 | + return self::check_version(true); |
|
| 2750 | + } |
|
| 2463 | 2751 | } elseif ($result['value'] == '45') { |
| 2464 | 2752 | $error = self::update_from_45(); |
| 2465 | - if ($error != '') return $error; |
|
| 2466 | - else return self::check_version(true); |
|
| 2753 | + if ($error != '') { |
|
| 2754 | + return $error; |
|
| 2755 | + } else { |
|
| 2756 | + return self::check_version(true); |
|
| 2757 | + } |
|
| 2467 | 2758 | } elseif ($result['value'] == '46') { |
| 2468 | 2759 | $error = self::update_from_46(); |
| 2469 | - if ($error != '') return $error; |
|
| 2470 | - else return self::check_version(true); |
|
| 2760 | + if ($error != '') { |
|
| 2761 | + return $error; |
|
| 2762 | + } else { |
|
| 2763 | + return self::check_version(true); |
|
| 2764 | + } |
|
| 2471 | 2765 | } elseif ($result['value'] == '47') { |
| 2472 | 2766 | $error = self::update_from_47(); |
| 2473 | - if ($error != '') return $error; |
|
| 2474 | - else return self::check_version(true); |
|
| 2767 | + if ($error != '') { |
|
| 2768 | + return $error; |
|
| 2769 | + } else { |
|
| 2770 | + return self::check_version(true); |
|
| 2771 | + } |
|
| 2475 | 2772 | } elseif ($result['value'] == '48') { |
| 2476 | 2773 | $error = self::update_from_48(); |
| 2477 | - if ($error != '') return $error; |
|
| 2478 | - else return self::check_version(true); |
|
| 2774 | + if ($error != '') { |
|
| 2775 | + return $error; |
|
| 2776 | + } else { |
|
| 2777 | + return self::check_version(true); |
|
| 2778 | + } |
|
| 2479 | 2779 | } elseif ($result['value'] == '49') { |
| 2480 | 2780 | $error = self::update_from_49(); |
| 2481 | - if ($error != '') return $error; |
|
| 2482 | - else return self::check_version(true); |
|
| 2483 | - } else return ''; |
|
| 2781 | + if ($error != '') { |
|
| 2782 | + return $error; |
|
| 2783 | + } else { |
|
| 2784 | + return self::check_version(true); |
|
| 2785 | + } |
|
| 2786 | + } else { |
|
| 2787 | + return ''; |
|
| 2788 | + } |
|
| 2484 | 2789 | } else { |
| 2485 | - if (isset($result['value']) && $result['value'] != '') return $result['value']; |
|
| 2486 | - else return 0; |
|
| 2790 | + if (isset($result['value']) && $result['value'] != '') { |
|
| 2791 | + return $result['value']; |
|
| 2792 | + } else { |
|
| 2793 | + return 0; |
|
| 2794 | + } |
|
| 2487 | 2795 | } |
| 2488 | 2796 | } |
| 2489 | - } else return $version; |
|
| 2797 | + } else { |
|
| 2798 | + return $version; |
|
| 2799 | + } |
|
| 2490 | 2800 | } |
| 2491 | 2801 | } |
| 2492 | 2802 | } |
@@ -123,7 +123,9 @@ discard block |
||
| 123 | 123 | $temp += 1; |
| 124 | 124 | $flat = (float)($temp / (60.0 * 10000.0)); |
| 125 | 125 | $flat *= -1.0; |
| 126 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 126 | + } else { |
|
| 127 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 128 | + } |
|
| 127 | 129 | return $flat; // float |
| 128 | 130 | } |
| 129 | 131 | |
@@ -135,7 +137,9 @@ discard block |
||
| 135 | 137 | $temp += 1; |
| 136 | 138 | $flon = (float)($temp / (60.0 * 10000.0)); |
| 137 | 139 | $flon *= -1.0; |
| 138 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 140 | + } else { |
|
| 141 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 142 | + } |
|
| 139 | 143 | return $flon; |
| 140 | 144 | } |
| 141 | 145 | |
@@ -158,10 +162,8 @@ discard block |
||
| 158 | 162 | */ |
| 159 | 163 | private function asciidec_2_8bit($ascii) { |
| 160 | 164 | //only process in the following range: 48-87, 96-119 |
| 161 | - if ($ascii < 48) { } |
|
| 162 | - else { |
|
| 163 | - if($ascii>119) { } |
|
| 164 | - else { |
|
| 165 | + if ($ascii < 48) { } else { |
|
| 166 | + if($ascii>119) { } else { |
|
| 165 | 167 | if ($ascii>87 && $ascii<96) ; |
| 166 | 168 | else { |
| 167 | 169 | $ascii=$ascii+40; |
@@ -263,7 +265,9 @@ discard block |
||
| 263 | 265 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
| 264 | 266 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
| 265 | 267 | $ro->heading = bindec(substr($_aisdata,124,9)); |
| 266 | - if ($ro->heading == 511) $ro->heading = ''; |
|
| 268 | + if ($ro->heading == 511) { |
|
| 269 | + $ro->heading = ''; |
|
| 270 | + } |
|
| 267 | 271 | $ro->cls = 2; // class B |
| 268 | 272 | } else if ($ro->id == 19) { |
| 269 | 273 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -273,7 +277,9 @@ discard block |
||
| 273 | 277 | $ro->name = $this->binchar($_aisdata,143,120); |
| 274 | 278 | $ro->cls = 2; // class B |
| 275 | 279 | $ro->heading = bindec(substr($_aisdata,124,9)); |
| 276 | - if ($ro->heading == 511) $ro->heading = ''; |
|
| 280 | + if ($ro->heading == 511) { |
|
| 281 | + $ro->heading = ''; |
|
| 282 | + } |
|
| 277 | 283 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
| 278 | 284 | $ro->type = $this->getShipType($ro->typeid); |
| 279 | 285 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -304,9 +310,13 @@ discard block |
||
| 304 | 310 | $ro->cls = 2; // class B |
| 305 | 311 | } else if ($ro->id == 27) { |
| 306 | 312 | $ro->cog = bindec(substr($_aisdata,85,9)); |
| 307 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
| 313 | + if ($ro->cog == 511) { |
|
| 314 | + $ro->cog = 0.0; |
|
| 315 | + } |
|
| 308 | 316 | $ro->sog = bindec(substr($_aisdata,79,6)); |
| 309 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
| 317 | + if ($ro->sog == 63) { |
|
| 318 | + $ro->sog = 0.0; |
|
| 319 | + } |
|
| 310 | 320 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
| 311 | 321 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
| 312 | 322 | $ro->cls = 1; // class A |
@@ -354,28 +364,48 @@ discard block |
||
| 354 | 364 | } |
| 355 | 365 | |
| 356 | 366 | public function getShipType($code) { |
| 357 | - if (isset($this->shiptype[$code])) return $this->shiptype[$code]; |
|
| 358 | - else return ''; |
|
| 367 | + if (isset($this->shiptype[$code])) { |
|
| 368 | + return $this->shiptype[$code]; |
|
| 369 | + } else { |
|
| 370 | + return ''; |
|
| 371 | + } |
|
| 359 | 372 | } |
| 360 | 373 | |
| 361 | 374 | public function getShipTypeID($type) { |
| 362 | 375 | $typeid = array_search($type,$this->shiptype); |
| 363 | - if ($typeid !== FALSE) return $typeid; |
|
| 364 | - elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') return 70; |
|
| 365 | - elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') return 60; |
|
| 366 | - elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') return 80; |
|
| 367 | - elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') return 84; |
|
| 368 | - elseif ($type == 'Sailing Vessel') return 36; |
|
| 369 | - elseif ($type == 'Yacht') return 37; |
|
| 370 | - elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') return 33; |
|
| 371 | - elseif ($type == 'High speed craft') return 40; |
|
| 372 | - elseif ($type == 'Crew Boat') return 53; |
|
| 373 | - elseif ($type == 'Icebreaker') return 52; |
|
| 374 | - elseif ($type == 'Pollution Control Vessel') return 54; |
|
| 375 | - elseif ($type == 'Other Type') return 90; |
|
| 376 | - elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') return 59; |
|
| 377 | - elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') return 30; |
|
| 378 | - else return 0; |
|
| 376 | + if ($typeid !== FALSE) { |
|
| 377 | + return $typeid; |
|
| 378 | + } elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') { |
|
| 379 | + return 70; |
|
| 380 | + } elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') { |
|
| 381 | + return 60; |
|
| 382 | + } elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') { |
|
| 383 | + return 80; |
|
| 384 | + } elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') { |
|
| 385 | + return 84; |
|
| 386 | + } elseif ($type == 'Sailing Vessel') { |
|
| 387 | + return 36; |
|
| 388 | + } elseif ($type == 'Yacht') { |
|
| 389 | + return 37; |
|
| 390 | + } elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') { |
|
| 391 | + return 33; |
|
| 392 | + } elseif ($type == 'High speed craft') { |
|
| 393 | + return 40; |
|
| 394 | + } elseif ($type == 'Crew Boat') { |
|
| 395 | + return 53; |
|
| 396 | + } elseif ($type == 'Icebreaker') { |
|
| 397 | + return 52; |
|
| 398 | + } elseif ($type == 'Pollution Control Vessel') { |
|
| 399 | + return 54; |
|
| 400 | + } elseif ($type == 'Other Type') { |
|
| 401 | + return 90; |
|
| 402 | + } elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') { |
|
| 403 | + return 59; |
|
| 404 | + } elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') { |
|
| 405 | + return 30; |
|
| 406 | + } else { |
|
| 407 | + return 0; |
|
| 408 | + } |
|
| 379 | 409 | } |
| 380 | 410 | |
| 381 | 411 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -412,11 +442,20 @@ discard block |
||
| 412 | 442 | // assume 1st ! is valid |
| 413 | 443 | // find * ensure that it is at correct position |
| 414 | 444 | $end = strrpos ( $rawdata , '*' ); |
| 415 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
| 445 | + if ($end === FALSE) { |
|
| 446 | + return -1; |
|
| 447 | + } |
|
| 448 | + // check for NULLS!!! |
|
| 416 | 449 | $cs = substr( $rawdata, $end + 1 ); |
| 417 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
| 450 | + if ( strlen($cs) != 2 ) { |
|
| 451 | + return -1; |
|
| 452 | + } |
|
| 453 | + // correct cs length |
|
| 418 | 454 | $dcs = (int)hexdec( $cs ); |
| 419 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
| 455 | + for ( $alias=1; $alias<$end; $alias++) { |
|
| 456 | + $chksum ^= ord( $rawdata[$alias] ); |
|
| 457 | + } |
|
| 458 | + // perform XOR for NMEA checksum |
|
| 420 | 459 | if ( $chksum == $dcs ) { // NMEA checksum pass |
| 421 | 460 | $pcs = explode(',', $rawdata); |
| 422 | 461 | // !AI??? identifier |
@@ -427,8 +466,14 @@ discard block |
||
| 427 | 466 | $num_seq = (int)$pcs[1]; // number of sequences |
| 428 | 467 | $seq = (int)$pcs[2]; // get sequence |
| 429 | 468 | // get msg sequence id |
| 430 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
| 431 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
| 469 | + if ($pcs[3] == '') { |
|
| 470 | + $msg_sid = -1; |
|
| 471 | + } |
|
| 472 | + // non-multipart message, set to -1 |
|
| 473 | + else { |
|
| 474 | + $msg_sid = (int)$pcs[3]; |
|
| 475 | + } |
|
| 476 | + // multipart message |
|
| 432 | 477 | $ais_ch = $pcs[4]; // get AIS channel |
| 433 | 478 | // message sequence checking |
| 434 | 479 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -491,10 +536,18 @@ discard block |
||
| 491 | 536 | //DEBUG echo "[$start $end $tst]\n"; |
| 492 | 537 | $result = $this->process_ais_raw( $tst, "" ); |
| 493 | 538 | $last_pos = $end + 1; |
| 494 | - } else break; |
|
| 539 | + } else { |
|
| 540 | + break; |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + if ($last_pos > 0) { |
|
| 544 | + $cbuf = substr($cbuf, $last_pos); |
|
| 495 | 545 | } |
| 496 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
| 497 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
| 546 | + // move... |
|
| 547 | + if (strlen($cbuf) > 1024) { |
|
| 548 | + $cbuf = ""; |
|
| 549 | + } |
|
| 550 | + // prevent overflow simple mode... |
|
| 498 | 551 | return $result; |
| 499 | 552 | } |
| 500 | 553 | |
@@ -514,7 +567,9 @@ discard block |
||
| 514 | 567 | if ($lat<0.0) { |
| 515 | 568 | $lat = -$lat; |
| 516 | 569 | $neg=true; |
| 517 | - } else $neg=false; |
|
| 570 | + } else { |
|
| 571 | + $neg=false; |
|
| 572 | + } |
|
| 518 | 573 | $latd = 0x00000000; |
| 519 | 574 | $latd = intval ($lat * 600000.0); |
| 520 | 575 | if ($neg==true) { |
@@ -530,7 +585,9 @@ discard block |
||
| 530 | 585 | if ($lon<0.0) { |
| 531 | 586 | $lon = -$lon; |
| 532 | 587 | $neg=true; |
| 533 | - } else $neg=false; |
|
| 588 | + } else { |
|
| 589 | + $neg=false; |
|
| 590 | + } |
|
| 534 | 591 | $lond = 0x00000000; |
| 535 | 592 | $lond = intval ($lon * 600000.0); |
| 536 | 593 | if ($neg==true) { |
@@ -543,9 +600,14 @@ discard block |
||
| 543 | 600 | |
| 544 | 601 | private function char2bin($name, $max_len) { |
| 545 | 602 | $len = strlen($name); |
| 546 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
| 547 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 548 | - else $pad = ''; |
|
| 603 | + if ($len > $max_len) { |
|
| 604 | + $name = substr($name,0,$max_len); |
|
| 605 | + } |
|
| 606 | + if ($len < $max_len) { |
|
| 607 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 608 | + } else { |
|
| 609 | + $pad = ''; |
|
| 610 | + } |
|
| 549 | 611 | $rv = ''; |
| 550 | 612 | $ais_chars = array( |
| 551 | 613 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -558,9 +620,12 @@ discard block |
||
| 558 | 620 | ); |
| 559 | 621 | // " |
| 560 | 622 | $_a = str_split($name); |
| 561 | - if ($_a) foreach ($_a as $_1) { |
|
| 623 | + if ($_a) { |
|
| 624 | + foreach ($_a as $_1) { |
|
| 562 | 625 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
| 563 | - else $dec = 0; |
|
| 626 | + } else { |
|
| 627 | + $dec = 0; |
|
| 628 | + } |
|
| 564 | 629 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
| 565 | 630 | $rv .= $bin; |
| 566 | 631 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -572,7 +637,9 @@ discard block |
||
| 572 | 637 | $len_bit = strlen($_enc); |
| 573 | 638 | $rem6 = $len_bit % 6; |
| 574 | 639 | $pad6_len = 0; |
| 575 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
| 640 | + if ($rem6) { |
|
| 641 | + $pad6_len = 6 - $rem6; |
|
| 642 | + } |
|
| 576 | 643 | //echo $pad6_len.'<br>'; |
| 577 | 644 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
| 578 | 645 | $len_enc = strlen($_enc) / 6; |
@@ -581,8 +648,11 @@ discard block |
||
| 581 | 648 | for ($i=0; $i<$len_enc; $i++) { |
| 582 | 649 | $offset = $i * 6; |
| 583 | 650 | $dec = bindec(substr($_enc,$offset,6)); |
| 584 | - if ($dec < 40) $dec += 48; |
|
| 585 | - else $dec += 56; |
|
| 651 | + if ($dec < 40) { |
|
| 652 | + $dec += 48; |
|
| 653 | + } else { |
|
| 654 | + $dec += 56; |
|
| 655 | + } |
|
| 586 | 656 | //echo chr($dec)." $dec<br/>"; |
| 587 | 657 | $itu .= chr($dec); |
| 588 | 658 | } |
@@ -595,26 +665,42 @@ discard block |
||
| 595 | 665 | } |
| 596 | 666 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
| 597 | 667 | $lsb = $chksum & 0x0F; |
| 598 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
| 599 | - else $lsbc = '0'; |
|
| 668 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
| 669 | + $lsbc = $hex_arr[$lsb]; |
|
| 670 | + } else { |
|
| 671 | + $lsbc = '0'; |
|
| 672 | + } |
|
| 600 | 673 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
| 601 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
| 602 | - else $msbc = '0'; |
|
| 674 | + if ($msb >=0 && $msb <= 15 ) { |
|
| 675 | + $msbc = $hex_arr[$msb]; |
|
| 676 | + } else { |
|
| 677 | + $msbc = '0'; |
|
| 678 | + } |
|
| 603 | 679 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
| 604 | 680 | return $itu; |
| 605 | 681 | } |
| 606 | 682 | |
| 607 | 683 | public function parse($buffer) { |
| 608 | 684 | $data = $this->process_ais_buf($buffer); |
| 609 | - if (!is_object($data)) return array(); |
|
| 685 | + if (!is_object($data)) { |
|
| 686 | + return array(); |
|
| 687 | + } |
|
| 610 | 688 | $result = array(); |
| 611 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 612 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 689 | + if ($data->lon != 0) { |
|
| 690 | + $result['longitude'] = $data->lon; |
|
| 691 | + } |
|
| 692 | + if ($data->lat != 0) { |
|
| 693 | + $result['latitude'] = $data->lat; |
|
| 694 | + } |
|
| 613 | 695 | $result['ident'] = trim($data->name); |
| 614 | 696 | $result['timestamp'] = $data->ts; |
| 615 | 697 | $result['mmsi'] = $data->mmsi; |
| 616 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 617 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 698 | + if ($data->sog != -1.0) { |
|
| 699 | + $result['speed'] = $data->sog; |
|
| 700 | + } |
|
| 701 | + if ($data->cog != 0) { |
|
| 702 | + $result['heading'] = $data->cog; |
|
| 703 | + } |
|
| 618 | 704 | /* |
| 619 | 705 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
| 620 | 706 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -624,15 +710,25 @@ discard block |
||
| 624 | 710 | |
| 625 | 711 | public function mmsitype($mmsi) { |
| 626 | 712 | if (strlen($mmsi) == 9) { |
| 627 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 628 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
| 629 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 630 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
| 631 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
| 632 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
| 633 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
| 634 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
| 635 | - else return 'Ship'; |
|
| 713 | + if (substr($mmsi,0,3) == '974') { |
|
| 714 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 715 | + } elseif (substr($mmsi,0,3) == '972') { |
|
| 716 | + return 'MOB (Man Overboard) device'; |
|
| 717 | + } elseif (substr($mmsi,0,3) == '970') { |
|
| 718 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 719 | + } elseif (substr($mmsi,0,3) == '111') { |
|
| 720 | + return 'SAR (Search and Rescue) aircraft'; |
|
| 721 | + } elseif (substr($mmsi,0,2) == '98') { |
|
| 722 | + return 'Auxiliary craft associated with a parent ship'; |
|
| 723 | + } elseif (substr($mmsi,0,2) == '99') { |
|
| 724 | + return 'Aids to Navigation'; |
|
| 725 | + } elseif (substr($mmsi,0,2) == '00') { |
|
| 726 | + return 'Coastal stations'; |
|
| 727 | + } elseif (substr($mmsi,0,1) == '0') { |
|
| 728 | + return 'Group of ships'; |
|
| 729 | + } else { |
|
| 730 | + return 'Ship'; |
|
| 731 | + } |
|
| 636 | 732 | } |
| 637 | 733 | |
| 638 | 734 | |
@@ -648,32 +744,61 @@ discard block |
||
| 648 | 744 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
| 649 | 745 | return array(); |
| 650 | 746 | } |
| 651 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 652 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 747 | + if ($data->lon != 0) { |
|
| 748 | + $result['longitude'] = $data->lon; |
|
| 749 | + } |
|
| 750 | + if ($data->lat != 0) { |
|
| 751 | + $result['latitude'] = $data->lat; |
|
| 752 | + } |
|
| 653 | 753 | $result['ident'] = trim(str_replace('@','',$data->name)); |
| 654 | 754 | $result['timestamp'] = $data->ts; |
| 655 | 755 | $result['mmsi'] = $data->mmsi; |
| 656 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
| 756 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
| 757 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
| 758 | + } |
|
| 657 | 759 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
| 658 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 659 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
| 660 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 661 | - if ($data->status != '') $result['status'] = $data->status; |
|
| 662 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
| 663 | - if ($data->type !== '') $result['type'] = $data->type; |
|
| 664 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
| 665 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
| 666 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 760 | + if ($data->sog != -1.0) { |
|
| 761 | + $result['speed'] = $data->sog; |
|
| 762 | + } |
|
| 763 | + if ($data->heading !== '') { |
|
| 764 | + $result['heading'] = $data->heading; |
|
| 765 | + } elseif ($data->cog != 0) { |
|
| 766 | + $result['heading'] = $data->cog; |
|
| 767 | + } |
|
| 768 | + if ($data->status != '') { |
|
| 769 | + $result['status'] = $data->status; |
|
| 770 | + } |
|
| 771 | + if ($data->statusid !== '') { |
|
| 772 | + $result['statusid'] = $data->statusid; |
|
| 773 | + } |
|
| 774 | + if ($data->type !== '') { |
|
| 775 | + $result['type'] = $data->type; |
|
| 776 | + } |
|
| 777 | + if ($data->typeid !== '') { |
|
| 778 | + $result['typeid'] = $data->typeid; |
|
| 779 | + } |
|
| 780 | + if ($data->imo !== '') { |
|
| 781 | + $result['imo'] = $data->imo; |
|
| 782 | + } |
|
| 783 | + if ($data->callsign !== '') { |
|
| 784 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 785 | + } |
|
| 667 | 786 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
| 668 | 787 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
| 669 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
| 788 | + if ($eta_ts != '') { |
|
| 789 | + $result['eta_ts'] = $eta_ts; |
|
| 790 | + } |
|
| 670 | 791 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
| 671 | 792 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
| 672 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
| 793 | + if ($eta_ts != '') { |
|
| 794 | + $result['eta_ts'] = $eta_ts; |
|
| 795 | + } |
|
| 673 | 796 | } |
| 674 | 797 | if ($data->destination != '') { |
| 675 | 798 | $dest = trim(str_replace('@','',$data->destination)); |
| 676 | - if ($dest != '') $result['destination'] = $dest; |
|
| 799 | + if ($dest != '') { |
|
| 800 | + $result['destination'] = $dest; |
|
| 801 | + } |
|
| 677 | 802 | } |
| 678 | 803 | $result['all'] = (array) $data; |
| 679 | 804 | /* |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function checkAll() { |
| 44 | 44 | global $globalDebug; |
| 45 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 45 | + if ($globalDebug) { |
|
| 46 | + echo "Update last seen tracked data...\n"; |
|
| 47 | + } |
|
| 46 | 48 | foreach ($this->all_tracked as $key => $flight) { |
| 47 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
| 48 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -55,12 +57,16 @@ discard block |
||
| 55 | 57 | public function del() { |
| 56 | 58 | global $globalDebug; |
| 57 | 59 | // Delete old infos |
| 58 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 60 | + if ($globalDebug) { |
|
| 61 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 62 | + } |
|
| 59 | 63 | foreach ($this->all_tracked as $key => $flight) { |
| 60 | 64 | if (isset($flight['lastupdate'])) { |
| 61 | 65 | if ($flight['lastupdate'] < (time()-3000)) { |
| 62 | 66 | if (isset($this->all_tracked[$key]['id'])) { |
| 63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 67 | + if ($globalDebug) { |
|
| 68 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 69 | + } |
|
| 64 | 70 | /* |
| 65 | 71 | $TrackerLive = new TrackerLive(); |
| 66 | 72 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -70,7 +76,9 @@ discard block |
||
| 70 | 76 | $Tracker = new Tracker($this->db); |
| 71 | 77 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 72 | 78 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
| 73 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 79 | + if ($globalDebug && $result != 'success') { |
|
| 80 | + echo '!!! ERROR : '.$result."\n"; |
|
| 81 | + } |
|
| 74 | 82 | } |
| 75 | 83 | // Put in archive |
| 76 | 84 | // $Tracker->db = null; |
@@ -83,7 +91,9 @@ discard block |
||
| 83 | 91 | |
| 84 | 92 | public function add($line) { |
| 85 | 93 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
| 86 | - if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
|
| 94 | + if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') { |
|
| 95 | + $globalCoordMinChangeTracker = '0.015'; |
|
| 96 | + } |
|
| 87 | 97 | date_default_timezone_set('UTC'); |
| 88 | 98 | $dataFound = false; |
| 89 | 99 | $send = false; |
@@ -97,19 +107,29 @@ discard block |
||
| 97 | 107 | // Increment message number |
| 98 | 108 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 99 | 109 | $current_date = date('Y-m-d'); |
| 100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 101 | - else $source = ''; |
|
| 102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 110 | + if (isset($line['source_name'])) { |
|
| 111 | + $source = $line['source_name']; |
|
| 112 | + } else { |
|
| 113 | + $source = ''; |
|
| 114 | + } |
|
| 115 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 116 | + $source = $line['format_source']; |
|
| 117 | + } |
|
| 103 | 118 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 104 | 119 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 105 | 120 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 121 | + } else { |
|
| 122 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 123 | + } |
|
| 107 | 124 | } |
| 108 | 125 | |
| 109 | 126 | |
| 110 | 127 | $Common = new Common(); |
| 111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 112 | - else $id = trim($line['id']); |
|
| 128 | + if (!isset($line['id'])) { |
|
| 129 | + $id = trim($line['ident']); |
|
| 130 | + } else { |
|
| 131 | + $id = trim($line['id']); |
|
| 132 | + } |
|
| 113 | 133 | |
| 114 | 134 | if (!isset($this->all_tracked[$id])) { |
| 115 | 135 | $this->all_tracked[$id] = array(); |
@@ -117,31 +137,46 @@ discard block |
||
| 117 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
| 118 | 138 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 119 | 139 | if (!isset($line['id'])) { |
| 120 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 140 | + if (!isset($globalDaemon)) { |
|
| 141 | + $globalDaemon = TRUE; |
|
| 142 | + } |
|
| 121 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 144 | + } else { |
|
| 145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 146 | + } |
|
| 147 | + if ($globalAllTracked !== FALSE) { |
|
| 148 | + $dataFound = true; |
|
| 149 | + } |
|
| 124 | 150 | } |
| 125 | 151 | |
| 126 | 152 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 127 | 153 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
| 128 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 129 | 155 | } else { |
| 130 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 131 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 156 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 157 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 158 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 159 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 160 | + } |
|
| 132 | 161 | return ''; |
| 133 | 162 | } |
| 134 | 163 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 135 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 164 | + if ($globalDebug) { |
|
| 165 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 166 | + } |
|
| 136 | 167 | return ''; |
| 137 | 168 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 138 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 169 | + if ($globalDebug) { |
|
| 170 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 171 | + } |
|
| 139 | 172 | return ''; |
| 140 | 173 | } elseif (!isset($line['datetime'])) { |
| 141 | 174 | date_default_timezone_set('UTC'); |
| 142 | 175 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 143 | 176 | } else { |
| 144 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 177 | + if ($globalDebug) { |
|
| 178 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 179 | + } |
|
| 145 | 180 | return ''; |
| 146 | 181 | } |
| 147 | 182 | |
@@ -153,11 +188,17 @@ discard block |
||
| 153 | 188 | $Tracker = new Tracker($this->db); |
| 154 | 189 | $fromsource = NULL; |
| 155 | 190 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 156 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 191 | + if ($globalDebug && $result != 'success') { |
|
| 192 | + echo '!!! ERROR : '.$result."\n"; |
|
| 193 | + } |
|
| 157 | 194 | $Tracker->db = null; |
| 158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 195 | + if ($globalDebugTimeElapsed) { |
|
| 196 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 159 | 201 | } |
| 160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 161 | 202 | } |
| 162 | 203 | |
| 163 | 204 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -168,14 +209,21 @@ discard block |
||
| 168 | 209 | if ($distance > 100 && $distance < 10000) { |
| 169 | 210 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 170 | 211 | $speed = $speed*3.6; |
| 171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 172 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 212 | + if ($speed < 1000) { |
|
| 213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 214 | + } |
|
| 215 | + if ($globalDebug) { |
|
| 216 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 217 | + } |
|
| 173 | 218 | } |
| 174 | 219 | } |
| 175 | 220 | |
| 176 | 221 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 178 | - else unset($timediff); |
|
| 222 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 223 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 224 | + } else { |
|
| 225 | + unset($timediff); |
|
| 226 | + } |
|
| 179 | 227 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 180 | 228 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 181 | 229 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) { |
@@ -183,20 +231,30 @@ discard block |
||
| 183 | 231 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 184 | 232 | $this->all_tracked[$id]['putinarchive'] = true; |
| 185 | 233 | |
| 186 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 234 | + if ($globalDebug) { |
|
| 235 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 236 | + } |
|
| 187 | 237 | $timeelapsed = microtime(true); |
| 188 | 238 | $Tracker = new Tracker($this->db); |
| 189 | 239 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 190 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 240 | + if (!empty($all_country)) { |
|
| 241 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 242 | + } |
|
| 191 | 243 | $Tracker->db = null; |
| 192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 244 | + if ($globalDebugTimeElapsed) { |
|
| 245 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 246 | + } |
|
| 193 | 247 | $this->tmd = 0; |
| 194 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 248 | + if ($globalDebug) { |
|
| 249 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 250 | + } |
|
| 195 | 251 | } |
| 196 | 252 | } |
| 197 | 253 | |
| 198 | 254 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 199 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 255 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 256 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 257 | + } |
|
| 200 | 258 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 201 | 259 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 202 | 260 | $dataFound = true; |
@@ -205,8 +263,12 @@ discard block |
||
| 205 | 263 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 206 | 264 | } |
| 207 | 265 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 209 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 266 | + if ($line['longitude'] > 180) { |
|
| 267 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 268 | + } |
|
| 269 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 270 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 271 | + } |
|
| 210 | 272 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 211 | 273 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 212 | 274 | $dataFound = true; |
@@ -226,7 +288,9 @@ discard block |
||
| 226 | 288 | } |
| 227 | 289 | } |
| 228 | 290 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 291 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 292 | + $dataFound = true; |
|
| 293 | + } |
|
| 230 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 231 | 295 | } |
| 232 | 296 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -246,7 +310,9 @@ discard block |
||
| 246 | 310 | |
| 247 | 311 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 248 | 312 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 313 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
| 314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 315 | + } |
|
| 250 | 316 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
| 251 | 317 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
| 252 | 318 | //$dataFound = true; |
@@ -258,15 +324,21 @@ discard block |
||
| 258 | 324 | } |
| 259 | 325 | |
| 260 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
| 261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 329 | + } |
|
| 262 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 263 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 264 | 332 | //$dataFound = true; |
| 265 | 333 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 266 | 334 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 267 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | + } |
|
| 339 | + if ($globalDebug) { |
|
| 340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 341 | + } |
|
| 270 | 342 | } |
| 271 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 272 | 344 | |
@@ -275,20 +347,31 @@ discard block |
||
| 275 | 347 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
| 276 | 348 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 277 | 349 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 278 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 350 | + if ($globalDebug) { |
|
| 351 | + echo "Check if aircraft is already in DB..."; |
|
| 352 | + } |
|
| 279 | 353 | $timeelapsed = microtime(true); |
| 280 | 354 | $TrackerLive = new TrackerLive($this->db); |
| 281 | 355 | if (isset($line['id'])) { |
| 282 | 356 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 357 | + if ($globalDebugTimeElapsed) { |
|
| 358 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 359 | + } |
|
| 284 | 360 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 285 | 361 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 287 | - } else $recent_ident = ''; |
|
| 362 | + if ($globalDebugTimeElapsed) { |
|
| 363 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 364 | + } |
|
| 365 | + } else { |
|
| 366 | + $recent_ident = ''; |
|
| 367 | + } |
|
| 288 | 368 | $TrackerLive->db=null; |
| 289 | 369 | |
| 290 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 291 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 370 | + if ($globalDebug && $recent_ident == '') { |
|
| 371 | + echo " Not in DB.\n"; |
|
| 372 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 373 | + echo " Already in DB.\n"; |
|
| 374 | + } |
|
| 292 | 375 | } else { |
| 293 | 376 | $recent_ident = ''; |
| 294 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -296,27 +379,41 @@ discard block |
||
| 296 | 379 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 297 | 380 | if($recent_ident == "") |
| 298 | 381 | { |
| 299 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 382 | + if ($globalDebug) { |
|
| 383 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 384 | + } |
|
| 300 | 385 | //adds the spotter data for the archive |
| 301 | 386 | $highlight = ''; |
| 302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 387 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 389 | + } |
|
| 303 | 390 | $timeelapsed = microtime(true); |
| 304 | 391 | $Tracker = new Tracker($this->db); |
| 305 | 392 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 306 | 393 | $Tracker->db = null; |
| 307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 394 | + if ($globalDebug && isset($result)) { |
|
| 395 | + echo $result."\n"; |
|
| 396 | + } |
|
| 397 | + if ($globalDebugTimeElapsed) { |
|
| 398 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 399 | + } |
|
| 309 | 400 | |
| 310 | 401 | |
| 311 | 402 | // Add source stat in DB |
| 312 | 403 | $Stats = new Stats($this->db); |
| 313 | 404 | if (!empty($this->stats)) { |
| 314 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 405 | + if ($globalDebug) { |
|
| 406 | + echo 'Add source stats : '; |
|
| 407 | + } |
|
| 315 | 408 | foreach($this->stats as $date => $data) { |
| 316 | 409 | foreach($data as $source => $sourced) { |
| 317 | 410 | //print_r($sourced); |
| 318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
| 319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
| 411 | + if (isset($sourced['polar'])) { |
|
| 412 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
| 413 | + } |
|
| 414 | + if (isset($sourced['hist'])) { |
|
| 415 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
| 416 | + } |
|
| 320 | 417 | if (isset($sourced['msg'])) { |
| 321 | 418 | if (time() - $sourced['msg']['date'] > 10) { |
| 322 | 419 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -329,7 +426,9 @@ discard block |
||
| 329 | 426 | unset($this->stats[$date]); |
| 330 | 427 | } |
| 331 | 428 | } |
| 332 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 429 | + if ($globalDebug) { |
|
| 430 | + echo 'Done'."\n"; |
|
| 431 | + } |
|
| 333 | 432 | |
| 334 | 433 | } |
| 335 | 434 | $Stats->db = null; |
@@ -339,12 +438,16 @@ discard block |
||
| 339 | 438 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 340 | 439 | //print_r($this->all_tracked[$id]); |
| 341 | 440 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 441 | + if ($globalDebug) { |
|
| 442 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 443 | + } |
|
| 343 | 444 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 344 | 445 | $TrackerLive = new TrackerLive($this->db); |
| 345 | 446 | $TrackerLive->deleteLiveTrackerData(); |
| 346 | 447 | $TrackerLive->db=null; |
| 347 | - if ($globalDebug) echo " Done\n"; |
|
| 448 | + if ($globalDebug) { |
|
| 449 | + echo " Done\n"; |
|
| 450 | + } |
|
| 348 | 451 | $this->last_delete = time(); |
| 349 | 452 | } |
| 350 | 453 | } else { |
@@ -367,19 +470,25 @@ discard block |
||
| 367 | 470 | |
| 368 | 471 | if (!$ignoreImport) { |
| 369 | 472 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 370 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 473 | + if ($globalDebug) { |
|
| 474 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 475 | + } |
|
| 371 | 476 | $timeelapsed = microtime(true); |
| 372 | 477 | $TrackerLive = new TrackerLive($this->db); |
| 373 | 478 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 374 | 479 | $TrackerLive->db = null; |
| 375 | 480 | $this->all_tracked[$id]['putinarchive'] = false; |
| 376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 481 | + if ($globalDebugTimeElapsed) { |
|
| 482 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 483 | + } |
|
| 377 | 484 | |
| 378 | 485 | // Put statistics in $this->stats variable |
| 379 | 486 | |
| 380 | 487 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 381 | 488 | $source = $this->all_tracked[$id]['source_name']; |
| 382 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 489 | + if ($source == '') { |
|
| 490 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 491 | + } |
|
| 383 | 492 | if (!isset($this->source_location[$source])) { |
| 384 | 493 | $Location = new Source($this->db); |
| 385 | 494 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -400,7 +509,9 @@ discard block |
||
| 400 | 509 | $stats_heading = round($stats_heading/22.5); |
| 401 | 510 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 402 | 511 | $current_date = date('Y-m-d'); |
| 403 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 512 | + if ($stats_heading == 16) { |
|
| 513 | + $stats_heading = 0; |
|
| 514 | + } |
|
| 404 | 515 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 405 | 516 | for ($i=0;$i<=15;$i++) { |
| 406 | 517 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -418,7 +529,9 @@ discard block |
||
| 418 | 529 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 419 | 530 | end($this->stats[$current_date][$source]['hist']); |
| 420 | 531 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 421 | - } else $mini = 0; |
|
| 532 | + } else { |
|
| 533 | + $mini = 0; |
|
| 534 | + } |
|
| 422 | 535 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 423 | 536 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 424 | 537 | } |
@@ -429,19 +542,29 @@ discard block |
||
| 429 | 542 | } |
| 430 | 543 | |
| 431 | 544 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 433 | - if ($globalDebug) echo $result."\n"; |
|
| 434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 545 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 546 | + $send = true; |
|
| 547 | + } |
|
| 548 | + if ($globalDebug) { |
|
| 549 | + echo $result."\n"; |
|
| 550 | + } |
|
| 551 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 552 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 553 | + } |
|
| 435 | 554 | //$this->del(); |
| 436 | 555 | |
| 437 | 556 | |
| 438 | 557 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 558 | + if ($globalDebug) { |
|
| 559 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 560 | + } |
|
| 440 | 561 | $TrackerLive = new TrackerLive($this->db); |
| 441 | 562 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 442 | 563 | $TrackerLive->db = null; |
| 443 | 564 | //TrackerLive->deleteLiveTrackerData(); |
| 444 | - if ($globalDebug) echo " Done\n"; |
|
| 565 | + if ($globalDebug) { |
|
| 566 | + echo " Done\n"; |
|
| 567 | + } |
|
| 445 | 568 | $this->last_delete_hourly = time(); |
| 446 | 569 | } |
| 447 | 570 | |
@@ -449,7 +572,9 @@ discard block |
||
| 449 | 572 | //$ignoreImport = false; |
| 450 | 573 | } |
| 451 | 574 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 452 | - if ($send) return $this->all_tracked[$id]; |
|
| 575 | + if ($send) { |
|
| 576 | + return $this->all_tracked[$id]; |
|
| 577 | + } |
|
| 453 | 578 | } |
| 454 | 579 | } |
| 455 | 580 | } |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | public function __construct($dbc = null) { |
| 7 | 7 | $Connection = new Connection($dbc); |
| 8 | 8 | $this->db = $Connection->db; |
| 9 | - if ($this->db === null) die('Error: No DB connection. (TrackerArchive)'); |
|
| 9 | + if ($this->db === null) { |
|
| 10 | + die('Error: No DB connection. (TrackerArchive)'); |
|
| 11 | + } |
|
| 10 | 12 | } |
| 11 | 13 | |
| 12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
| 27 | 29 | if (isset($filter[0]['source'])) { |
| 28 | 30 | $filters = array_merge($filters,$filter); |
| 29 | 31 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 31 | 35 | $filter_query_join = ''; |
| 32 | 36 | $filter_query_where = ''; |
| 33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
| 73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 75 | 79 | } |
| 76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 80 | + if ($filter_query_where == '' && $where) { |
|
| 81 | + $filter_query_where = ' WHERE'; |
|
| 82 | + } elseif ($filter_query_where != '' && $and) { |
|
| 83 | + $filter_query_where .= ' AND'; |
|
| 84 | + } |
|
| 78 | 85 | if ($filter_query_where != '') { |
| 79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
| 88 | 95 | if ($over_country == '') { |
| 89 | 96 | $Tracker = new Tracker($this->db); |
| 90 | 97 | $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 92 | - else $country = ''; |
|
| 93 | - } else $country = $over_country; |
|
| 98 | + if (!empty($data_country)) { |
|
| 99 | + $country = $data_country['iso2']; |
|
| 100 | + } else { |
|
| 101 | + $country = ''; |
|
| 102 | + } |
|
| 103 | + } else { |
|
| 104 | + $country = $over_country; |
|
| 105 | + } |
|
| 94 | 106 | // Route is not added in tracker_archive |
| 95 | 107 | $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 96 | 108 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -168,8 +180,11 @@ discard block |
||
| 168 | 180 | { |
| 169 | 181 | date_default_timezone_set('UTC'); |
| 170 | 182 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 171 | - if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 172 | - else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 183 | + if ($date == '') { |
|
| 184 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 185 | + } else { |
|
| 186 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 187 | + } |
|
| 173 | 188 | |
| 174 | 189 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 175 | 190 | |
@@ -593,7 +608,9 @@ discard block |
||
| 593 | 608 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 594 | 609 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
| 595 | 610 | $translate = $Translation->ident2icao($q_item); |
| 596 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 611 | + if ($translate != $q_item) { |
|
| 612 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 613 | + } |
|
| 597 | 614 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
| 598 | 615 | $additional_query .= ")"; |
| 599 | 616 | } |
@@ -811,7 +828,9 @@ discard block |
||
| 811 | 828 | date_default_timezone_set($globalTimezone); |
| 812 | 829 | $datetime = new DateTime(); |
| 813 | 830 | $offset = $datetime->format('P'); |
| 814 | - } else $offset = '+00:00'; |
|
| 831 | + } else { |
|
| 832 | + $offset = '+00:00'; |
|
| 833 | + } |
|
| 815 | 834 | |
| 816 | 835 | |
| 817 | 836 | if ($date_array[1] != "") |
@@ -1087,9 +1106,13 @@ discard block |
||
| 1087 | 1106 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1088 | 1107 | } |
| 1089 | 1108 | } |
| 1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1109 | + if ($sincedate != '') { |
|
| 1110 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1111 | + } |
|
| 1091 | 1112 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1092 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1113 | + if ($limit) { |
|
| 1114 | + $query .= " LIMIT 0,10"; |
|
| 1115 | + } |
|
| 1093 | 1116 | |
| 1094 | 1117 | |
| 1095 | 1118 | $sth = $this->db->prepare($query); |
@@ -1133,9 +1156,13 @@ discard block |
||
| 1133 | 1156 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1134 | 1157 | } |
| 1135 | 1158 | } |
| 1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1159 | + if ($sincedate != '') { |
|
| 1160 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1161 | + } |
|
| 1137 | 1162 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1138 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1163 | + if ($limit) { |
|
| 1164 | + $query .= " LIMIT 0,10"; |
|
| 1165 | + } |
|
| 1139 | 1166 | |
| 1140 | 1167 | |
| 1141 | 1168 | $sth = $this->db->prepare($query); |
@@ -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. (TrackerLive)'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection. (TrackerLive)'); |
|
| 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) { |
@@ -77,8 +81,11 @@ discard block |
||
| 77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 79 | 83 | } |
| 80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 84 | + if ($filter_query_where == '' && $where) { |
|
| 85 | + $filter_query_where = ' WHERE'; |
|
| 86 | + } elseif ($filter_query_where != '' && $and) { |
|
| 87 | + $filter_query_where .= ' AND'; |
|
| 88 | + } |
|
| 82 | 89 | if ($filter_query_where != '') { |
| 83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 84 | 91 | } |
@@ -120,7 +127,9 @@ discard block |
||
| 120 | 127 | } |
| 121 | 128 | } |
| 122 | 129 | |
| 123 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 130 | + if (!isset($globalLiveInterval)) { |
|
| 131 | + $globalLiveInterval = '200'; |
|
| 132 | + } |
|
| 124 | 133 | if ($globalDBdriver == 'mysql') { |
| 125 | 134 | //$query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate"; |
| 126 | 135 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -145,7 +154,9 @@ discard block |
||
| 145 | 154 | |
| 146 | 155 | $filter_query = $this->getFilter($filter,true,true); |
| 147 | 156 | |
| 148 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 157 | + if (!isset($globalLiveInterval)) { |
|
| 158 | + $globalLiveInterval = '200'; |
|
| 159 | + } |
|
| 149 | 160 | if ($globalDBdriver == 'mysql') { |
| 150 | 161 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 151 | 162 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0"; |
@@ -190,50 +201,74 @@ discard block |
||
| 190 | 201 | } |
| 191 | 202 | $filter_query = $this->getFilter($filter,true,true); |
| 192 | 203 | |
| 193 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 194 | - if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300'; |
|
| 204 | + if (!isset($globalLiveInterval)) { |
|
| 205 | + $globalLiveInterval = '200'; |
|
| 206 | + } |
|
| 207 | + if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') { |
|
| 208 | + $globalMap3DTrackersLimit = '300'; |
|
| 209 | + } |
|
| 195 | 210 | if ($globalDBdriver == 'mysql') { |
| 196 | 211 | if (isset($globalArchive) && $globalArchive) { |
| 197 | 212 | $query = "SELECT * FROM ( |
| 198 | 213 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 199 | 214 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 200 | - if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 215 | + if ($usecoord) { |
|
| 216 | + $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 217 | + } |
|
| 201 | 218 | $query .= "UNION |
| 202 | 219 | SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 203 | 220 | FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date "; |
| 204 | - if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 221 | + if ($usecoord) { |
|
| 222 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 223 | + } |
|
| 205 | 224 | $query .= ") AS tracker |
| 206 | 225 | WHERE latitude <> '0' AND longitude <> '0' |
| 207 | 226 | ORDER BY famtrackid, date"; |
| 208 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 227 | + if ($limit) { |
|
| 228 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 229 | + } |
|
| 209 | 230 | } else { |
| 210 | 231 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 211 | 232 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date "; |
| 212 | - if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 233 | + if ($usecoord) { |
|
| 234 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 235 | + } |
|
| 213 | 236 | $query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
| 214 | 237 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 215 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 238 | + if ($limit) { |
|
| 239 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 240 | + } |
|
| 216 | 241 | } |
| 217 | 242 | } else { |
| 218 | 243 | if (isset($globalArchive) && $globalArchive) { |
| 219 | 244 | $query = "SELECT * FROM ( |
| 220 | 245 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 221 | 246 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 222 | - if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 247 | + if ($usecoord) { |
|
| 248 | + $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 249 | + } |
|
| 223 | 250 | $query .= "UNION |
| 224 | 251 | SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 225 | 252 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date"; |
| 226 | - if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 253 | + if ($usecoord) { |
|
| 254 | + $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 255 | + } |
|
| 227 | 256 | $query .= ") AS tracker |
| 228 | 257 | WHERE latitude <> '0' AND longitude <> '0' |
| 229 | 258 | ORDER BY famtrackid, date"; |
| 230 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 259 | + if ($limit) { |
|
| 260 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 261 | + } |
|
| 231 | 262 | } else { |
| 232 | 263 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 233 | 264 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' "; |
| 234 | - if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 265 | + if ($usecoord) { |
|
| 266 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 267 | + } |
|
| 235 | 268 | $query .= "ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 236 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 269 | + if ($limit) { |
|
| 270 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
| 271 | + } |
|
| 237 | 272 | } |
| 238 | 273 | } |
| 239 | 274 | |
@@ -259,7 +294,9 @@ discard block |
||
| 259 | 294 | global $globalDBdriver, $globalLiveInterval; |
| 260 | 295 | $filter_query = $this->getFilter($filter,true,true); |
| 261 | 296 | |
| 262 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 297 | + if (!isset($globalLiveInterval)) { |
|
| 298 | + $globalLiveInterval = '200'; |
|
| 299 | + } |
|
| 263 | 300 | if ($globalDBdriver == 'mysql') { |
| 264 | 301 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 265 | 302 | } else { |
@@ -287,7 +324,9 @@ discard block |
||
| 287 | 324 | { |
| 288 | 325 | global $globalDBdriver, $globalLiveInterval; |
| 289 | 326 | $Tracker = new Tracker($this->db); |
| 290 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 327 | + if (!isset($globalLiveInterval)) { |
|
| 328 | + $globalLiveInterval = '200'; |
|
| 329 | + } |
|
| 291 | 330 | $filter_query = $this->getFilter($filter); |
| 292 | 331 | |
| 293 | 332 | if (is_array($coord)) { |
@@ -295,7 +334,9 @@ discard block |
||
| 295 | 334 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 296 | 335 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 297 | 336 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 298 | - } else return array(); |
|
| 337 | + } else { |
|
| 338 | + return array(); |
|
| 339 | + } |
|
| 299 | 340 | if ($globalDBdriver == 'mysql') { |
| 300 | 341 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
| 301 | 342 | } else { |
@@ -315,7 +356,9 @@ discard block |
||
| 315 | 356 | { |
| 316 | 357 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 317 | 358 | $Tracker = new Tracker($this->db); |
| 318 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 359 | + if (!isset($globalLiveInterval)) { |
|
| 360 | + $globalLiveInterval = '200'; |
|
| 361 | + } |
|
| 319 | 362 | $filter_query = $this->getFilter($filter,true,true); |
| 320 | 363 | |
| 321 | 364 | if (is_array($coord)) { |
@@ -323,7 +366,9 @@ discard block |
||
| 323 | 366 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 324 | 367 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 325 | 368 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 326 | - } else return array(); |
|
| 369 | + } else { |
|
| 370 | + return array(); |
|
| 371 | + } |
|
| 327 | 372 | /* |
| 328 | 373 | if ($globalDBdriver == 'mysql') { |
| 329 | 374 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
@@ -557,13 +602,19 @@ discard block |
||
| 557 | 602 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date'; |
| 558 | 603 | if ($globalDBdriver == 'mysql') { |
| 559 | 604 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 560 | - if ($liveinterval === true) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 561 | - elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'"; |
|
| 605 | + if ($liveinterval === true) { |
|
| 606 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 607 | + } elseif ($liveinterval !== false) { |
|
| 608 | + $query .= " AND date <= '".date('c',$liveinterval)."'"; |
|
| 609 | + } |
|
| 562 | 610 | $query .= ' ORDER BY date'; |
| 563 | 611 | } else { |
| 564 | 612 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 565 | - if ($liveinterval === true) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 566 | - elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'"; |
|
| 613 | + if ($liveinterval === true) { |
|
| 614 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 615 | + } elseif ($liveinterval !== false) { |
|
| 616 | + $query .= " AND date <= '".date('c',$liveinterval)."'"; |
|
| 617 | + } |
|
| 567 | 618 | $query .= ' ORDER BY date'; |
| 568 | 619 | } |
| 569 | 620 | |
@@ -658,7 +709,9 @@ discard block |
||
| 658 | 709 | $i++; |
| 659 | 710 | $j++; |
| 660 | 711 | if ($j == 30) { |
| 661 | - if ($globalDebug) echo "."; |
|
| 712 | + if ($globalDebug) { |
|
| 713 | + echo "."; |
|
| 714 | + } |
|
| 662 | 715 | try { |
| 663 | 716 | |
| 664 | 717 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -905,7 +958,9 @@ discard block |
||
| 905 | 958 | { |
| 906 | 959 | return false; |
| 907 | 960 | } |
| 908 | - } else return ''; |
|
| 961 | + } else { |
|
| 962 | + return ''; |
|
| 963 | + } |
|
| 909 | 964 | |
| 910 | 965 | if ($longitude != '') |
| 911 | 966 | { |
@@ -913,7 +968,9 @@ discard block |
||
| 913 | 968 | { |
| 914 | 969 | return false; |
| 915 | 970 | } |
| 916 | - } else return ''; |
|
| 971 | + } else { |
|
| 972 | + return ''; |
|
| 973 | + } |
|
| 917 | 974 | |
| 918 | 975 | if ($altitude != '') |
| 919 | 976 | { |
@@ -921,7 +978,9 @@ discard block |
||
| 921 | 978 | { |
| 922 | 979 | return false; |
| 923 | 980 | } |
| 924 | - } else $altitude = 0; |
|
| 981 | + } else { |
|
| 982 | + $altitude = 0; |
|
| 983 | + } |
|
| 925 | 984 | |
| 926 | 985 | if ($heading != '') |
| 927 | 986 | { |
@@ -929,7 +988,9 @@ discard block |
||
| 929 | 988 | { |
| 930 | 989 | return false; |
| 931 | 990 | } |
| 932 | - } else $heading = 0; |
|
| 991 | + } else { |
|
| 992 | + $heading = 0; |
|
| 993 | + } |
|
| 933 | 994 | |
| 934 | 995 | if ($groundspeed != '') |
| 935 | 996 | { |
@@ -937,9 +998,13 @@ discard block |
||
| 937 | 998 | { |
| 938 | 999 | return false; |
| 939 | 1000 | } |
| 940 | - } else $groundspeed = 0; |
|
| 1001 | + } else { |
|
| 1002 | + $groundspeed = 0; |
|
| 1003 | + } |
|
| 941 | 1004 | date_default_timezone_set('UTC'); |
| 942 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1005 | + if ($date == '') { |
|
| 1006 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1007 | + } |
|
| 943 | 1008 | |
| 944 | 1009 | |
| 945 | 1010 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -955,12 +1020,18 @@ discard block |
||
| 955 | 1020 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 956 | 1021 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 957 | 1022 | |
| 958 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 959 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1023 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1024 | + $groundspeed = 0; |
|
| 1025 | + } |
|
| 1026 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1027 | + $heading = 0; |
|
| 1028 | + } |
|
| 960 | 1029 | |
| 961 | 1030 | $query = ''; |
| 962 | 1031 | if ($globalArchive) { |
| 963 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1032 | + if ($globalDebug) { |
|
| 1033 | + echo '-- Delete previous data -- '; |
|
| 1034 | + } |
|
| 964 | 1035 | $query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;'; |
| 965 | 1036 | } |
| 966 | 1037 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
@@ -979,10 +1050,14 @@ discard block |
||
| 979 | 1050 | echo 'noarchive : '.$noarchive."\n"; |
| 980 | 1051 | */ |
| 981 | 1052 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 982 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 1053 | + if ($globalDebug) { |
|
| 1054 | + echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 1055 | + } |
|
| 983 | 1056 | $TrackerArchive = new TrackerArchive($this->db); |
| 984 | 1057 | $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
| 985 | - if ($globalDebug) echo $result.')'; |
|
| 1058 | + if ($globalDebug) { |
|
| 1059 | + echo $result.')'; |
|
| 1060 | + } |
|
| 986 | 1061 | } |
| 987 | 1062 | |
| 988 | 1063 | return "success"; |
@@ -46,7 +46,9 @@ discard block |
||
| 46 | 46 | $gpx .= '<trkseg>'; |
| 47 | 47 | foreach($spotter_history_array as $spotter_data) { |
| 48 | 48 | $gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">'; |
| 49 | - if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>'; |
|
| 49 | + if (isset($spotter_data['altitude'])) { |
|
| 50 | + $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>'; |
|
| 51 | + } |
|
| 50 | 52 | $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>'; |
| 51 | 53 | $gpx .= '</trkpt>'; |
| 52 | 54 | } |
@@ -82,9 +84,15 @@ discard block |
||
| 82 | 84 | |
| 83 | 85 | public function TrackMatching($spotter_history_array) { |
| 84 | 86 | global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId; |
| 85 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 86 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 87 | - if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
| 87 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 88 | + $globalMapMatchingMaxPts = 100; |
|
| 89 | + } |
|
| 90 | + if (count($spotter_history_array) < 2) { |
|
| 91 | + return $spotter_history_array; |
|
| 92 | + } |
|
| 93 | + if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
|
| 94 | + $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
| 95 | + } |
|
| 88 | 96 | $data = $this->create_gpx($spotter_history_array); |
| 89 | 97 | $url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true'; |
| 90 | 98 | $Common = new Common(); |
@@ -111,8 +119,12 @@ discard block |
||
| 111 | 119 | */ |
| 112 | 120 | public function GraphHopper($spotter_history_array) { |
| 113 | 121 | global $globalMapMatchingMaxPts, $globalGraphHopperKey; |
| 114 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 115 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 122 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 123 | + $globalMapMatchingMaxPts = 100; |
|
| 124 | + } |
|
| 125 | + if (count($spotter_history_array) < 2) { |
|
| 126 | + return $spotter_history_array; |
|
| 127 | + } |
|
| 116 | 128 | $spotter_history_initial_array = array(); |
| 117 | 129 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 118 | 130 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -142,8 +154,12 @@ discard block |
||
| 142 | 154 | */ |
| 143 | 155 | public function FAMMapMatching($spotter_history_array) { |
| 144 | 156 | global $globalMapMatchingMaxPts, $globalGraphHopperKey; |
| 145 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
|
| 146 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 157 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 158 | + $globalMapMatchingMaxPts = 100; |
|
| 159 | + } |
|
| 160 | + if (count($spotter_history_array) < 2) { |
|
| 161 | + return $spotter_history_array; |
|
| 162 | + } |
|
| 147 | 163 | $spotter_history_initial_array = array(); |
| 148 | 164 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 149 | 165 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -174,8 +190,12 @@ discard block |
||
| 174 | 190 | */ |
| 175 | 191 | public function osmr($spotter_history_array) { |
| 176 | 192 | global $globalMapMatchingMaxPts; |
| 177 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50; |
|
| 178 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 193 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 194 | + $globalMapMatchingMaxPts = 50; |
|
| 195 | + } |
|
| 196 | + if (count($spotter_history_array) < 2) { |
|
| 197 | + return $spotter_history_array; |
|
| 198 | + } |
|
| 179 | 199 | $spotter_history_initial_array = array(); |
| 180 | 200 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 181 | 201 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -185,11 +205,17 @@ discard block |
||
| 185 | 205 | $ts = ''; |
| 186 | 206 | $rd = ''; |
| 187 | 207 | foreach ($spotter_history_array as $spotter_data) { |
| 188 | - if ($coord != '') $coord .= ';'; |
|
| 208 | + if ($coord != '') { |
|
| 209 | + $coord .= ';'; |
|
| 210 | + } |
|
| 189 | 211 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
| 190 | - if ($ts != '') $ts .= ';'; |
|
| 212 | + if ($ts != '') { |
|
| 213 | + $ts .= ';'; |
|
| 214 | + } |
|
| 191 | 215 | $ts .= strtotime($spotter_data['date']); |
| 192 | - if ($rd != '') $rd .= ';'; |
|
| 216 | + if ($rd != '') { |
|
| 217 | + $rd .= ';'; |
|
| 218 | + } |
|
| 193 | 219 | $rd .= '20'; |
| 194 | 220 | } |
| 195 | 221 | $url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore'; |
@@ -215,8 +241,12 @@ discard block |
||
| 215 | 241 | */ |
| 216 | 242 | public function mapbox($spotter_history_array) { |
| 217 | 243 | global $globalMapMatchingMaxPts, $globalMapboxToken; |
| 218 | - if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60; |
|
| 219 | - if (count($spotter_history_array) < 2) return $spotter_history_array; |
|
| 244 | + if (!isset($globalMapMatchingMaxPts)) { |
|
| 245 | + $globalMapMatchingMaxPts = 60; |
|
| 246 | + } |
|
| 247 | + if (count($spotter_history_array) < 2) { |
|
| 248 | + return $spotter_history_array; |
|
| 249 | + } |
|
| 220 | 250 | $spotter_history_initial_array = array(); |
| 221 | 251 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
| 222 | 252 | $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
@@ -226,11 +256,17 @@ discard block |
||
| 226 | 256 | $ts = ''; |
| 227 | 257 | $rd = ''; |
| 228 | 258 | foreach ($spotter_history_array as $spotter_data) { |
| 229 | - if ($coord != '') $coord .= ';'; |
|
| 259 | + if ($coord != '') { |
|
| 260 | + $coord .= ';'; |
|
| 261 | + } |
|
| 230 | 262 | $coord .= $spotter_data['longitude'].','.$spotter_data['latitude']; |
| 231 | - if ($ts != '') $ts .= ';'; |
|
| 263 | + if ($ts != '') { |
|
| 264 | + $ts .= ';'; |
|
| 265 | + } |
|
| 232 | 266 | $ts .= strtotime($spotter_data['date']); |
| 233 | - if ($rd != '') $rd .= ';'; |
|
| 267 | + if ($rd != '') { |
|
| 268 | + $rd .= ';'; |
|
| 269 | + } |
|
| 234 | 270 | $rd .= '20'; |
| 235 | 271 | } |
| 236 | 272 | //$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'×tamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd; |
@@ -5,21 +5,30 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | document.cookie = 'MapFormat=3d; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' |
| 7 | 7 | <?php |
| 8 | - if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType']; |
|
| 9 | - else $MapType = $globalMapProvider; |
|
| 8 | + if (isset($_COOKIE['MapType'])) { |
|
| 9 | + $MapType = $_COOKIE['MapType']; |
|
| 10 | + } else { |
|
| 11 | + $MapType = $globalMapProvider; |
|
| 12 | + } |
|
| 10 | 13 | |
| 11 | 14 | // unset($_COOKIE['MapType']); |
| 12 | 15 | if ($MapType != 'Mapbox' && $MapType != 'OpenStreetMap' && $MapType != 'Bing-Aerial' && $MapType != 'Bing-Hybrid' && $MapType != 'Bing-Road' && $MapType != 'offline' && $MapType != 'ArcGIS-Streetmap' && $MapType != 'ArcGIS-Satellite' && $MapType != 'NatGeo-Street') { |
| 13 | - if (isset($globalBingMapKey) && $globalBingMapKey != '') $MapType = 'Bing-Aerial'; |
|
| 14 | - else $MapType = 'OpenStreetMap'; |
|
| 16 | + if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
|
| 17 | + $MapType = 'Bing-Aerial'; |
|
| 18 | + } else { |
|
| 19 | + $MapType = 'OpenStreetMap'; |
|
| 20 | + } |
|
| 15 | 21 | } |
| 16 | 22 | if (($MapType == 'Bing-Aerial' || $MapType == 'Bing-Hybrid' || $MapType == 'Bing-Road') && (!isset($globalBingMapKey) || $globalBingMapKey == '')) { |
| 17 | 23 | $MapType = 'OpenStreetMap'; |
| 18 | 24 | } |
| 19 | 25 | if ($MapType == 'Mapbox') { |
| 20 | - if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId; |
|
| 21 | - else $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 22 | -?> |
|
| 26 | + if ($_COOKIE['MapTypeId'] == 'default') { |
|
| 27 | + $MapBoxId = $globalMapboxId; |
|
| 28 | + } else { |
|
| 29 | + $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 30 | + } |
|
| 31 | + ?> |
|
| 23 | 32 | var imProv = Cesium.MapboxImageryProvider({ |
| 24 | 33 | credit: 'Map data © OpenStreetMap contributors, ' + |
| 25 | 34 | 'CC-BY-SA, ' + |
@@ -147,13 +156,23 @@ discard block |
||
| 147 | 156 | */ |
| 148 | 157 | ?> |
| 149 | 158 | <?php |
| 150 | - } elseif (isset($globalMapCustomLayer[$MapType])) { |
|
| 159 | + } elseif (isset($globalMapCustomLayer[$MapType])) { |
|
| 151 | 160 | $customid = $MapType; |
| 152 | 161 | ?> |
| 153 | 162 | var imProv = Cesium.createOpenStreetMapImageryProvider({ |
| 154 | 163 | url : '<?php print $globalMapCustomLayer[$customid]['url']; ?>', |
| 155 | - maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '99'; ?>, |
|
| 156 | - minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>, |
|
| 164 | + maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) { |
|
| 165 | + print $globalMapCustomLayer[$customid]['maxZoom']; |
|
| 166 | +} else { |
|
| 167 | + print '99'; |
|
| 168 | +} |
|
| 169 | +?>, |
|
| 170 | + minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) { |
|
| 171 | + print $globalMapCustomLayer[$customid]['minZoom']; |
|
| 172 | +} else { |
|
| 173 | + print '0'; |
|
| 174 | +} |
|
| 175 | +?>, |
|
| 157 | 176 | credit: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>' |
| 158 | 177 | }); |
| 159 | 178 | <?php |
@@ -480,8 +499,11 @@ discard block |
||
| 480 | 499 | if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) { |
| 481 | 500 | if (isset($_COOKIE['lastcentercoord'])) { |
| 482 | 501 | $lastcentercoord = explode(',',$_COOKIE['lastcentercoord']); |
| 483 | - if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0; |
|
| 484 | - else $zoom = $lastcentercoord[3]; |
|
| 502 | + if (!isset($lastcentercoord[3])) { |
|
| 503 | + $zoom = $lastcentercoord[2]*1000000.0; |
|
| 504 | + } else { |
|
| 505 | + $zoom = $lastcentercoord[3]; |
|
| 506 | + } |
|
| 485 | 507 | $viewcenterlatitude = $lastcentercoord[0]; |
| 486 | 508 | $viewcenterlongitude = $lastcentercoord[1]; |
| 487 | 509 | } else { |
@@ -602,7 +624,12 @@ discard block |
||
| 602 | 624 | ?> |
| 603 | 625 | |
| 604 | 626 | update_locationsLayer(); |
| 605 | -setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 627 | +setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 628 | + print $globalMapRefresh*1000*2; |
|
| 629 | +} else { |
|
| 630 | + print '60000'; |
|
| 631 | +} |
|
| 632 | +?>); |
|
| 606 | 633 | /* |
| 607 | 634 | var handlera = new Cesium.ScreenSpaceEventHandler(viewer.canvas, false); |
| 608 | 635 | handlera.setInputAction( |
@@ -7,7 +7,9 @@ discard block |
||
| 7 | 7 | $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop'); |
| 8 | 8 | $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
| 9 | 9 | |
| 10 | -if (!isset($type)) $type = 'aircraft'; |
|
| 10 | +if (!isset($type)) { |
|
| 11 | + $type = 'aircraft'; |
|
| 12 | +} |
|
| 11 | 13 | |
| 12 | 14 | if (!isset($_GET['sort'])) |
| 13 | 15 | { |
@@ -492,7 +494,9 @@ discard block |
||
| 492 | 494 | if (isset($globalTimezone)) |
| 493 | 495 | { |
| 494 | 496 | date_default_timezone_set($globalTimezone); |
| 495 | - } else date_default_timezone_set('UTC'); |
|
| 497 | + } else { |
|
| 498 | + date_default_timezone_set('UTC'); |
|
| 499 | + } |
|
| 496 | 500 | if ($showSpecial === true) |
| 497 | 501 | { |
| 498 | 502 | print '<tr class="special">'."\n"; |
@@ -507,7 +511,9 @@ discard block |
||
| 507 | 511 | print '<tr class="active">'; |
| 508 | 512 | } elseif (isset($spotter_item['spotted_registration'])) { |
| 509 | 513 | print '<tr class="info">'; |
| 510 | - } else print '<tr>'; |
|
| 514 | + } else { |
|
| 515 | + print '<tr>'; |
|
| 516 | + } |
|
| 511 | 517 | } |
| 512 | 518 | if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") { |
| 513 | 519 | if ($type == 'aircraft') { |
@@ -515,8 +521,9 @@ discard block |
||
| 515 | 521 | { |
| 516 | 522 | print '<td class="aircraft_thumbnail">'."\n"; |
| 517 | 523 | if ($spotter_item['image_source'] == 'planespotters') { |
| 518 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
| 519 | - else { |
|
| 524 | + if ($spotter_item['image_source_website'] != '') { |
|
| 525 | + $image_src = $spotter_item['image_source_website']; |
|
| 526 | + } else { |
|
| 520 | 527 | $planespotter_url_array = explode("_", $spotter_item['image']); |
| 521 | 528 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
| 522 | 529 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -529,7 +536,9 @@ discard block |
||
| 529 | 536 | } else { |
| 530 | 537 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 531 | 538 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 532 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 539 | + } else { |
|
| 540 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 541 | + } |
|
| 533 | 542 | if (isset($spotter_item['airline_name'])) { |
| 534 | 543 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 535 | 544 | } else { |
@@ -548,7 +557,9 @@ discard block |
||
| 548 | 557 | print '<td class="aircraft_thumbnail">'."\n"; |
| 549 | 558 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 550 | 559 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 551 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 560 | + } else { |
|
| 561 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 562 | + } |
|
| 552 | 563 | if (isset($spotter_item['airline_name'])) { |
| 553 | 564 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 554 | 565 | } else { |
@@ -566,7 +577,9 @@ discard block |
||
| 566 | 577 | print '<td class="aircraft_thumbnail">'."\n"; |
| 567 | 578 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 568 | 579 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 569 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 580 | + } else { |
|
| 581 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 582 | + } |
|
| 570 | 583 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 571 | 584 | print '</td>'."\n"; |
| 572 | 585 | } else { |
@@ -619,8 +632,9 @@ discard block |
||
| 619 | 632 | print '<td class="aircraft_thumbnail">'."\n"; |
| 620 | 633 | //print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
| 621 | 634 | if ($spotter_item['image_source'] == 'planespotters') { |
| 622 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
| 623 | - else { |
|
| 635 | + if ($spotter_item['image_source_website'] != '') { |
|
| 636 | + $image_src = $spotter_item['image_source_website']; |
|
| 637 | + } else { |
|
| 624 | 638 | $planespotter_url_array = explode("_", $spotter_array[0]['image']); |
| 625 | 639 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
| 626 | 640 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -637,7 +651,9 @@ discard block |
||
| 637 | 651 | } else { |
| 638 | 652 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 639 | 653 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 640 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 654 | + } else { |
|
| 655 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 656 | + } |
|
| 641 | 657 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
| 642 | 658 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 643 | 659 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
@@ -670,7 +686,9 @@ discard block |
||
| 670 | 686 | print '<td class="aircraft_thumbnail">'."\n"; |
| 671 | 687 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 672 | 688 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 673 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 689 | + } else { |
|
| 690 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 691 | + } |
|
| 674 | 692 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 675 | 693 | print '</td>'."\n"; |
| 676 | 694 | } else { |
@@ -684,7 +702,9 @@ discard block |
||
| 684 | 702 | print '<td class="aircraft_thumbnail">'."\n"; |
| 685 | 703 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 686 | 704 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 687 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 705 | + } else { |
|
| 706 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 707 | + } |
|
| 688 | 708 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 689 | 709 | print '</td>'."\n"; |
| 690 | 710 | } else { |
@@ -802,8 +822,11 @@ discard block |
||
| 802 | 822 | print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
| 803 | 823 | } else { |
| 804 | 824 | $aircraft_names = explode('/',$spotter_item['aircraft_name']); |
| 805 | - if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
|
| 806 | - else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
|
| 825 | + if (count($aircraft_names) == 1) { |
|
| 826 | + print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
|
| 827 | + } else { |
|
| 828 | + print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
|
| 829 | + } |
|
| 807 | 830 | } |
| 808 | 831 | print '<span class="mobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
| 809 | 832 | } elseif ($type == 'marine') { |
@@ -846,15 +869,21 @@ discard block |
||
| 846 | 869 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
| 847 | 870 | if ($spotter_item['departure_airport_time'] > 2460) { |
| 848 | 871 | $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
| 849 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
| 872 | + } else { |
|
| 873 | + $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
| 874 | + } |
|
| 850 | 875 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
| 851 | 876 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
| 852 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 877 | + } else { |
|
| 878 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 879 | + } |
|
| 853 | 880 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
| 854 | 881 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
| 855 | 882 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
| 856 | 883 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
| 857 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 884 | + } else { |
|
| 885 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 886 | + } |
|
| 858 | 887 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
| 859 | 888 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
| 860 | 889 | if ($spotter_item['departure_airport_time'] > 2460) { |
@@ -876,7 +905,9 @@ discard block |
||
| 876 | 905 | $longitude = $spotter_item['longitude']; |
| 877 | 906 | } |
| 878 | 907 | $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
| 879 | - } else $distance = ''; |
|
| 908 | + } else { |
|
| 909 | + $distance = ''; |
|
| 910 | + } |
|
| 880 | 911 | if ($distance != '') { |
| 881 | 912 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
| 882 | 913 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -903,7 +934,9 @@ discard block |
||
| 903 | 934 | } else { |
| 904 | 935 | if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) { |
| 905 | 936 | print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n"; |
| 906 | - if (!isset($Spotter)) $Spotter = new Spotter(); |
|
| 937 | + if (!isset($Spotter)) { |
|
| 938 | + $Spotter = new Spotter(); |
|
| 939 | + } |
|
| 907 | 940 | $arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']); |
| 908 | 941 | print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n"; |
| 909 | 942 | print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n"; |
@@ -919,20 +952,28 @@ discard block |
||
| 919 | 952 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
| 920 | 953 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 921 | 954 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
| 922 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 955 | + } else { |
|
| 956 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 957 | + } |
|
| 923 | 958 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
| 924 | 959 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
| 925 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 960 | + } else { |
|
| 961 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 962 | + } |
|
| 926 | 963 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
| 927 | 964 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
| 928 | 965 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
| 929 | 966 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
| 930 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 967 | + } else { |
|
| 968 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 969 | + } |
|
| 931 | 970 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
| 932 | 971 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
| 933 | 972 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 934 | 973 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
| 935 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 974 | + } else { |
|
| 975 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 976 | + } |
|
| 936 | 977 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
| 937 | 978 | } |
| 938 | 979 | if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
@@ -945,7 +986,9 @@ discard block |
||
| 945 | 986 | $longitude = $spotter_item['longitude']; |
| 946 | 987 | } |
| 947 | 988 | $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
| 948 | - } else $distance = ''; |
|
| 989 | + } else { |
|
| 990 | + $distance = ''; |
|
| 991 | + } |
|
| 949 | 992 | if ($distance != '') { |
| 950 | 993 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
| 951 | 994 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |