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