Advertisement
Guest User

sirboderafael

a guest
Mar 1st, 2009
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?
  2.     $ultimas_linhas = array_reverse(
  3.         array_slice(
  4.             file('./log'),
  5.             -10
  6.         )
  7.     );
  8.  
  9.     $ultimos_dados = array();
  10.  
  11.     foreach ($ultimas_linhas as $linha) {
  12.         $partes = explode(":", $linha);
  13.  
  14.         if (isset($partes[0]) && isset($partes[2])) {
  15.             array_push(
  16.                 $ultimos_dados,
  17.                 array(
  18.                     'ip' => trim($partes[0]),
  19.                     'informacao' => trim($partes[2])
  20.                 )
  21.             );
  22.         }
  23.     }
  24. ?>
  25. <html>
  26.     <head>
  27.         <meta http-equiv="refresh" content="5">
  28.         <title>Monitor de logs - Servidor GPS na porta 25000 UDP</title>
  29.     </head>
  30.     <body>
  31.         <h1>Monitor de logs - Servidor GPS na porta 25000 UDP</h1>
  32.         <h2>Atualizando a página a cada 5 segundos...</h2>
  33.         <p>Últimos 10 dados recebidos:
  34.             <ul>
  35. <? foreach ($ultimos_dados as $dado) { ?>
  36.                 <li><?= $dado['ip'].' : '.$dado['informacao']; ?></li>
  37. <? } ?>
  38.             </ul>
  39.         </p>
  40.     </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement