Changeset 119 for trollforge/lastmeasure


Ignore:
Timestamp:
11/30/05 15:00:43 (7 years ago)
Author:
sam
Message:
  • nicer stats
Location:
trollforge/lastmeasure
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trollforge/lastmeasure/index.php

    r115 r119  
    188188    $uagent = base64_encode($_SERVER['HTTP_USER_AGENT']); 
    189189    $referer = base64_encode($_SERVER['HTTP_REFERER']); 
    190     $user = base64_encode('nobody'); 
     190    $user = base64_encode(''); 
    191191    $clipboard = base64_encode(''); 
    192192 
  • trollforge/lastmeasure/stats/index.php

    r118 r119  
    33    $id = dba_open('../db/hit.db', 'c', 'db4'); 
    44    if(!$id) { 
    5         echo '<tr><td colspan="5" style="background-color: #f66;">Failed to open database!</td></tr>'; 
     5        ?><tr><td colspan="6" style="background-color: #f66;">Failed to open database!</td></tr><?php 
    66        return; 
    77    } 
    88    $key = dba_firstkey($id); 
    99    if($key == false) { 
    10         echo '<tr><td colspan="5" style="background-color: #f66;">No hits found!</td></tr>'; 
     10        ?><tr><td colspan="6" style="background-color: #f66;">No hits found!</td></tr><?php 
    1111        return; 
    1212    } 
    13     for($lines = 0; $lines < 20 && $key != false; $lines++) { 
     13    for($l = 0; $l < 20 && $key != false; $l++) { 
    1414        $val = dba_fetch($key, $id); 
    1515        list($ip, $port, $hostname, $uagent, 
    1616             $referer, $user, $clipboard) = explode(' ', $val); 
    17         $str = '<tr>'; 
    18         $str .= '<td>' . date('Y-m-d H:i:s', -1 - hexdec(substr($key, 0, 8))) . '</td>'; 
    19         $str .= '<td>' . $ip . ':' . $port; 
    20         if($hostname) $str .= ' ('.$hostname.')'; 
    21         $str .= '</td>'; 
    22         $str .= '<td>' . base64_decode($referer) . '</td>'; 
    23         $str .= '<td>' . base64_decode($user) . '</td>'; 
    24         $str .= '<td>' . base64_decode($clipboard) . '</td>'; 
    25         $str .= '</tr>'; 
    26         echo $str; 
     17        $date = -1 - hexdec(substr($key, 0, 8)); ?> 
     18        <tr style="background-color: <?php echo ($l % 2) ? '#cef' : '#ecf'; ?>"> 
     19          <td><?php echo date('Y-m-d H:i:s', $date); ?></td> 
     20          <td><?php echo $ip . ':' . $port; 
     21                    if($hostname) echo ' ('.$hostname.')'; ?></td> 
     22          <td><?php echo base64_decode($uagent); ?></td> 
     23          <td><?php echo base64_decode($referer); ?></td> 
     24          <td><?php echo base64_decode($user); ?></td> 
     25          <td><?php echo base64_decode($clipboard); ?></td> 
     26        </tr><?php 
    2727        $key = dba_nextkey($id); 
    2828    } 
     
    3030} 
    3131 
    32 function print_uagents() { 
    33     $id = dba_open('../db/uagent.db', 'c', 'db4'); 
     32function print_table($table) { 
     33    $id = dba_open($table, 'c', 'db4'); 
    3434    if(!$id) { 
    35         echo '<li style="color:red;">Failed to open database!</li>'; 
     35        ?><tr><td colspan="2" style="background-color: #f66;">Failed to open database!</td></tr><?php 
    3636        return; 
    3737    } 
    3838    $key = dba_firstkey($id); 
    3939    if($key == false) { 
    40         echo '<li style="color:red;">No hits found!</li>'; 
     40        ?><tr><td colspan="2" style="background-color: #f66;">No hits found!</td></tr><?php 
    4141        return; 
    4242    } 
    43     while($key != false) { 
    44         $val = dba_fetch($key, $id); 
    45         echo "<li>".base64_decode($key).": $val</li>"; 
    46         $key = dba_nextkey($id); 
    47     } 
    48     dba_close($id); 
    49 } 
    50  
    51 function print_users() { 
    52     $id = dba_open('../db/user.db', 'c', 'db4'); 
    53     if(!$id) { 
    54         echo '<li style="color:red;">Failed to open database!</li>'; 
    55         return; 
    56     } 
    57     $key = dba_firstkey($id); 
    58     if($key == false) { 
    59         echo '<li style="color:red;">No hits found!</li>'; 
    60         return; 
    61     } 
    62     while($key != false) { 
    63         $val = dba_fetch($key, $id); 
    64         echo "<li>".base64_decode($key).": $val</li>"; 
     43    for($l = 0; $key != false; $l++) { 
     44        $val = dba_fetch($key, $id); ?> 
     45        <tr style="background-color: <?php echo ($l % 2) ? '#cef' : '#ecf'; ?>"> 
     46          <td><?php echo base64_decode($key); ?></td> 
     47          <td><?php echo $val; ?></td> 
     48        </tr><?php 
    6549        $key = dba_nextkey($id); 
    6650    } 
     
    7963</head> 
    8064<body> 
    81   <div style="float: left; margin-top: 0px; background-color: transparent; 
    82               border: 30px; clear: both;"> 
     65  <div style="float: left; background-color: transparent; 
     66              border: 10px; clear: both;"> 
    8367    <img src="/gnaa.png" width="108" height="40" 
    8468         alt="GNAA" /> 
     
    8771  <h1> GNAA Last Measure Statistics </h1> 
    8872 
    89   <p> Attempt at some lmstats. Unfinished. </p> 
    90   <p> Hits: </p> 
    91   <table style="border: solid black 1px;"> 
     73  <table style="border: solid black 1px; margin: 10px;"> 
    9274    <tr style="background-color: #8af;"> 
    93       <td>Date</td><td>Host</td><td>Referer</td><td>User</td><td>Clipboard</td> 
     75      <td>Date</td> 
     76      <td>Host</td> 
     77      <td>Browser</td> 
     78      <td>Referer</td> 
     79      <td>User</td> 
     80      <td>Clipboard</td> 
    9481    </tr> 
     82    <?php print_hits(); ?> 
    9583  </table> 
    9684 
    97   <ul><?php print_hits(); ?></ul> 
    98   <p> Browsers: </p> 
    99   <ul><?php print_uagents(); ?></ul> 
    100   <p> Users: </p> 
    101   <ul><?php print_users(); ?></ul> 
     85  <table style="border: solid black 1px; margin: 10px;"> 
     86    <tr style="background-color: #8af;"> 
     87      <td>Browser</td> 
     88      <td>Count</td> 
     89    </tr> 
     90    <?php print_table('../db/uagent.db'); ?> 
     91  </table> 
     92 
     93  <table style="border: solid black 1px; margin: 10px;"> 
     94    <tr style="background-color: #8af;"> 
     95      <td>User</td> 
     96      <td>Count</td> 
     97    </tr> 
     98    <?php print_table('../db/user.db'); ?> 
     99  </table> 
     100 
     101  <hr /> 
     102 
     103  <p> Generated by Last Measure Unified <?php echo date('Y-m-d H:i:s'); ?> </p> 
    102104 
    103105</body> 
Note: See TracChangeset for help on using the changeset viewer.