This is formgen.c in view mode; [Download] [Up]
/*** analog 1.9beta ***/ /* Please read Readme.html, or http://www.statslab.cam.ac.uk/~sret1/analog/ */ /*** formgen.c; generate a form for the analog form interface ***/ #include "analhea2.h" void genopts(FILE *outf, char name[17], char plural[16], int sortby, char codeletter) { fprintf(outf, "\n<h3>%s options</h3>\n\n", name); fprintf(outf, "Sort the %s \n<select name=%cs size=1>\n", name, codeletter); fprintf(outf, "<option value=2%s>alphabetically (*)\n", (sortby==ALPHABETICAL)?" selected":""); fprintf(outf, "<option value=1%s>by volume of traffic (+)\n", (sortby==BYBYTES)?" selected":""); fprintf(outf, "<option value=0%s>by number of requests (*)\n", (sortby==BYREQUESTS)?" selected":""); fprintf(outf, "</select>\n"); fprintf(outf, "<br>(*) Include all %s with at least\n", plural); fprintf(outf, "<input type=TEXT name=\"%ca\" maxlength=6 size=6> requests\n", codeletter); fprintf(outf, "<b>or</b> the top "); fprintf(outf, "<input type=TEXT name=\"%cb\" maxlength=3 size=3> %s.\n", codeletter, plural); fprintf(outf, "<br>(*) Include all %s with at least\n", plural); fprintf(outf, "<input type=TEXT name=\"%cc\" maxlength=6 size=6> bytes\n", codeletter); fprintf(outf, "transferred <b>or</b> the top "); fprintf(outf, "<input type=TEXT name=\"%cd\" maxlength=3 size=3> %s.\n", codeletter, plural); } void formgen(void) { extern flag xq, mq, Wq, dq, Dq, hq, oq, Sq, iq, rq, Bq, bq, fq, eq, cq; extern char reportorder[]; extern int domsortby, dirsortby, hostsortby, reqsortby, refsortby; extern int browsortby, fullbrowsortby; extern int dirlevel, reqtype, kq; extern char hostname[], hosturl[], logourl[], commandname[]; extern char outfile[]; extern struct timestruct fromtime, totime; char *ro; FILE *outf; if (STREQ(outfile, "stdout")) outf = stdout; else if ((outf = fopen(outfile, "w")) == NULL) { fprintf(stderr, "%s: Error: failed to open output file %s for writing.\n", commandname, outfile); exit(ERR); /* shouldn't get here because also tested at the beginning */ } fprintf(outf, "<html><head>\n"); fprintf(outf, "<title>Analog form interface</title>\n"); fprintf(outf, "</head>\n\n"); fprintf(outf, "<body>\n"); if (hosturl[0] == '-') fprintf(outf, "<h1><img src=\"%s\" alt=\"\"> Analog form interface for %s</h1>\n", logourl, hostname); else fprintf(outf, "<h1><img src=\"%s\" alt=\"\"> Analog form interface for <a HREF=\"%s\">%s</a></h1>\n", logourl, hosturl, hostname); fprintf(outf, "<form action=\""FORMPROG"\" method=\"GET\">\n"); fprintf(outf, "<hr><i>You can set any options you like below. But they should all be set to\n"); fprintf(outf, "sensible default values, so you can ignore any of them too.</i>\n"); fprintf(outf, "<hr>\n<h2>1. Report choices</h2>\n"); fprintf(outf, "<i>See <a href=\"http://www.statslab.cam.ac.uk/~sret1/analog/\">the analog\n"); fprintf(outf, "home page</a> for the meanings of the various reports.</i>\n\n"); fprintf(outf, "<p>\n<h3>Which reports do you want to see?</h3>\n"); fprintf(outf, "<INPUT TYPE=checkbox NAME=\"xq\" VALUE=1%s>General statistics?\n", xq?" checked":""); for (ro = reportorder; *ro != '\0'; ro++) { switch(*ro) { case 'b': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"bq\" VALUE=1%s>Browser summary?\n", bq?" checked":""); break; case 'B': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"Bq\" VALUE=1%s>Browser report?\n", Bq?" checked":""); break; case 'c': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"cq\" VALUE=1%s>Status code report?\n", cq?" checked":""); break; case 'd': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"dq\" VALUE=1%s>Daily summary?\n", dq?" checked":""); break; case 'D': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"Dq\" VALUE=1%s>Daily report? (NB: Can be long)\n", Dq?" checked":""); break; case 'e': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"eq\" VALUE=1%s>Error report?\n", eq?" checked":""); break; case 'f': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"fq\" VALUE=1%s>Referer report?\n", fq?" checked":""); break; /* case 'H', hourly report, deliberately omitted */ case 'h': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"hq\" VALUE=1%s>Hourly summary?\n", hq?" checked":""); break; case 'i': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"iq\" VALUE=1%s>Directory report?\n", iq?" checked":""); break; case 'm': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"mq\" VALUE=1%s>Monthly report?\n", mq?" checked":""); break; case 'o': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"oq\" VALUE=1%s>Domain report?\n", oq?" checked":""); break; case 'r': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"rq\" VALUE=1%s>Request report?\n", rq?" checked":""); break; case 'S': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"Sq\" VALUE=1%s>Host report? (NB: Can be long)\n", Sq?" checked":""); break; case 'W': fprintf(outf, "<BR><INPUT TYPE=checkbox NAME=\"Wq\" VALUE=1%s>Weekly report?\n", Wq?" checked":""); break; } } fprintf(outf, "<p><i>You can now fill in the options below for individual reports.\n"); fprintf(outf, "You can fill in the </i>(+)<i> or </i>(*)<i> in each section according to which sort method you select.\n"); fprintf(outf, "You can use <input type=TEXT name=\"vo\" maxlength=4 size=4 value=\"10M\"> bytes to mean 10 Megabytes etc.</i>\n"); fprintf(outf, "<hr>\n<h2>2. Detailed report options</h2>\n"); for (ro = reportorder; *ro != '\0'; ro++) { switch(*ro) { case 'b': genopts(outf, "Browser summary", "browsers", browsortby, 'b'); break; case 'B': genopts(outf, "Browser report", "browsers", fullbrowsortby, 'B'); break; case 'f': genopts(outf, "Referer report", "referring URLs", refsortby, 'f'); break; case 'i': genopts(outf, "Directory report", "directories", dirsortby, 'i'); fprintf(outf, "<br>Print directories to depth "); fprintf(outf, "<input type=text name=\"ie\" maxlength=1 size=1 value=%d>\n", dirlevel); break; case 'o': genopts(outf, "Domain report", "domains", domsortby, 'o'); break; case 'r': genopts(outf, "Request report", "requests", reqsortby, 'r'); fprintf(outf, "<br>Show\n"); fprintf(outf, "<select name=\"rt\" size=1>\n"); fprintf(outf, "<option value=\"f\"%s>all files\n", reqtype == ALL?" selected":""); fprintf(outf, "<option value=\"p\"%s>pages only\n", reqtype == PAGES?" selected":""); fprintf(outf, "</select>\n; include links to\n"); fprintf(outf, "<select name=\"rl\" size=1>\n"); fprintf(outf, "<option value=\"f\"%s>all files\n", kq == ALL?" selected":""); fprintf(outf, "<option value=\"p\"%s>pages only\n", kq == ON?" selected":""); fprintf(outf, "<option value=\"n\"%s>no files\n", kq == OFF?" selected":""); fprintf(outf, "</select>\n"); break; case 'S': genopts(outf, "Host report", "hosts", hostsortby, 'S'); break; } } fprintf(outf, "<hr>\n\n<h2>3. Analysing only part of the logfile</h2>\n"); fprintf(outf, "<b>Only certain dates</b>\n"); fprintf(outf, "<br>You can analyse only the requests from certain dates.\n"); fprintf(outf, "Enter the range of dates below in the from <i>yymmdd</i>;\n"); fprintf(outf, "e.g., 950701 for 1st July 1995 (or fill in just one box\n"); fprintf(outf, "to limit the range of dates on just one side)."); fprintf(outf, "<br>From <input type=TEXT name=\"fr\" maxlength=10 size=6"); if (fromtime.code > -INFINITY) fprintf(outf, " value=\"%02d%02d%02d\"", fromtime.year % 100, fromtime.monthno + 1, fromtime.date); fprintf(outf, ">\nto <input type=TEXT name=\"to\" maxlength=10 size=6"); if (totime.code < INFINITY) fprintf(outf, " value=\"%02d%02d%02d\"", totime.year % 100, totime.monthno + 1, totime.date); fprintf(outf, ">\n\n"); fprintf(outf, "<p><b>Only certain files</b>\n"); fprintf(outf, "<br>Only look at the following files (list, separated by commas; can contain wild character *)\n"); fprintf(outf, "<br><input type=TEXT name=\"fy\" size=60>\n"); fprintf(outf, "<br>Ignore the following files\n"); fprintf(outf, "<br><input type=TEXT name=\"fi\" size=60>\n"); fprintf(outf, "<hr><h2>4. Layout</h2>\n"); fprintf(outf, "<b>Your organisation's name</b> (for the title of the page)\n"); fprintf(outf, "<input type=TEXT name=\"or\" value=\"%s\" size=60>\n", hostname); fprintf(outf, "<p><b>Your organisation's home page</b> (leave blank for none)\n"); fprintf(outf, "<br>URL: <input type=TEXT name=\"ho\" value=\"%s\" size=60>\n", hosturl); fprintf(outf, "<hr><input type=hidden name=\"TZ\" value=\"%s\">\n", getenv("TZ")!=NULL?getenv("TZ"):""); /* gets it twice, but easy */ fprintf(outf, "<input type=submit value=\"Produce statistics\"> "); fprintf(outf, "<input type=reset value=\"Reset form\">\n"); fprintf(outf, "</form>\n"); fprintf(outf, "<P> <A HREF=\"http://www.webtechs.com/html-val-svc/\">\n"); fprintf(outf, "<IMG SRC=\"http://www.webtechs.com/html-val-svc/images/valid_html.gif\" ALT=\"HTML 2.0 Compliant!\"></A>\n"); fprintf(outf, "</body></html>\n"); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.