* 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
#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),
+ "<tr><td>%s</td><td style=\"text-align: right\">%llu</td>\n",
+ encoded_block_reason, count);
+ freez(encoded_block_reason);
+
+ if (!err) err = string_append(&statistics, buf);
+ }
+ last_action = b->action;
+ }
+ }
+
+ return statistics;
+
+}
+
+
/*********************************************************************
*
* Function : get_filter_statistics_table
if (b->type == FT_CONTENT_FILTER)
{
unsigned long long executions;
- unsigned long long pages_modified;
+ unsigned long long response_bodies_modified;
unsigned long long hits;
- get_filter_statistics(b->name, &executions, &pages_modified, &hits);
+ get_filter_statistics(b->name, &executions, &response_bodies_modified, &hits);
snprintf(buf, sizeof(buf),
"<tr><td>%s</td><td style=\"text-align: right\">%llu</td>"
"<td style=\"text-align: right\">%llu</td>"
"<td style=\"text-align: right\">%llu</td><tr>\n",
- b->name, executions, pages_modified, hits);
+ b->name, executions, response_bodies_modified, hits);
if (!err) err = string_append(&statistics, buf);
}
return statistics;
}
-#endif
+#endif /* def FEATURE_EXTENDED_STATISTICS */
/*********************************************************************
#endif /* ndef FEATURE_STATISTICS */
#ifdef FEATURE_EXTENDED_STATISTICS
+ {
+ char *block_reason_statistics = get_block_reason_statistics_table(csp);
+ if (block_reason_statistics != NULL)
+ {
+ if (!err) err = map(exports, "block-reason-statistics", 1, block_reason_statistics, 0);
+ }
+ else
+ {
+ if (!err) err = map_block_killer(exports, "extended-statistics");
+ }
+ }
{
char *filter_statistics = get_filter_statistics_table(csp);
if (filter_statistics != NULL)
else
{
if (!err) err = map(exports, "actions-filenames", 1, "<tr><td>None specified</td></tr>", 1);
+ freez(s);
}
/*
{
if (!err) err = map(exports, "re-filter-filenames", 1, "<tr><td>None specified</td></tr>", 1);
if (!err) err = map_block_killer(exports, "have-filterfile");
+ freez(s);
}
#ifdef FEATURE_TRUST