Advertisement
JosephDB

Untitled

Feb 18th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <?php
  2. echo "<!--Code by Joseph Donat Bolton 1289478-->";
  3. $cache_file = 'atctable.cache';
  4. if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 60 * 2 ))) {
  5. $tablerows = file_get_contents($cache_file);
  6. }
  7. else {
  8. $atcNAF = simplexml_load_file('http://api.vateud.net/online/atc/DA.xml');
  9. foreach ($atcNAF as $controller):
  10. $xploded = explode('_', $controller->callsign);
  11. if (strlen($xploded[0]) == 4){
  12. if (in_array(end($xploded), array('DEL','GND','TWR', 'APP', 'DEP', 'CTR'), true)){
  13. $name = $controller->name;
  14. $frequency = $controller->frequency;
  15. $callsign = $controller->callsign;
  16. $row = "<tr> <td>$name</td> <td>$frequency MHz</td> <td>$callsign</td></tr>";
  17. $tablerows .= $row;
  18. }
  19. }
  20. endforeach;
  21. file_put_contents($cache_file, $tablerows, LOCK_EX);
  22. }
  23. if (!empty($tablerows)) {
  24. echo "<table class=\"table table-hover\">
  25. <thead>
  26. <tr>
  27. <th>Name</th>
  28. <th>Frequency</th>
  29. <th>Position</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. $tablerows
  34. </tbody>
  35. </table>";
  36. }
  37. else {
  38. echo "<span>No controllers currently online!</span>";
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement