Advertisement
Guest User

Lecteur de log

a guest
Jun 30th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <table cellspacing="0" border="1" cellpadding="10">
  2.     <tr>   
  3.         <td>ID</td>
  4.         <td>Site</td>
  5.         <td>Ip visiteur</td>
  6.         <td>Date</td>
  7.         <td>Heure</td>
  8.         <td>Page</td>
  9.         <td>Navigateur</td>
  10.     </tr>
  11.    
  12. <?php
  13.     $file = file('log.log');
  14.    
  15.    
  16.    
  17.     foreach ($file as $lineNumber => $lineContent)
  18.     {
  19.            
  20.             $id = $lineNumber+1 ;
  21.             $site = '#(.*):80#';
  22.             $ip = '#[1-9]{1,3}.[1-9]{1,3}.[1-9]{1,3}.[1-9]{1,3}#';
  23.             $jour = '#[[1-9]{1,2}/#';
  24.             $mois = '#/[a-zA-Z]{3}/#';
  25.             $heure = '#:[0-9]{2}:(.*):(.*) +#';
  26.             $page = '# /(.*) HTTP#';
  27.             $navigateur = '#"-" "(.*)"#';
  28.            
  29.             $content = @preg_match($site, $lineContent, $site, 0);
  30.             $content = @preg_match($ip, $lineContent, $ip, 0);
  31.             $content = @preg_match($jour, $lineContent, $jour, 0);
  32.             $content = @preg_match($mois, $lineContent, $mois, 0);
  33.             $content = @preg_match($heure, $lineContent, $heure, 0);
  34.             $content = @preg_match($page, $lineContent, $page, 0);
  35.             $content = @preg_match($navigateur, $lineContent, $navigateur, 0);
  36.            
  37.             $heure = @preg_replace('# +(.*)#', '', $heure[0]);
  38.             $heure = @substr($heure,1);
  39.            
  40. ?>
  41.            
  42.            
  43.                
  44.                 <tr>
  45.                     <td><?php echo '#'.$id; ?></td>
  46.                     <td><?php echo @preg_replace('#:80#', '', $site[0]); ?></td>
  47.                     <td><?php echo $ip[0]; ?></td>
  48.                     <td><?php echo @preg_replace('#/#', '', $jour[0]).' '.preg_replace('#/#', '', $mois[0]) ; ?></td>
  49.                     <td><?php echo $heure; ?></td>
  50.                     <td><?php echo @preg_replace('# HTTP#', '', $page[0]); ?></td>
  51.                     <td><?php echo @preg_replace('#"-" "#', '', $navigateur[0]); ?></td>
  52. <?php
  53.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement