]> git.wh0rd.org Git - tt-rss.git/blob - stats.php
use author attribute
[tt-rss.git] / stats.php
1 <?
2         session_start();
3
4         require_once "sanity_check.php";
5         require_once "version.php"; 
6         require_once "config.php";
7         require_once "db-prefs.php";
8         require_once "functions.php"; 
9
10         $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
11
12         login_sequence($link);
13
14         if ($_SESSION["access_level"] < 10) { 
15                 header("Location: error.php?c=8");
16                 exit;
17         }
18 ?>
19
20 <html>
21 <head>
22         <title>Tiny Tiny Statistics</title>
23 </head>
24
25 <body>
26
27 <h1>Tiny Tiny Statistics</h1>
28
29 <h2>Counters</h2>
30
31 <?
32         $result = db_query($link, "SELECT count(id) AS cid,
33                 SUM(LENGTH(content)) AS size
34                 FROM ttrss_entries");
35
36         $total_articles = db_fetch_result($result, 0, "cid");
37         $articles_size = round(db_fetch_result($result, 0, "size") / 1024);
38
39         print "<p>Total articles stored: $total_articles (${articles_size}K)</p>";
40
41         $result = db_query($link, "SELECT COUNT(int_id) as cid,owner_uid,login 
42                 FROM ttrss_user_entries 
43                         JOIN ttrss_users ON (owner_uid = ttrss_users.id)
44                 GROUP BY owner_uid,login ORDER BY cid DESC");
45
46         print "<h2>Per-user storage</h2>";
47
48         print "<table width='100%'>";
49         
50         print "<tr>
51                 <td>Articles</td>
52                 <td>Owner</td>
53         </tr>";
54
55         while ($line = db_fetch_assoc($result)) {
56                 print "<tr>";
57                 print "<td>" . $line["cid"] . "</td><td>" . $line["login"] . "</td>";
58                 print "</tr>";
59         }
60
61         print "</table>";
62
63         print "<h2>User subscriptions</h2>";
64
65         $result = db_query($link, "SELECT title,feed_url,site_url,login,
66                 (SELECT count(int_id) FROM ttrss_user_entries 
67                         WHERE feed_id = ttrss_feeds.id) AS num_articles,
68                 (SELECT count(int_id) FROM ttrss_user_entries 
69                         WHERE feed_id = ttrss_feeds.id AND unread = true) AS num_articles_unread
70                 FROM ttrss_feeds,ttrss_users 
71                 WHERE owner_uid = ttrss_users.id ORDER BY login");
72
73         print "<table width='100%'>";
74         print "<tr>
75                 <td>Site</td>
76                 <td>Feed</td>
77                 <td>Owner</td>
78                 <td>Stored Articles</td>
79                 <td>Unread Articles</td>
80         </tr>";
81
82         $cur_login = "";
83
84         while ($line = db_fetch_assoc($result)) {
85                 print "<tr>";
86                 print "<td><a href=\"".$line["site_url"]."\">".$line["title"]."</a></td>";
87                 print "<td><a href=\"".$line["feed_url"]."\">".$line["feed_url"]."</a></td>";
88                 print "<td>" . $line["login"] . "</td>";
89                 print "<td>" . $line["num_articles"] . "</td>";
90                 print "<td>" . $line["num_articles_unread"] . "</td>";
91                 print "</tr>";
92
93                 if ($cur_login != $line["login"] && $cur_login != "") {
94                         print "<tr><td>&nbsp;</td></tr>";
95                         $cur_login = $line["login"];
96                 }
97         }
98
99         print "</table>";
100
101 ?>
102 </pre>
103
104 </body>
105 </html>