From 5611c22c92cefb2e9c86d20a98ed4680e5b813ed Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Wed, 6 May 2009 20:30:48 +0200 Subject: Renamed fieldmapping for 'attempts' to 'attemptslog' Also made the result XML from eDBadminAttemptsLog(...) more efficient by not adding the username/certificate/ipaddress group tags if the information is not present. --- database/sqlite/administration.c | 6 +++--- database/sqlite/attempts.c | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'database/sqlite') diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index 6def2e8..e75dccd 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -1565,11 +1565,11 @@ xmlDoc *eDBadminGetLastlog(eurephiaCTX *ctx, xmlDoc *srch, const char *sortkeys) // The search XML document format is: // -// +// // // <{field name}>{field value} // -// +// // // // It can be several search field tags to limit the search even more. @@ -1593,7 +1593,7 @@ xmlDoc *eDBadminAttemptsLog(eurephiaCTX *ctx, xmlDoc *qryxml) { return NULL; } - root_n = eurephiaXML_getRoot(ctx, qryxml, "attempts", 1); + root_n = eurephiaXML_getRoot(ctx, qryxml, "attemptslog", 1); if( root_n == NULL ) { eurephia_log(ctx, LOG_CRITICAL, 0, "Invalid XML input."); return NULL; diff --git a/database/sqlite/attempts.c b/database/sqlite/attempts.c index 7e8e95b..4afd981 100644 --- a/database/sqlite/attempts.c +++ b/database/sqlite/attempts.c @@ -65,24 +65,31 @@ xmlDoc *attempts_list(eurephiaCTX *ctx, eDBfieldMap *fmap) { return 0; } - eurephiaXML_CreateDoc(ctx, 1, "attempts", &doc, &root_n); + eurephiaXML_CreateDoc(ctx, 1, "attemptslog", &doc, &root_n); xmlNewProp(root_n, (xmlChar *) "mode", (xmlChar *) "list"); - uname_n = xmlNewChild(root_n, NULL, (xmlChar *) "username", NULL); - cert_n = xmlNewChild(root_n, NULL, (xmlChar *) "certificate", NULL); - remip_n = xmlNewChild(root_n, NULL, (xmlChar *) "ipaddress", NULL); - assert( (uname_n != NULL) && (cert_n != NULL) && (remip_n != NULL) ); - for( i = 0; i < sqlite_get_numtuples(res); i++ ) { xmlNode *atmpt_n = NULL; if( sqlite_get_value(res, i, 0) != NULL ) { // Username + if( uname_n == NULL ) { + uname_n = xmlNewChild(root_n, NULL, (xmlChar *) "username", NULL); + assert( uname_n != NULL ); + } atmpt_n = xmlNewChild(uname_n, NULL, (xmlChar *) "attempt", NULL); sqlite_xml_value(atmpt_n, XML_NODE, "username", res, i, 0); } else if( sqlite_get_value(res, i, 1) != NULL ) { // Digest + if( cert_n == NULL ) { + cert_n = xmlNewChild(root_n, NULL, (xmlChar *) "certificate", NULL); + assert( cert_n != NULL ); + } atmpt_n = xmlNewChild(cert_n, NULL, (xmlChar *) "attempt", NULL); sqlite_xml_value(atmpt_n, XML_NODE, "certificate", res, i, 1); } else if( sqlite_get_value(res, i, 2) != NULL ) { // IP address + if( remip_n == NULL ) { + remip_n = xmlNewChild(root_n, NULL, (xmlChar *) "ipaddress", NULL); + assert( remip_n != NULL ); + } atmpt_n = xmlNewChild(remip_n, NULL, (xmlChar *) "attempt", NULL); sqlite_xml_value(atmpt_n, XML_NODE, "ipaddress", res, i, 2); } else { -- cgit