Advertisement
Guest User

Untitled

a guest
Jul 30th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.44 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Log reader</title>
  4.         <style>
  5.             /* tables */
  6.             table.tablesorter {
  7.                 font-family:arial;
  8.                 background-color: #CDCDCD;
  9.                 margin:10px 0pt 15px;
  10.                 font-size: 8pt;
  11.                 width: 100%;
  12.                 text-align: left;
  13.             }
  14.             table.tablesorter thead tr th, table.tablesorter tfoot tr th {
  15.                 background-color: #e6EEEE;
  16.                 border: 1px solid #FFF;
  17.                 font-size: 8pt;
  18.                 padding: 4px;
  19.             }
  20.             table.tablesorter thead tr .header {
  21.                 background-image: url('data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==');
  22.                 background-repeat: no-repeat;
  23.                 background-position: center right;
  24.                 cursor: pointer;
  25.             }
  26.             table.tablesorter tbody td {
  27.                 color: #3D3D3D;
  28.                 padding: 4px;
  29.                 background-color: #FFF;
  30.                 vertical-align: top;
  31.             }
  32.             table.tablesorter tbody tr.odd td {
  33.                 background-color:#F0F0F6;
  34.             }
  35.             table.tablesorter thead tr .headerSortUp {
  36.                 background-image: url('data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7');
  37.             }
  38.             table.tablesorter thead tr .headerSortDown {
  39.                 background-image: url('data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7');
  40.             }
  41.             table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
  42.             background-color: #8dbdd8;
  43.             }
  44.            
  45.             table tr td div {
  46.                 float:left;margin-right:5px;
  47.             }
  48.         </style>
  49.     </head>
  50.    
  51.     <body>
  52.         <table width="100%" class='tablesorter'>
  53.             <thead>
  54.                 <tr>
  55.                     <th>#</th>
  56.                     <th>Nom de domaine</th>
  57.                     <th>Protocole</th>
  58.                     <th style='width:150px;'>IP visiteur</th>
  59.                     <th>Date et heure</th>
  60.                     <th>Type de requête</th>
  61.                     <th>Url demandée</th>
  62.                     <th>Code http</th>
  63.                     <th>Taille de la page</th>
  64.                     <th>Referer</th>
  65.                     <th>Navigateur</th>
  66.                 </tr>
  67.             </thead>
  68.             <tbody>
  69.        
  70.         <?php
  71.             function bin_convert($octets) {
  72.                 $resultat = $octets * 1000;
  73.                 for ($i=0; $i < 8 && $resultat >= 1000; $i++) {
  74.                     $resultat = $resultat / 1000;
  75.                 }
  76.                 if ($i > 0) {
  77.                     return preg_replace('/,00$/', '', number_format($resultat, 2, ',', ''))
  78.             . ' ' . substr('KMGTPEZY',$i-1,1) . 'o';
  79.                 } else {
  80.                     return $resultat . ' o';
  81.                 }
  82.             }
  83.            
  84.             function httpCode($code) {
  85.                 switch ($code) {
  86.                     case 100: $text = 'Continue'; break;
  87.                     case 101: $text = 'Switching Protocols'; break;
  88.                     case 200: $text = 'OK'; break;
  89.                     case 201: $text = 'Created'; break;
  90.                     case 202: $text = 'Accepted'; break;
  91.                     case 203: $text = 'Non-Authoritative Information'; break;
  92.                     case 204: $text = 'No Content'; break;
  93.                     case 205: $text = 'Reset Content'; break;
  94.                     case 206: $text = 'Partial Content'; break;
  95.                     case 300: $text = 'Multiple Choices'; break;
  96.                     case 301: $text = 'Moved Permanently'; break;
  97.                     case 302: $text = 'Moved Temporarily'; break;
  98.                     case 303: $text = 'See Other'; break;
  99.                     case 304: $text = 'Not Modified'; break;
  100.                     case 305: $text = 'Use Proxy'; break;
  101.                     case 400: $text = 'Bad Request'; break;
  102.                     case 401: $text = 'Unauthorized'; break;
  103.                     case 402: $text = 'Payment Required'; break;
  104.                     case 403: $text = 'Forbidden'; break;
  105.                     case 404: $text = 'Not Found'; break;
  106.                     case 405: $text = 'Method Not Allowed'; break;
  107.                     case 406: $text = 'Not Acceptable'; break;
  108.                     case 407: $text = 'Proxy Authentication Required'; break;
  109.                     case 408: $text = 'Request Time-out'; break;
  110.                     case 409: $text = 'Conflict'; break;
  111.                     case 410: $text = 'Gone'; break;
  112.                     case 411: $text = 'Length Required'; break;
  113.                     case 412: $text = 'Precondition Failed'; break;
  114.                     case 413: $text = 'Request Entity Too Large'; break;
  115.                     case 414: $text = 'Request-URI Too Large'; break;
  116.                     case 415: $text = 'Unsupported Media Type'; break;
  117.                     case 500: $text = 'Internal Server Error'; break;
  118.                     case 501: $text = 'Not Implemented'; break;
  119.                     case 502: $text = 'Bad Gateway'; break;
  120.                     case 503: $text = 'Service Unavailable'; break;
  121.                     case 504: $text = 'Gateway Time-out'; break;
  122.                     case 505: $text = 'HTTP Version not supported'; break;
  123.                     default:
  124.                         $text = 'Unknown http status code "' . htmlentities($code) . '"';
  125.                     break;
  126.                 }
  127.                 return $text;
  128.             }
  129.            
  130.             require("Browscap.php");
  131.             use phpbrowscap\Browscap;
  132.             $bc = new Browscap(dirname(__FILE__));
  133.            
  134.             $logFile = file('gilbert1995.log');
  135.             foreach($logFile as $nb=>$line) {
  136.                 preg_match('#(.*):([0-9]{1,5}) (([0-9]{1,3}\.){3}([0-9]{1,3}){1}) - - \[([0-9]{1,2}\/[a-zA-Z]{1,3}\/[0-9]{4}):(([0-9]{2}:){2}([0-9]{2}){1}) \+[0-9]{4}\] "([A-Z]+) \/(.*) HTTP\/[0-9.]+" ([0-9]{3}) ([0-9-]+) "(.*)" "(.*)"#',$line,$matches);
  137.                 $class = ($nb%2 == 1) ? 'odd' : 'even';
  138.                
  139.                 echo '<tr class="'.$class.'">';
  140.                     echo "<td>$nb</td>";
  141.                     echo "<td>{$matches[1]}</td>";
  142.                     $protocol = ($matches[2]==80)?'http':'https';
  143.                     echo "<td>$protocol</td>";
  144.                     echo "<td><div id='box_$nb'></div><script type='text/javascript' src='http://ipays.fr.nf/ip.php?nb=$nb&size=5&size_x=35&style=3&ip={$matches[3]}'></script><span style='float:left;'>{$matches[3]}</span></td>";
  145.                     echo "<td>{$matches[6]} {$matches[7]}</td>";
  146.                     echo "<td>{$matches[10]}</td>";
  147.                     echo "<td>/{$matches[11]}</td>";
  148.                     echo "<td>{$matches[12]} (".httpCode($matches[12]).")</td>";
  149.                     echo "<td>".bin_convert($matches[13])."</td>";
  150.                     echo "<td>{$matches[14]}</td>";
  151.                     $browser = ($bc->getBrowser($matches[15])->Browser == 'Default Browser') ? $bc->getBrowser($matches[15])->browser_name : $bc->getBrowser($matches[15])->Browser;
  152.                     echo "<td>$browser</td>";
  153.                 echo "</tr>";
  154.             }
  155.         ?>
  156.             </tbody>
  157.         </table>   
  158.        
  159.         <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
  160.         <script src='http://tablesorter.com/__jquery.tablesorter.min.js'></script>
  161.         <script>$("table").tablesorter(); </script>
  162.     </body>
  163. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement