From 05cf05e423f26005bab5797f0e5b53d05ede56c5 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 21 Apr 2020 02:39:18 +1000 Subject: Part of the validated member list code. --- src/sledjchisl/sledjchisl.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index b05aaa0..8980bd4 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -4761,6 +4761,96 @@ static int accountOut(reqData *Rd, inputForm *iF, inputValue *iV) return ret; } +typedef struct _RdAndListTbl RdAndListTbl; +struct _RdAndListTbl +{ + reqData *Rd; + qlisttbl_t *list; +}; +static int accountFilterValidated(struct dirtree *node) +{ + if (!node->parent) return DIRTREE_RECURSE | DIRTREE_SHUTUP; + + if (S_ISREG(node->st.st_mode)) + { + struct stat st; + struct timespec now; + RdAndListTbl *rdl = (RdAndListTbl *) node->parent->extra; + qhashtbl_t *tnm = qhashtbl(0, 0); + char *name = node->name; + char *where = xmprintf("%s/users/%s", scData, node->name); + int rt = LuaToHash(rdl->Rd, where, "user", tnm, 0, &st, &now, "user"); + +//t("accountFilterValidatedVoucher %s (%s) -> %s -> %s", name, getStrH(tnm, "level"), getStrH(tnm, "name"), getStrH(tnm, "voucher")); + if ((0 == rt) && (strcmp("-100", getStrH(tnm, "level")) == 0)) + rdl->list->put(rdl->list, getStrH(tnm, "name"), tnm, sizeof(*tnm)); + else + tnm->free(tnm); + free(where); + } + return 0; +} +qlisttbl_t *getAccounts(reqData *Rd) +{ + qlisttbl_t *ret = qlisttbl(0); + RdAndListTbl rdl = {Rd, ret}; + char *path = xmprintf("%s/users", scData); + struct dirtree *new = dirtree_add_node(0, path, 0); + + new->extra = (long) &rdl; + dirtree_handle_callback(new, accountFilterValidated); + ret->sort(ret); + free(path); + + return ret; +} +static void accountExploreValidatedVouchersWeb(reqData *Rd, inputForm *oF, inputValue *oV) +{ + qlisttbl_t *list =getAccounts(Rd); + char *name = getStrH(Rd->stuff, "name"); + + Rd->shs.UUID = NULL; + accountWebHeaders(Rd, oF, name); + accountWebFields(Rd, oF, oV); + + count = list->size(list); + Rd->reply->addstrf(Rd->reply, "
name | "); + Rd->reply->addstr(Rd->reply, "voucher | "); + Rd->reply->addstr(Rd->reply, "level | "); + Rd->reply->addstr(Rd->reply, "title | "); + Rd->reply->addstr(Rd->reply, "
---|---|---|---|
%s | ", Rd->Host, Rd->RUri, nm, obj.name); + Rd->reply->addstrf(Rd->reply, "%s | %s | %s |