Monday, November 08, 2010 at 12:05 AM.

system.verbs.builtins.radio.html.viewWebServerLog

on viewWebServerLog () {
	<<Changes:
		<<1/6/02; 4:28:23 AM by JES
			<<Added table css classes.
		<<1/25/01; 6:36:14 PM by DW
			<<Created.
		<<2/12/01; 3:54:56 PM by PBS
			<<Added column headings, to be consistent with the Events page. Headings are: Time, IP address, Secs, Size, Type, and Path.
		<<2/15/01; 4:07:26 PM by PBS
			<<Prevent macros.
		<<2/20/01; 4:08:42 PM by PBS
			<<Don't untaint text here -- it's now untainted before it's stored in the log guest database.
		<<2/24/01; 5:51:57 PM by PBS
			<<Help link.
		<<2/25/01; 8:34:32 PM by JES
			<<If the uri ends with a '/', make the link text "/", instead of the empty string.
	local (pta = html.getpagetableaddress ());
	pta^.title = radio.string.getlocalizedstring ("webServerLog.title");
	local (adrlog = log.getGuestSubTable ("webServer"));
	local (maxitems = 100);
	local (htmltext = "\r", indentlevel = 0);
	on add (s) {
		htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n"};
	bundle { //show the intro
		local (t);
		new (tabletype, @t);
		t.maxitems = maxitems;
		add ("<p>" + radio.string.getlocalizedstring ("webServerLog.intro", @t) + " " + radio.userInterface.helpLink ("The Web Server Log page") + "</p>")};
	add ("<table class=\"dwsFrameTable\" cellspacing=\"0\" cellpadding=\"0\"><tr bgcolor=\"" + radio.data.htmlColors.framecolor + "\"><td>"); indentlevel++;
	add ("<table class=\"dwsTable\" border=\"0\" cellspacing=\"1\" cellpadding=\"5\">"); indentlevel++;
	add ("<tr bgcolor=\"" + radio.data.htmlColors.cellbgcolor + "\"><td class=\"dwsTableCell\"><b>Time</b></td><td class=\"dwsTableCell\"><b>IP address</b></td><td class=\"dwsTableCell\" align=\"right\"><b>Secs</b></td><td class=\"dwsTableCell\" align=\"right\"><b>Size</b></td><td class=\"dwsTableCell\"><b>Type</b></td><td class=\"dwsTableCell\"><b>Path</b></td></tr>");
	local (adrhour, adritem, i, j, fname, ct = 0);
	for i = sizeof (adrlog^) downto 1 {
		adrhour = @adrlog^ [i];
		for j = sizeof (adrhour^) downto 1 {
			adritem = @adrhour^ [j];
			add ("<tr bgcolor=\"" + radio.data.htmlColors.cellbgcolor + "\">"); indentlevel++;
			add ("<td class=\"dwsTableCell\">" + date.timestring (timeCreated (adritem)) + "</td>");
			add ("<td class=\"dwsTableCell\">" + adritem^.client + "</td>");
			<<add ("<td>" + adritem^.code + "</td>")
			add ("<td class=\"dwsTableCell\" align=\"right\">" + adritem^.secs + "</td>");
			add ("<td class=\"dwsTableCell\" align=\"right\">" + string.megabytestring (adritem^.size) + "</td>");
			add ("<td class=\"dwsTableCell\">" + adritem^.type + "</td>");
			if adritem^.uri endsWith "/" {
				fname = "/"}
			else {
				fname = string.nthfield (adritem^.uri, "/", string.countfields (adritem^.uri, "/"))};
			add ("<td class=\"dwsTableCell\">" + "<a href=\"" + adritem^.uri + "\"><font size=\"-1\">" + fname + "</font></a></td>");
			add ("</tr>"); indentlevel--;
			if ++ct > maxitems {
				break}}};
	add ("</table>"); indentlevel--;
	add ("</td></tr></table>"); indentlevel--;
	<<add ("<a name=\"helpText\"></a>" + radio.string.getlocalizedstring ("webServerLog.helpText"))
	return (htmltext)};
bundle { //test code
	local (pagetable);
	new (tabletype, @pagetable);
	html.setpagetableaddress (@pagetable);
	viewwebserverlog ()}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.