Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Log reader</title>
- <style>
- /* tables */
- table.tablesorter {
- font-family:arial;
- background-color: #CDCDCD;
- margin:10px 0pt 15px;
- font-size: 8pt;
- width: 100%;
- text-align: left;
- }
- table.tablesorter thead tr th, table.tablesorter tfoot tr th {
- background-color: #e6EEEE;
- border: 1px solid #FFF;
- font-size: 8pt;
- padding: 4px;
- }
- table.tablesorter thead tr .header {
- background-image: url('data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==');
- background-repeat: no-repeat;
- background-position: center right;
- cursor: pointer;
- }
- table.tablesorter tbody td {
- color: #3D3D3D;
- padding: 4px;
- background-color: #FFF;
- vertical-align: top;
- }
- table.tablesorter tbody tr.odd td {
- background-color:#F0F0F6;
- }
- table.tablesorter thead tr .headerSortUp {
- background-image: url('data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7');
- }
- table.tablesorter thead tr .headerSortDown {
- background-image: url('data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7');
- }
- table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
- background-color: #8dbdd8;
- }
- table tr td div {
- float:left;margin-right:5px;
- }
- </style>
- </head>
- <body>
- <table width="100%" class='tablesorter'>
- <thead>
- <tr>
- <th>#</th>
- <th>Nom de domaine</th>
- <th>Protocole</th>
- <th style='width:150px;'>IP visiteur</th>
- <th>Date et heure</th>
- <th>Type de requête</th>
- <th>Url demandée</th>
- <th>Code http</th>
- <th>Taille de la page</th>
- <th>Referer</th>
- <th>Navigateur</th>
- </tr>
- </thead>
- <tbody>
- <?php
- function bin_convert($octets) {
- $resultat = $octets * 1000;
- for ($i=0; $i < 8 && $resultat >= 1000; $i++) {
- $resultat = $resultat / 1000;
- }
- if ($i > 0) {
- return preg_replace('/,00$/', '', number_format($resultat, 2, ',', ''))
- . ' ' . substr('KMGTPEZY',$i-1,1) . 'o';
- } else {
- return $resultat . ' o';
- }
- }
- function httpCode($code) {
- switch ($code) {
- case 100: $text = 'Continue'; break;
- case 101: $text = 'Switching Protocols'; break;
- case 200: $text = 'OK'; break;
- case 201: $text = 'Created'; break;
- case 202: $text = 'Accepted'; break;
- case 203: $text = 'Non-Authoritative Information'; break;
- case 204: $text = 'No Content'; break;
- case 205: $text = 'Reset Content'; break;
- case 206: $text = 'Partial Content'; break;
- case 300: $text = 'Multiple Choices'; break;
- case 301: $text = 'Moved Permanently'; break;
- case 302: $text = 'Moved Temporarily'; break;
- case 303: $text = 'See Other'; break;
- case 304: $text = 'Not Modified'; break;
- case 305: $text = 'Use Proxy'; break;
- case 400: $text = 'Bad Request'; break;
- case 401: $text = 'Unauthorized'; break;
- case 402: $text = 'Payment Required'; break;
- case 403: $text = 'Forbidden'; break;
- case 404: $text = 'Not Found'; break;
- case 405: $text = 'Method Not Allowed'; break;
- case 406: $text = 'Not Acceptable'; break;
- case 407: $text = 'Proxy Authentication Required'; break;
- case 408: $text = 'Request Time-out'; break;
- case 409: $text = 'Conflict'; break;
- case 410: $text = 'Gone'; break;
- case 411: $text = 'Length Required'; break;
- case 412: $text = 'Precondition Failed'; break;
- case 413: $text = 'Request Entity Too Large'; break;
- case 414: $text = 'Request-URI Too Large'; break;
- case 415: $text = 'Unsupported Media Type'; break;
- case 500: $text = 'Internal Server Error'; break;
- case 501: $text = 'Not Implemented'; break;
- case 502: $text = 'Bad Gateway'; break;
- case 503: $text = 'Service Unavailable'; break;
- case 504: $text = 'Gateway Time-out'; break;
- case 505: $text = 'HTTP Version not supported'; break;
- default:
- $text = 'Unknown http status code "' . htmlentities($code) . '"';
- break;
- }
- return $text;
- }
- require("Browscap.php");
- use phpbrowscap\Browscap;
- $bc = new Browscap(dirname(__FILE__));
- $logFile = file('gilbert1995.log');
- foreach($logFile as $nb=>$line) {
- 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);
- $class = ($nb%2 == 1) ? 'odd' : 'even';
- echo '<tr class="'.$class.'">';
- echo "<td>$nb</td>";
- echo "<td>{$matches[1]}</td>";
- $protocol = ($matches[2]==80)?'http':'https';
- echo "<td>$protocol</td>";
- 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>";
- echo "<td>{$matches[6]} {$matches[7]}</td>";
- echo "<td>{$matches[10]}</td>";
- echo "<td>/{$matches[11]}</td>";
- echo "<td>{$matches[12]} (".httpCode($matches[12]).")</td>";
- echo "<td>".bin_convert($matches[13])."</td>";
- echo "<td>{$matches[14]}</td>";
- $browser = ($bc->getBrowser($matches[15])->Browser == 'Default Browser') ? $bc->getBrowser($matches[15])->browser_name : $bc->getBrowser($matches[15])->Browser;
- echo "<td>$browser</td>";
- echo "</tr>";
- }
- ?>
- </tbody>
- </table>
- <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
- <script src='http://tablesorter.com/__jquery.tablesorter.min.js'></script>
- <script>$("table").tablesorter(); </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement