summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--httpd.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/httpd.c b/httpd.c
index 5f24685..52684cf 100644
--- a/httpd.c
+++ b/httpd.c
@@ -39,11 +39,35 @@ const char *nodeinfo_2_0_template = ""
39xs_str *nodeinfo_2_0(void) 39xs_str *nodeinfo_2_0(void)
40/* builds a nodeinfo json object */ 40/* builds a nodeinfo json object */
41{ 41{
42 xs *users = user_list(); 42 int n_utotal = 0;
43 int n_users = xs_list_len(users); 43 int n_umonth = 0;
44 int n_posts = 0; /* to be implemented someday */ 44 int n_uhyear = 0;
45 int n_posts = 0;
46 xs *users = user_list();
47 xs_list *p;
48 char *v;
49
50 p = users;
51 while (xs_list_iter(&p, &v)) {
52 /* build the full path name to the last usage log */
53 xs *llfn = xs_fmt("%s/user/%s/lastlog.txt", srv_basedir, v);
54 double llsecs = (double)time(NULL) - mtime(llfn);
55
56 if (llsecs < 60 * 60 * 24 * 30 * 6) {
57 n_uhyear++;
58
59 if (llsecs < 60 * 60 * 24 * 30)
60 n_umonth++;
61 }
62
63 n_utotal++;
64
65 /* build the file to each user public.idx */
66 xs *pidxfn = xs_fmt("%s/user/%s/private.idx", srv_basedir, v);
67 n_posts += index_len(pidxfn);
68 }
45 69
46 return xs_fmt(nodeinfo_2_0_template, n_users, n_users, n_users, n_posts); 70 return xs_fmt(nodeinfo_2_0_template, n_utotal, n_umonth, n_uhyear, n_posts);
47} 71}
48 72
49 73