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

Revision 111, 1.7 KB checked in by sam, 7 years ago (diff)
  • warn if the database could not be found
  • 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, $referer, $user, $clipboard) = explode(' ', $val);
16        $str = "<li>$key --- $ip:$port ($hostname)";
17        $str .= " useragent: " . base64_decode($uagent);
18        $str .= " referer: " . base64_decode($referer);
19        $str .= " user: " . base64_decode($user);
20        $str .= " clipboard: " . base64_decode($clipboard);
21        $str .= "</li>";
22        echo $str;
23        $key = dba_nextkey($id);
24    }
25    dba_close($id);
26}
27
28function print_uagents() {
29    $id = dba_open('../db/uagent.db', 'c', 'db4');
30    if(!$id) {
31        return;
32    }
33    $key = dba_firstkey($id);
34    while($key != false) {
35        $val = dba_fetch($key, $id);
36        echo "<li>".base64_decode($key).": $val</li>";
37        $key = dba_nextkey($id);
38    }
39    dba_close($id);
40}
41
42function print_users() {
43    $id = dba_open('../db/user.db', 'c', 'db4');
44    if(!$id) {
45        return;
46    }
47    $key = dba_firstkey($id);
48    while($key != false) {
49        $val = dba_fetch($key, $id);
50        echo "<li>".base64_decode($key).": $val</li>";
51        $key = dba_nextkey($id);
52    }
53    dba_close($id);
54}
55
56?>
57<html>
58<body>
59  <p>Attempt at some lmstats. Unfinished. <img src="/gnaa.png" alt="GNAA"/></p>
60
61  <p>Hits:</p>
62  <ul><?php print_hits(); ?></ul>
63
64  <p>User agents:</p>
65  <ul><?php print_uagents(); ?></ul>
66
67  <p>Users:</p>
68  <ul><?php print_users(); ?></ul>
69
70  </body>
71</html>
Note: See TracBrowser for help on using the repository browser.