]> git.wh0rd.org - tt-rss.git/blob - stats.php
statistics stub
[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(int_id) as cid FROM ttrss_user_entries");
33
34 $total_articles = db_fetch_result($result, 0, "cid");
35
36 print "<p>Total articles stored: $total_articles</p>";
37
38 $result = db_query($link, "SELECT COUNT(int_id) as cid,owner_uid,login
39 FROM ttrss_user_entries
40 JOIN ttrss_users ON (owner_uid = ttrss_users.id)
41 GROUP BY owner_uid,login ORDER BY cid DESC");
42
43 print "<h2>Per-user storage</h2>";
44
45 print "<table width='100%'>";
46
47 print "<tr>
48 <td>Articles</td>
49 <td>Owner</td>
50 </tr>";
51
52 while ($line = db_fetch_assoc($result)) {
53 print "<tr>";
54 print "<td>" . $line["cid"] . "</td><td>" . $line["login"] . "</td>";
55 print "</tr>";
56 }
57
58 print "</table>";
59
60 print "<h2>User subscriptions</h2>";
61
62 $result = db_query($link, "SELECT title,feed_url,site_url,login,
63 (SELECT count(int_id) FROM ttrss_user_entries
64 WHERE feed_id = ttrss_feeds.id) AS num_articles,
65 (SELECT count(int_id) FROM ttrss_user_entries
66 WHERE feed_id = ttrss_feeds.id AND unread = true) AS num_articles_unread
67 FROM ttrss_feeds,ttrss_users
68 WHERE owner_uid = ttrss_users.id ORDER BY login");
69
70 print "<table width='100%'>";
71 print "<tr>
72 <td>Site</td>
73 <td>Feed</td>
74 <td>Owner</td>
75 <td>Stored Articles</td>
76 <td>Unread Articles</td>
77 </tr>";
78
79 $cur_login = "";
80
81 while ($line = db_fetch_assoc($result)) {
82 print "<tr>";
83 print "<td><a href=\"".$line["site_url"]."\">".$line["title"]."</a></td>";
84 print "<td><a href=\"".$line["feed_url"]."\">".$line["feed_url"]."</a></td>";
85 print "<td>" . $line["login"] . "</td>";
86 print "<td>" . $line["num_articles"] . "</td>";
87 print "<td>" . $line["num_articles_unread"] . "</td>";
88 print "</tr>";
89
90 if ($cur_login != $line["login"] && $cur_login != "") {
91 print "<tr><td>&nbsp;</td></tr>";
92 $cur_login = $line["login"];
93 }
94 }
95
96 print "</table>";
97
98 ?>
99 </pre>
100
101 </body>
102 </html>