source: trollforge/lastmeasure/stats/index.php @ 115

Revision 115, 2.8 KB checked in by sam, 8 years ago (diff)
  • store dates in reverse order so that the latest hits are found at the beginning of the database.
  • Property svn:keywords set to Id
Line 
1<?php
2function print_hits() {
3    $id = dba_open('../db/hit.db', 'c', 'db4');
4    if(!$id) {
5        echo '<li style="color:red;">Failed to open database!</li>';
6        return;
7    }
8    $key = dba_firstkey($id);
9    if($key == false) {
10        echo '<li style="color:red;">No hits found!</li>';
11        return;
12    }
13    while($key != false) {
14        $val = dba_fetch($key, $id);
15        list($ip, $port, $hostname, $uagent,
16             $referer, $user, $clipboard) = explode(' ', $val);
17        $str = "<li>";
18        $str .= date('Y-m-d H:M:S', -1 - '0x' . substr($key, 0, 8));
19        $str .= " $ip:$port ($hostname)";
20        $str = "<li>$key --- $ip:$port ($hostname)";
21        $str .= " referer: " . base64_decode($referer);
22        $str .= " user: " . base64_decode($user);
23        $str .= " clipboard: " . base64_decode($clipboard);
24        $str .= "</li>";
25        echo $str;
26        $key = dba_nextkey($id);
27    }
28    dba_close($id);
29}
30
31function print_uagents() {
32    $id = dba_open('../db/uagent.db', 'c', 'db4');
33    if(!$id) {
34        echo '<li style="color:red;">Failed to open database!</li>';
35        return;
36    }
37    $key = dba_firstkey($id);
38    if($key == false) {
39        echo '<li style="color:red;">No hits found!</li>';
40        return;
41    }
42    while($key != false) {
43        $val = dba_fetch($key, $id);
44        echo "<li>".base64_decode($key).": $val</li>";
45        $key = dba_nextkey($id);
46    }
47    dba_close($id);
48}
49
50function print_users() {
51    $id = dba_open('../db/user.db', 'c', 'db4');
52    if(!$id) {
53        echo '<li style="color:red;">Failed to open database!</li>';
54        return;
55    }
56    $key = dba_firstkey($id);
57    if($key == false) {
58        echo '<li style="color:red;">No hits found!</li>';
59        return;
60    }
61    while($key != false) {
62        $val = dba_fetch($key, $id);
63        echo "<li>".base64_decode($key).": $val</li>";
64        $key = dba_nextkey($id);
65    }
66    dba_close($id);
67}
68
69?>
70<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
71       "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
72<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
73<head>
74   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
75   <title>GNAA Last Measure Statistics</title>
76   <link rel="icon" type="image/x-icon" href="/favicon.ico" />
77   <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
78</head>
79<body>
80  <div style="float: left; margin-top: 0px; background-color: transparent;
81              border: 30px; clear: both;">
82    <img src="/gnaa.png" width="108" height="40"
83         alt="GNAA" />
84  </div>
85
86  <h1> GNAA Last Measure Statistics </h1>
87
88  <p> Attempt at some lmstats. Unfinished. </p>
89  <p> Hits: </p>
90  <ul><?php print_hits(); ?></ul>
91  <p> Browsers: </p>
92  <ul><?php print_uagents(); ?></ul>
93  <p> Users: </p>
94  <ul><?php print_users(); ?></ul>
95
96</body>
97</html>
Note: See TracBrowser for help on using the repository browser.