Advertisement
JosephDB

ACCNAF online php

Feb 18th, 2016
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 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/GM,GS,GQ,GO,GB,GV,GU,GL,GF,GG,DA,DT,GA,DF,DI,DG,DX,DB,DN,DR,HL,FT,HS,HA,HH,HD,HC,HK,FS.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', 'FSS'), true) && $xploded[0] !== 'GULF'){
  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 "                        <div class=\"panel margin-bottom-40\">
  25.  <table class=\"table table-hover\">
  26.    <thead>
  27.        <tr>
  28.            <th>Name</th>
  29.            <th>Frequency</th>
  30.            <th>Position</th>
  31.        </tr>
  32.    </thead>
  33.    <tbody>
  34.    $tablerows
  35.    </tbody>
  36. </table>
  37. </div>
  38. ";
  39.   }
  40.   else {
  41.     echo "<div class=\"row\">
  42.                 <div class=\"col-md-9 animated fadeInLeft\"><span>No controllers currently online!</span></div></div>";
  43.   }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement