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