NEOERR* system_plan_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mdb_conn *db = hash_lookup(dbh, "plan"); STRING str; string_init(&str); int count, offset; char *mname; HDF *node; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, db); MEMBER_CHECK_ADMIN(); SET_DASHBOARD_ACTION(cgi->hdf); hdf_get_node(cgi->hdf, PRE_OUTPUT, &node); mdb_pagediv(hdf_get_obj(cgi->hdf, PRE_QUERY), NULL, &count, &offset, NULL, node); err = mdb_build_querycond(hdf_get_obj(cgi->hdf, PRE_QUERY), hdf_get_obj(g_cfg, "Db.QueryCond.system.plan"), &str, "intime > current_date - 1"); if (err != STATUS_OK) return nerr_pass(err); MDB_PAGEDIV_SET_N(node, db, "plan", "%s", NULL, str.buf); MDB_QUERY_RAW(db, "plan", _COL_PLAN_ADMIN, "%s ORDER BY id DESC LIMIT %d OFFSET %d", NULL, str.buf, count, offset); err = mdb_set_rows(cgi->hdf, db, _COL_PLAN_ADMIN, PRE_OUTPUT".rows", NULL, MDB_FLAG_EMPTY_OK); if (err != STATUS_OK) return nerr_pass(err); return STATUS_OK; }
/* * ids=0:1 * { "0": { "1": { "ntt": "0", "nst": "0" } }, "success": "1" } * * ids=0:1,0:20 * { "0": { "1": { "ntt": "0", "nst": "0" }, "20": { "ntt": "0", "nst": "0" } }, "success": "1" } * * ids=0:1,1:20 * { "0": { "1": { "ntt": "0", "nst": "0" } }, "1": { "20": { "ntt": "0", "nst": "0" } }, "success": "1" } */ static NEOERR* aux_cmd_cmtget(struct aux_entry *e, QueueEntry *q) { unsigned char *val = NULL; size_t vsize = 0; int count, offset; char *ids, *idsdump, tok[128]; int type = -1, oid = -1; NEOERR *err; REQ_GET_PARAM_STR(q->hdfrcv, "ids", ids); mdb_conn *db = e->db; struct cache *cd = e->cd; mdb_pagediv(q->hdfrcv, NULL, &count, &offset, NULL, q->hdfsnd); if (cache_getf(cd, &val, &vsize, PREFIX_COMMENT"%s_%d", ids, offset)) { unpack_hdf(val, vsize, &q->hdfsnd); } else { idsdump = strdup(ids); char *p = ids; while (*p) { if (*p == ':') { *p = '\0'; type = atoi(ids); ids = p+1; } if (*p == ',') { *p = '\0'; oid = atoi(ids); if (type >= 0 && oid >= 0) { sprintf(tok, "%d.%d", type, oid); MDB_PAGEDIV_SET(q->hdfsnd, tok, db, "comment", "type=%d AND statu=%d AND oid=%d", NULL, type, CMT_ST_NORMAL, oid); MDB_QUERY_RAW(db, "comment", _COL_CMT, "type=%d AND statu=%d AND oid=%d " " ORDER BY intime DESC LIMIT %d OFFSET %d", NULL, type, CMT_ST_NORMAL, oid, count, offset); sprintf(tok, "%d.%d.cmts", type, oid); err = mdb_set_rows(q->hdfsnd, db, _COL_CMT, tok, NULL); nerr_handle(&err, NERR_NOT_FOUND); if (err != STATUS_OK) return nerr_pass(err); mstr_html_escape(hdf_get_child(q->hdfsnd, tok), "content"); type = oid = -1; } ids = p+1; } p++; } oid = atoi(ids); if (type >= 0 && oid >=0) { sprintf(tok, "%d.%d", type, oid); MDB_PAGEDIV_SET(q->hdfsnd, tok, db, "comment", "type=%d AND statu=%d AND oid=%d", NULL, type, CMT_ST_NORMAL, oid); MDB_QUERY_RAW(db, "comment", _COL_CMT, "type=%d AND statu=%d AND oid=%d " " ORDER BY intime DESC LIMIT %d OFFSET %d", NULL, type, CMT_ST_NORMAL, oid, count, offset); sprintf(tok, "%d.%d.cmts", type, oid); err = mdb_set_rows(q->hdfsnd, db, _COL_CMT, tok, NULL); nerr_handle(&err, NERR_NOT_FOUND); if (err != STATUS_OK) return nerr_pass(err); mstr_html_escape(hdf_get_child(q->hdfsnd, tok), "content"); } CACHE_HDF(q->hdfsnd, CMT_CC_SEC, PREFIX_COMMENT"%s_%d", idsdump, offset); free(idsdump); } return STATUS_OK; }