X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=cgisimple.c;h=4339ecd01199a8baeaf64cca8628c95d2742d6b6;hp=2fcd0022fc8c02448f4ad29d7b2ac49bf3bedc47;hb=57702318b095358ffe8fa3a99ec330d7aed3fca3;hpb=ab082f57780b5acb5b1305d82309a1dea8c026a1;ds=sidebyside diff --git a/cgisimple.c b/cgisimple.c index 2fcd0022..4339ecd0 100644 --- a/cgisimple.c +++ b/cgisimple.c @@ -5,7 +5,7 @@ * Purpose : Simple CGIs to get information about Privoxy's * status. * - * Copyright : Written by and Copyright (C) 2001-2017 the + * Copyright : Written by and Copyright (C) 2001-2020 the * Privoxy team. https://www.privoxy.org/ * * Based on the Internet Junkbuster originally written @@ -1032,6 +1032,76 @@ jb_err cgi_send_user_manual(struct client_state *csp, #ifdef FEATURE_EXTENDED_STATISTICS +/********************************************************************* + * + * Function : get_block_reason_statistics_table + * + * Description : Produces the block reason statistic table content. + * + * Parameters : + * 1 : csp = Current client state (buffers, headers, etc...) + * + * Returns : Pointer to the HTML statistic table content or + * NULL on out of memory + * + *********************************************************************/ +static char *get_block_reason_statistics_table(const struct client_state *csp) +{ + char buf[BUFFER_SIZE]; + char *statistics; + int i; + struct file_list *fl; + jb_err err = JB_ERR_OK; + + statistics = strdup_or_die(""); + + /* Run through all action files. */ + for (i = 0; i < MAX_AF_FILES; i++) + { + struct url_actions *b; + struct action_spec *last_action = NULL; + + if (((fl = csp->actions_list[i]) == NULL) || ((b = fl->f) == NULL)) + { + /* Skip empty files */ + continue; + } + + /* Go through all the actions. */ + for (b = b->next; NULL != b; b = b->next) + { + if (last_action == b->action) + { + continue; + } + if ((b->action->add & ACTION_BLOCK)) + { + unsigned long long count; + const char *block_reason = b->action->string[ACTION_STRING_BLOCK]; + const char *encoded_block_reason = html_encode(block_reason); + + if (encoded_block_reason == NULL) + { + freez(statistics); + return NULL; + } + get_block_reason_count(block_reason, &count); + snprintf(buf, sizeof(buf), + "