]> git.wh0rd.org - tt-rss.git/blame - stats.php
TAG 1.0.6
[tt-rss.git] / stats.php
CommitLineData
81f8401d 1<?
36bfab86 2 require_once "sessions.php";
81f8401d
AD
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) {
f2b6a2d4 15 header("Location: login.php"); die;
81f8401d
AD
16 }
17?>
18
19<html>
20<head>
21 <title>Tiny Tiny Statistics</title>
22</head>
23
24<body>
25
26<h1>Tiny Tiny Statistics</h1>
27
28<h2>Counters</h2>
29
30<?
3e4950c7
AD
31 $result = db_query($link, "SELECT count(id) AS cid,
32 SUM(LENGTH(content)) AS size
33 FROM ttrss_entries");
81f8401d
AD
34
35 $total_articles = db_fetch_result($result, 0, "cid");
3e4950c7 36 $articles_size = round(db_fetch_result($result, 0, "size") / 1024);
81f8401d 37
3e4950c7 38 print "<p>Total articles stored: $total_articles (${articles_size}K)</p>";
81f8401d 39
f26ef034 40/* $result = db_query($link, "SELECT COUNT(int_id) as cid,owner_uid,login
81f8401d 41 FROM ttrss_user_entries
f26ef034
AD
42 LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)
43 GROUP BY owner_uid,login ORDER BY cid DESC"); */
44
45 $result = db_query($link, "SELECT count(ttrss_entries.id) AS cid,
46 login FROM ttrss_entries
47 LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id)
48 LEFT JOIN ttrss_users ON (ttrss_users.id = owner_uid) GROUP BY login");
81f8401d
AD
49
50 print "<h2>Per-user storage</h2>";
51
52 print "<table width='100%'>";
53
54 print "<tr>
55 <td>Articles</td>
56 <td>Owner</td>
57 </tr>";
58
59 while ($line = db_fetch_assoc($result)) {
60 print "<tr>";
61 print "<td>" . $line["cid"] . "</td><td>" . $line["login"] . "</td>";
62 print "</tr>";
63 }
64
65 print "</table>";
66
67 print "<h2>User subscriptions</h2>";
68
69 $result = db_query($link, "SELECT title,feed_url,site_url,login,
70 (SELECT count(int_id) FROM ttrss_user_entries
71 WHERE feed_id = ttrss_feeds.id) AS num_articles,
72 (SELECT count(int_id) FROM ttrss_user_entries
73 WHERE feed_id = ttrss_feeds.id AND unread = true) AS num_articles_unread
74 FROM ttrss_feeds,ttrss_users
75 WHERE owner_uid = ttrss_users.id ORDER BY login");
76
77 print "<table width='100%'>";
78 print "<tr>
79 <td>Site</td>
80 <td>Feed</td>
81 <td>Owner</td>
82 <td>Stored Articles</td>
83 <td>Unread Articles</td>
84 </tr>";
85
86 $cur_login = "";
87
88 while ($line = db_fetch_assoc($result)) {
89 print "<tr>";
90 print "<td><a href=\"".$line["site_url"]."\">".$line["title"]."</a></td>";
91 print "<td><a href=\"".$line["feed_url"]."\">".$line["feed_url"]."</a></td>";
92 print "<td>" . $line["login"] . "</td>";
93 print "<td>" . $line["num_articles"] . "</td>";
94 print "<td>" . $line["num_articles_unread"] . "</td>";
95 print "</tr>";
96
97 if ($cur_login != $line["login"] && $cur_login != "") {
98 print "<tr><td>&nbsp;</td></tr>";
99 $cur_login = $line["login"];
100 }
101 }
102
103 print "</table>";
104
105?>
106</pre>
107
108</body>
109</html>