+#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
+ *
+ * Description : Produces the filter 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_filter_statistics_table(const struct client_state *csp)
+{
+ char buf[BUFFER_SIZE];
+ char *statistics;
+ int i;
+ struct file_list *fl;
+ struct re_filterfile_spec *b;
+ jb_err err = JB_ERR_OK;
+
+ statistics = strdup_or_die("");
+
+ for (i = 0; i < MAX_AF_FILES; i++)
+ {
+ fl = csp->rlist[i];
+ if ((NULL == fl) || (NULL == fl->f))
+ {
+ /*
+ * Either there are no filter files left or this
+ * filter file just contains no valid filters.
+ *
+ * Continue to be sure we don't miss valid filter
+ * files that are chained after empty or invalid ones.
+ */
+ continue;
+ }
+
+ for (b = fl->f; b != NULL; b = b->next)
+ {
+ if (b->type == FT_CONTENT_FILTER)
+ {
+ unsigned long long executions;
+ unsigned long long pages_modified;
+ unsigned long long hits;
+
+ get_filter_statistics(b->name, &executions, &pages_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);
+
+ if (!err) err = string_append(&statistics, buf);
+ }
+ }
+ }
+
+ return statistics;
+
+}
+#endif /* def FEATURE_EXTENDED_STATISTICS */
+
+