- char *s = NULL;
- int i;
-
- FILE * fp;
- char buf[BUFFER_SIZE];
- char * p;
- const char * filename = NULL;
- char * file_description = NULL;
-#ifdef FEATURE_STATISTICS
- float perc_rej; /* Percentage of http requests rejected */
- int local_urls_read;
- int local_urls_rejected;
-#endif /* ndef FEATURE_STATISTICS */
-
- struct map * exports = default_exports(csp, "show-status");
-
- switch (*(lookup(parameters, "file")))
- {
- case 'p':
- if (csp->actions_list)
- {
- filename = csp->actions_list->filename;
- file_description = "Actions List";
- }
- break;
-
- case 'r':
- if (csp->rlist)
- {
- filename = csp->rlist->filename;
- file_description = "Regex Filter List";
- }
- break;
-
-#ifdef FEATURE_TRUST
- case 't':
- if (csp->tlist)
- {
- filename = csp->tlist->filename;
- file_description = "Trust List";
- }
- break;
-#endif /* def FEATURE_TRUST */
- }
-
- if (NULL != filename)
- {
- map(exports, "file-description", 1, file_description, 1);
- map(exports, "filepath", 1, html_encode(filename), 0);
-
- if ((fp = fopen(filename, "r")) == NULL)
- {
- map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1);
- }
- else
- {
- while (fgets(buf, sizeof(buf), fp))
- {
- p = html_encode(buf);
- if (p)
- {
- s = strsav(s, p);
- freez(p);
- s = strsav(s, "<br>");
- }
- }
- fclose(fp);
- map(exports, "contents", 1, s, 0);
- }
- rsp->body = template_load(csp, "show-status-file");
- template_fill(&rsp->body, exports);
- free_map(exports);
- return(0);
-
- }
-
- map(exports, "redirect-url", 1, REDIRECT_URL, 1);
-
- s = NULL;
- for (i=0; i < Argc; i++)
- {
- s = strsav(s, Argv[i]);
- s = strsav(s, " ");
- }
- map(exports, "invocation", 1, s, 0);
-
- map(exports, "options", 1, csp->config->proxy_args, 1);
- show_defines(exports);
-
-#ifdef FEATURE_STATISTICS
- local_urls_read = urls_read;
- local_urls_rejected = urls_rejected;
-
- /*
- * Need to alter the stats not to include the fetch of this
- * page.
- *
- * Can't do following thread safely! doh!
- *
- * urls_read--;
- * urls_rejected--; * This will be incremented subsequently *
- */
-
- if (local_urls_read == 0)
- {
- map_block_killer(exports, "have-stats");
- }
- else
- {
- map_block_killer(exports, "have-no-stats");
-
- perc_rej = (float)local_urls_rejected * 100.0F /
- (float)local_urls_read;
-
- sprintf(buf, "%d", local_urls_read);
- map(exports, "requests-received", 1, buf, 1);
-
- sprintf(buf, "%d", local_urls_rejected);
- map(exports, "requests-blocked", 1, buf, 1);
-
- sprintf(buf, "%6.2f", perc_rej);
- map(exports, "percent-blocked", 1, buf, 1);
- }
-
-#else /* ndef FEATURE_STATISTICS */
- map_block_killer(exports, "statistics");
-#endif /* ndef FEATURE_STATISTICS */
-
- if (csp->actions_list)
- {
- map(exports, "actions-filename", 1, csp->actions_list->filename, 1);
- }
- else
- {
- map(exports, "actions-filename", 1, "None specified", 1);
- }
-
- if (csp->rlist)
- {
- map(exports, "re-filter-filename", 1, csp->rlist->filename, 1);
- }
- else
- {
- map(exports, "re-filter-filename", 1, "None specified", 1);
- }
-
-#ifdef FEATURE_TRUST
- if (csp->tlist)
- {
- map(exports, "trust-filename", 1, csp->tlist->filename, 1);
- }
- else
- {
- map(exports, "trust-filename", 1, "None specified", 1);
- }
-#else
- map_block_killer(exports, "trust-support");
-#endif /* ndef FEATURE_TRUST */
-
- rsp->body = template_load(csp, "show-status");
- template_fill(&rsp->body, exports);
- free_map(exports);
- return(0);