[freenet-cvs] r11225 - trunk/freenet/src/freenet/clients/http

toad at freenetproject.org toad at freenetproject.org
Mon Dec 4 16:15:21 UTC 2006


Author: toad
Date: 2006-12-04 16:15:14 +0000 (Mon, 04 Dec 2006)
New Revision: 11225

Modified:
   trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
   trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
   trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
   trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java
   trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java
   trunk/freenet/src/freenet/clients/http/PageMaker.java
   trunk/freenet/src/freenet/clients/http/PluginToadlet.java
   trunk/freenet/src/freenet/clients/http/PproxyToadlet.java
   trunk/freenet/src/freenet/clients/http/QueueToadlet.java
   trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
   trunk/freenet/src/freenet/clients/http/Spider.java
   trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
   trunk/freenet/src/freenet/clients/http/ToadletContainer.java
   trunk/freenet/src/freenet/clients/http/ToadletContext.java
   trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
   trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
Log:
Factor out creation of a form tag with correct parameters, and inclusion of the formPassword, into a method on ToadletContext.
Always include accept-charset=UTF-8, enctype=multipart/form-data.
This and 11222 fix #889, as well as saving some code.

Modified: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -121,8 +121,7 @@
 		HTMLNode infobox = contentNode.addChild("div", "class", "infobox infobox-normal");
 		infobox.addChild("div", "class", "infobox-header", "Freenet node configuration");
 		HTMLNode configNode = infobox.addChild("div", "class", "infobox-content");
-		HTMLNode formNode = configNode.addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
-		formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+		HTMLNode formNode = ctx.addFormChild(configNode, ".", "configForm");
 		
 		for(int i=0; i<sc.length;i++){
 			short displayedConfigElements = 0;

Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -342,8 +342,7 @@
 				peerTableInfoboxContent.addChild("a", "href", "/", "node homepage");
 				peerTableInfoboxContent.addChild("#", " and read the top infobox to see how it is done.");
 			} else {
-				HTMLNode peerForm = peerTableInfoboxContent.addChild("form", new String[] { "action", "method", "enctype", "id", "name" }, new String[] { ".", "post", "multipart/form-data", "peersForm", "peersForm" });
-				peerForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+				HTMLNode peerForm = ctx.addFormChild(peerTableInfoboxContent, ".", "peersForm");
 				HTMLNode peerTable = peerForm.addChild("table", "class", "darknet_connections");
 				HTMLNode peerTableHeaderRow = peerTable.addChild("tr");
 				peerTableHeaderRow.addChild("th");
@@ -523,8 +522,7 @@
 		HTMLNode peerAdditionInfobox = contentNode.addChild("div", "class", "infobox infobox-normal");
 		peerAdditionInfobox.addChild("div", "class", "infobox-header", "Add another peer");
 		HTMLNode peerAdditionContent = peerAdditionInfobox.addChild("div", "class", "infobox-content");
-		HTMLNode peerAdditionForm = peerAdditionContent.addChild("form", new String[] { "action", "method", "enctype" }, new String[] { ".", "post", "multipart/form-data" });
-		peerAdditionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+		HTMLNode peerAdditionForm = ctx.addFormChild(peerAdditionContent, ".", "addPeerForm");
 		peerAdditionForm.addChild("#", "Paste the reference here:");
 		peerAdditionForm.addChild("br");
 		peerAdditionForm.addChild("textarea", new String[] { "id", "name", "rows", "cols" }, new String[] { "reftext", "ref", "8", "74" });
@@ -697,7 +695,7 @@
 					}
 				}
 			}
-			String resultString = N2NTMToadlet.createN2NTMSendForm( pageNode, contentNode, ctx, peers, core.formPassword);
+			String resultString = N2NTMToadlet.createN2NTMSendForm( pageNode, contentNode, ctx, peers);
 			if(resultString != null) {  // was there an error in createN2NTMSendForm()?
 				this.writeReply(ctx, 200, "text/html", "OK", resultString);
 				return;
@@ -867,9 +865,8 @@
 						HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-warning", "Node removal"));
 						HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
 						content.addChild("p").addChild("#", "Are you sure you wish to remove "+peerNodes[i].getName()+" ? Before it has at least one week downtime, it's not recommended to do so, as it may be down only temporarily, and many users cannot run their nodes 24x7.");
-						HTMLNode removeForm = content.addChild("p").addChild("form", new String[] { "action", "method" }, new String[] { "/darknet/", "post" });
+						HTMLNode removeForm = ctx.addFormChild(content, "/darknet/", "removeConfirmForm");
 						removeForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "node_"+peerNodes[i].hashCode(), "remove" });
-						removeForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 						removeForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "cancel", "Cancel" });
 						removeForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "remove", "Remove it!" });
 						removeForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "forceit", "Force" });

Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -391,11 +391,10 @@
 				optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "max-size", String.valueOf(e.expectedSize == -1 ? Long.MAX_VALUE : e.expectedSize*2) });
 				optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "fetch", "Fetch anyway and display file in browser" });
 				option = optionList.addChild("li");
-				optionForm = option.addChild("form", new String[] { "action", "method" }, new String[] { "/queue/", "post" });
+				optionForm = ctx.addFormChild(option, "/queue/", "tooBigQueueForm");
 				optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "key", key.toString(false) });
 				optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "return-type", "disk" });
 				optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "persistence", "forever" });
-				optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 				if (mime != null) {
 					optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "type", mime });
 				}

Modified: trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -115,8 +115,7 @@
 				} else {
 					if (currentFile.canRead()) {
 						HTMLNode cellNode = fileRow.addChild("td");
-						HTMLNode formNode = cellNode.addChild("form", new String[] { "action", "method", "accept-charset" }, new String[] { "/queue/", "post", "utf-8" });
-						formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+						HTMLNode formNode = toadletContext.addFormChild(cellNode, "/queue/", "insertLocalFileForm"); 
 						formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "filename", currentFile.getAbsolutePath() });
 						formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "insert-local-file", "Insert" });
 						fileRow.addChild("td", currentFile.getName());

Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -75,7 +75,7 @@
 		  }
 			HashMap peers = new HashMap();
 			peers.put( input_hashcode_string, peernode_name );
-			String resultString = createN2NTMSendForm( pageNode, contentNode, ctx, peers, core.formPassword);
+			String resultString = createN2NTMSendForm( pageNode, contentNode, ctx, peers);
 			if(resultString != null) {  // was there an error in createN2NTMSendForm()?
 				this.writeReply(ctx, 200, "text/html", "OK", resultString);
 				return;
@@ -198,7 +198,7 @@
 	  ctx.sendReplyHeaders(302, "Found", headers, null, 0);
 	}
 	    
-	public static String createN2NTMSendForm(HTMLNode pageNode, HTMLNode contentNode, ToadletContext ctx, HashMap peers, String formPassword) throws ToadletContextClosedException, IOException {
+	public static String createN2NTMSendForm(HTMLNode pageNode, HTMLNode contentNode, ToadletContext ctx, HashMap peers) throws ToadletContextClosedException, IOException {
 		if(contentNode == null) {
 			contentNode.addChild(createPeerInfobox("infobox-error", "Internal error", "Internal error: N2NTMToadlet.createN2NTMSendForm() not passed a valid contentNode."));
 			StringBuffer pageBuffer = new StringBuffer();
@@ -216,8 +216,7 @@
 			messageTargetList.addChild("li", peer_name);
 		}
 		HTMLNode infoboxContent = infobox.addChild("div", "class", "infobox-content");
-		HTMLNode messageForm = infoboxContent.addChild("form", new String[] { "action", "method" }, new String[] { "/send_n2ntm/", "post" });
-		messageForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", formPassword });
+		HTMLNode messageForm = ctx.addFormChild(infoboxContent, "/send_n2ntm/", "sendN2NTMForm");
 		// Iterate peers
 		for (Iterator it = peers.keySet().iterator(); it.hasNext(); ) {
 			String peerNodeHash = (String) it.next();

Modified: trunk/freenet/src/freenet/clients/http/PageMaker.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PageMaker.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/PageMaker.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -139,10 +139,6 @@
 		return infobox;
 	}
 	
-	public HTMLNode createFormPasswordInput(String formPassword) {
-		return new HTMLNode("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", formPassword });
-	}
-	
 	/**
 	 * Returns an {@link ArrayList} containing the names of all available
 	 * themes. If freenet was started from a JAR file the list is cached

Modified: trunk/freenet/src/freenet/clients/http/PluginToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PluginToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/PluginToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -218,19 +218,17 @@
 			} else {
 				tableRow.addChild("td");
 			}
-			HTMLNode reloadForm = tableRow.addChild("td").addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
+			HTMLNode reloadForm = context.addFormChild(tableRow, ".", "pluginReloadForm"); 
 			reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "action", "reload" });
 			reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "pluginName", internalName });
 			reloadForm.addChild("input", new String[] { "type", "value" }, new String[] { "submit", "Reload" });
-			reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
-			HTMLNode unloadForm = tableRow.addChild("td").addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
+			HTMLNode unloadForm = context.addFormChild(tableRow, ".", "pluginUnloadForm");
 			unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "action", "unload" });
 			unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "pluginName", internalName });
 			unloadForm.addChild("input", new String[] { "type", "value" }, new String[] { "submit", "Unload" });
-			unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 		}
 
-		contentNode.addChild(createAddPluginBox());
+		contentNode.addChild(createAddPluginBox(context));
 
 		StringBuffer pageBuffer = new StringBuffer();
 		pageNode.generate(pageBuffer);
@@ -273,12 +271,11 @@
 	 * @param outputBuffer
 	 *            The StringBuffer to append the HTML code to
 	 */
-	private HTMLNode createAddPluginBox() {
+	private HTMLNode createAddPluginBox(ToadletContext ctx) {
 		HTMLNode addPluginBox = new HTMLNode("div", "class", "infobox");
 		addPluginBox.addChild("div", "class", "infobox-header", "Add a plugin");
-		HTMLNode addForm = addPluginBox.addChild("div", "class", "infobox-content").addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
+		HTMLNode addForm = ctx.addFormChild(addPluginBox.addChild("div", "class", "infobox-content"), ".", "addPluginBox");
 		addForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "action", "add" });
-		addForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 		addForm.addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "pluginName", "", "40" });
 		addForm.addChild("input", new String[] { "type", "value" }, new String[] { "submit", "Load plugin" });
 		return addPluginBox;

Modified: trunk/freenet/src/freenet/clients/http/PproxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PproxyToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/PproxyToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -78,8 +78,8 @@
 			infobox.addChild("div", "class", "infobox-header", "Unload plugin?");
 			HTMLNode infoboxContent = infobox.addChild("div", "class", "infobox-content");
 			infoboxContent.addChild("#", "Are you sure you wish to unload " + request.getPartAsString("unload", MAX_PLUGIN_NAME_LENGTH) + '?');
-			HTMLNode unloadForm = infoboxContent.addChild("form", new String[] { "action", "method" }, new String[] { "/plugins/", "post" });
-			unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+			HTMLNode unloadForm = 
+				ctx.addFormChild(infoboxContent, "/plugins/", "unloadPluginConfirmForm");
 			unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "cancel", "Cancel" });
 			unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "unloadconfirm", request.getPartAsString("unload", MAX_PLUGIN_NAME_LENGTH) });
 			unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "confirm", "Unload" });
@@ -202,19 +202,16 @@
 						visitForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 						visitForm.addChild("input", new String[] { "type", "value" }, new String[] { "submit", "Visit" });
 					}
-					HTMLNode unloadForm = actionCell.addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
-					unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+					HTMLNode unloadForm = ctx.addFormChild(actionCell, ".", "unloadPluginForm");
 					unloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "unload", pi.getThreadName() });
 					unloadForm.addChild("input", new String[] { "type", "value" }, new String[] { "submit", "Unload" });
-					HTMLNode reloadForm = actionCell.addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
-					reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+					HTMLNode reloadForm = ctx.addFormChild(actionCell, ".", "reloadPluginForm");
 					reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "reload", pi.getThreadName() });
 					reloadForm.addChild("input", new String[] { "type", "value" }, new String[] { "submit", "Reload" });
 				}
 			}
 			
-			HTMLNode addForm = infoboxContent.addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
-			addForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+			HTMLNode addForm = ctx.addFormChild(infoboxContent, ".", "addPluginForm");
 			HTMLNode loadDiv = addForm.addChild("div");
 			loadDiv.addChild("#", "Load plugin: ");
 			loadDiv.addChild("input", new String[] { "type", "name", "size" }, new String[] { "text", "load", "40" });

Modified: trunk/freenet/src/freenet/clients/http/QueueToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/QueueToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/QueueToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -78,16 +78,17 @@
 				return;
 			}			
 			
+			boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+			
 			String pass = request.getPartAsString("formPassword", 32);
 			if ((pass.length() == 0) || !pass.equals(core.formPassword)) {
 				MultiValueTable headers = new MultiValueTable();
 				headers.put("Location", "/queue/");
 				ctx.sendReplyHeaders(302, "Found", headers, null, 0);
+				if(logMINOR) Logger.minor(this, "No formPassword: "+pass);
 				return;
 			}
 
-			boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
-			
 			if(request.isPartSet("remove_request") && (request.getPartAsString("remove_request", 32).length() > 0)) {
 				String identifier = request.getPartAsString("identifier", MAX_IDENTIFIER_LENGTH);
 				if(logMINOR) Logger.minor(this, "Removing "+identifier);
@@ -247,8 +248,7 @@
 									HTMLNode alertContent = ctx.getPageMaker().getContentNode(alertNode);
 									alertContent.addChild("#", "The file you want to download is currently not filtered by Freenet\u2019s content filter! That means that your anonymity can be compromised by opening the file!");
 									HTMLNode optionListNode = alertContent.addChild("ul");
-									HTMLNode optionForm = optionListNode.addChild("li").addChild("form", new String[] { "action", "method", "enctype", "encoding" }, new String[] { "/queue/", "post", "UTF-8", "multipart/form-data" });
-									optionForm.addChild(ctx.getPageMaker().createFormPasswordInput(core.formPassword));
+									HTMLNode optionForm = ctx.addFormChild(optionListNode, "/queue/", "queueDownloadNotFilteredConfirmForm");
 									optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "identifier", identifier });
 									optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "forceDownload", String.valueOf(System.currentTimeMillis()) });
 									optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "get", "Download anyway" });
@@ -348,7 +348,7 @@
 			HTMLNode infobox = contentNode.addChild(pageMaker.getInfobox("infobox-information", "Global queue is empty"));
 			HTMLNode infoboxContent = pageMaker.getContentNode(infobox);
 			infoboxContent.addChild("#", "There is no task queued on the global queue at the moment.");
-			contentNode.addChild(createInsertBox(pageMaker));
+			contentNode.addChild(createInsertBox(pageMaker, ctx));
 			writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
 			return;
 		}
@@ -423,7 +423,7 @@
 		/* add alert summary box */
 		contentNode.addChild(core.alerts.createSummary());
 		/* add file insert box */
-		contentNode.addChild(createInsertBox(pageMaker));
+		contentNode.addChild(createInsertBox(pageMaker, ctx));
 
 		/* navigation bar */
 		HTMLNode navigationBar = pageMaker.getInfobox("navbar", "Request Navigation");
@@ -484,7 +484,7 @@
 		}
 
 		if (reqs.length > 1 && SimpleToadletServer.isPanicButtonToBeShown) {
-			contentNode.addChild(createPanicBox(pageMaker));
+			contentNode.addChild(createPanicBox(pageMaker, ctx));
 		}
 
 		boolean advancedEnabled = core.isAdvancedDarknetEnabled();
@@ -494,9 +494,9 @@
 			HTMLNode completedDownloadsTempInfobox = contentNode.addChild(pageMaker.getInfobox("completed_requests", "Completed: Downloads to temporary directory (" + completedDownloadToTemp.size() + ')'));
 			HTMLNode completedDownloadsToTempContent = pageMaker.getContentNode(completedDownloadsTempInfobox);
 			if (advancedEnabled) {
-				completedDownloadsToTempContent.addChild(createRequestTable(pageMaker, completedDownloadToTemp, new int[] { LIST_IDENTIFIER, LIST_SIZE, LIST_MIME_TYPE, LIST_DOWNLOAD, LIST_PERSISTENCE, LIST_KEY }));
+				completedDownloadsToTempContent.addChild(createRequestTable(pageMaker, ctx, completedDownloadToTemp, new int[] { LIST_IDENTIFIER, LIST_SIZE, LIST_MIME_TYPE, LIST_DOWNLOAD, LIST_PERSISTENCE, LIST_KEY }));
 			} else {
-				completedDownloadsToTempContent.addChild(createRequestTable(pageMaker, completedDownloadToTemp, new int[] { LIST_SIZE, LIST_MIME_TYPE, LIST_DOWNLOAD, LIST_PERSISTENCE, LIST_KEY }));
+				completedDownloadsToTempContent.addChild(createRequestTable(pageMaker, ctx, completedDownloadToTemp, new int[] { LIST_SIZE, LIST_MIME_TYPE, LIST_DOWNLOAD, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 		
@@ -505,9 +505,9 @@
 			HTMLNode completedToDiskInfobox = contentNode.addChild(pageMaker.getInfobox("completed_requests", "Completed: Downloads to download directory (" + completedDownloadToDisk.size() + ')'));
 			HTMLNode completedToDiskInfoboxContent = pageMaker.getContentNode(completedToDiskInfobox);
 			if (advancedEnabled) {
-				completedToDiskInfoboxContent.addChild(createRequestTable(pageMaker, completedDownloadToDisk, new int[] { LIST_IDENTIFIER, LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_DOWNLOAD, LIST_PERSISTENCE, LIST_KEY }));
+				completedToDiskInfoboxContent.addChild(createRequestTable(pageMaker, ctx, completedDownloadToDisk, new int[] { LIST_IDENTIFIER, LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_DOWNLOAD, LIST_PERSISTENCE, LIST_KEY }));
 			} else {
-				completedToDiskInfoboxContent.addChild(createRequestTable(pageMaker, completedDownloadToDisk, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_DOWNLOAD, LIST_PERSISTENCE, LIST_KEY }));
+				completedToDiskInfoboxContent.addChild(createRequestTable(pageMaker, ctx, completedDownloadToDisk, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_DOWNLOAD, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 
@@ -516,9 +516,9 @@
 			HTMLNode completedUploadInfobox = contentNode.addChild(pageMaker.getInfobox("completed_requests", "Completed: Uploads (" + completedUpload.size() + ')'));
 			HTMLNode completedUploadInfoboxContent = pageMaker.getContentNode(completedUploadInfobox);
 			if (advancedEnabled) {
-				completedUploadInfoboxContent.addChild(createRequestTable(pageMaker, completedUpload, new int[] { LIST_IDENTIFIER, LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PERSISTENCE, LIST_KEY }));
+				completedUploadInfoboxContent.addChild(createRequestTable(pageMaker, ctx, completedUpload, new int[] { LIST_IDENTIFIER, LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PERSISTENCE, LIST_KEY }));
 			} else  {
-				completedUploadInfoboxContent.addChild(createRequestTable(pageMaker, completedUpload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PERSISTENCE, LIST_KEY }));
+				completedUploadInfoboxContent.addChild(createRequestTable(pageMaker, ctx, completedUpload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 		
@@ -527,9 +527,9 @@
 			HTMLNode completedUploadDirInfobox = contentNode.addChild(pageMaker.getInfobox("completed_requests", "Completed: Directory Uploads (" + completedDirUpload.size() + ')'));
 			HTMLNode completedUploadDirContent = pageMaker.getContentNode(completedUploadDirInfobox);
 			if (advancedEnabled) {
-				completedUploadDirContent.addChild(createRequestTable(pageMaker, completedDirUpload, new int[] { LIST_IDENTIFIER, LIST_FILES, LIST_TOTAL_SIZE, LIST_PERSISTENCE, LIST_KEY }));
+				completedUploadDirContent.addChild(createRequestTable(pageMaker, ctx, completedDirUpload, new int[] { LIST_IDENTIFIER, LIST_FILES, LIST_TOTAL_SIZE, LIST_PERSISTENCE, LIST_KEY }));
 			} else {
-				completedUploadDirContent.addChild(createRequestTable(pageMaker, completedDirUpload, new int[] { LIST_FILES, LIST_TOTAL_SIZE, LIST_PERSISTENCE, LIST_KEY }));
+				completedUploadDirContent.addChild(createRequestTable(pageMaker, ctx, completedDirUpload, new int[] { LIST_FILES, LIST_TOTAL_SIZE, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 				
@@ -538,9 +538,9 @@
 			HTMLNode failedInfobox = contentNode.addChild(pageMaker.getInfobox("failed_requests", "Failed: Downloads (" + failedDownload.size() + ')'));
 			HTMLNode failedContent = pageMaker.getContentNode(failedInfobox);
 			if (advancedEnabled) {
-				failedContent.addChild(createRequestTable(pageMaker, failedDownload, new int[] { LIST_IDENTIFIER, LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
+				failedContent.addChild(createRequestTable(pageMaker, ctx, failedDownload, new int[] { LIST_IDENTIFIER, LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
 			} else {
-				failedContent.addChild(createRequestTable(pageMaker, failedDownload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
+				failedContent.addChild(createRequestTable(pageMaker, ctx, failedDownload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 		
@@ -549,9 +549,9 @@
 			HTMLNode failedInfobox = contentNode.addChild(pageMaker.getInfobox("failed_requests", "Failed: Uploads (" + failedUpload.size() + ')'));
 			HTMLNode failedContent = pageMaker.getContentNode(failedInfobox);
 			if (advancedEnabled) {
-				failedContent.addChild(createRequestTable(pageMaker, failedUpload, new int[] { LIST_IDENTIFIER, LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
+				failedContent.addChild(createRequestTable(pageMaker, ctx, failedUpload, new int[] { LIST_IDENTIFIER, LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
 			} else {
-				failedContent.addChild(createRequestTable(pageMaker, failedUpload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
+				failedContent.addChild(createRequestTable(pageMaker, ctx, failedUpload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 		
@@ -560,9 +560,9 @@
 			HTMLNode failedInfobox = contentNode.addChild(pageMaker.getInfobox("failed_requests", "Failed: Directory Uploads (" + failedDirUpload.size() + ')'));
 			HTMLNode failedContent = pageMaker.getContentNode(failedInfobox);
 			if (advancedEnabled) {
-				failedContent.addChild(createRequestTable(pageMaker, failedDirUpload, new int[] { LIST_IDENTIFIER, LIST_FILES, LIST_TOTAL_SIZE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
+				failedContent.addChild(createRequestTable(pageMaker, ctx, failedDirUpload, new int[] { LIST_IDENTIFIER, LIST_FILES, LIST_TOTAL_SIZE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
 			} else {
-				failedContent.addChild(createRequestTable(pageMaker, failedDirUpload, new int[] { LIST_FILES, LIST_TOTAL_SIZE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
+				failedContent.addChild(createRequestTable(pageMaker, ctx, failedDirUpload, new int[] { LIST_FILES, LIST_TOTAL_SIZE, LIST_PROGRESS, LIST_REASON, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 		
@@ -571,9 +571,9 @@
 			HTMLNode uncompletedInfobox = contentNode.addChild(pageMaker.getInfobox("requests_in_progress", "In Progress: Downloads (" + uncompletedDownload.size() + ')'));
 			HTMLNode uncompletedContent = pageMaker.getContentNode(uncompletedInfobox);
 			if (advancedEnabled) {
-				uncompletedContent.addChild(createRequestTable(pageMaker, uncompletedDownload, new int[] { LIST_IDENTIFIER, LIST_PRIORITY, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_FILENAME, LIST_KEY }));
+				uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedDownload, new int[] { LIST_IDENTIFIER, LIST_PRIORITY, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_FILENAME, LIST_KEY }));
 			} else {
-				uncompletedContent.addChild(createRequestTable(pageMaker, uncompletedDownload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_KEY }));
+				uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedDownload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 		
@@ -582,9 +582,9 @@
 			HTMLNode uncompletedInfobox = contentNode.addChild(pageMaker.getInfobox("requests_in_progress", "In Progress: Uploads (" + uncompletedUpload.size() + ')'));
 			HTMLNode uncompletedContent = pageMaker.getContentNode(uncompletedInfobox);
 			if (advancedEnabled) {
-				uncompletedContent.addChild(createRequestTable(pageMaker, uncompletedUpload, new int[] { LIST_IDENTIFIER, LIST_PRIORITY, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_FILENAME, LIST_KEY }));
+				uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedUpload, new int[] { LIST_IDENTIFIER, LIST_PRIORITY, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_FILENAME, LIST_KEY }));
 			} else {
-				uncompletedContent.addChild(createRequestTable(pageMaker, uncompletedUpload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_KEY }));
+				uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedUpload, new int[] { LIST_FILENAME, LIST_SIZE, LIST_MIME_TYPE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 		
@@ -593,9 +593,9 @@
 			HTMLNode uncompletedInfobox = contentNode.addChild(pageMaker.getInfobox("requests_in_progress", "In Progress: DirUploads (" + uncompletedDirUpload.size() + ')'));
 			HTMLNode uncompletedContent = pageMaker.getContentNode(uncompletedInfobox);
 			if (advancedEnabled) {
-				uncompletedContent.addChild(createRequestTable(pageMaker, uncompletedDirUpload, new int[] { LIST_IDENTIFIER, LIST_FILES, LIST_PRIORITY, LIST_TOTAL_SIZE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_KEY }));
+				uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedDirUpload, new int[] { LIST_IDENTIFIER, LIST_FILES, LIST_PRIORITY, LIST_TOTAL_SIZE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_KEY }));
 			} else {
-				uncompletedContent.addChild(createRequestTable(pageMaker, uncompletedDirUpload, new int[] { LIST_FILES, LIST_TOTAL_SIZE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_KEY }));
+				uncompletedContent.addChild(createRequestTable(pageMaker, ctx, uncompletedDirUpload, new int[] { LIST_FILES, LIST_TOTAL_SIZE, LIST_PROGRESS, LIST_PERSISTENCE, LIST_KEY }));
 			}
 		}
 		
@@ -670,10 +670,9 @@
 		return filenameCell;
 	}
 
-	private HTMLNode createPriorityCell(PageMaker pageMaker, String identifier, short priorityClass) {
+	private HTMLNode createPriorityCell(PageMaker pageMaker, String identifier, short priorityClass, ToadletContext ctx) {
 		HTMLNode priorityCell = new HTMLNode("td", "class", "request-priority nowrap");
-		HTMLNode priorityForm = priorityCell.addChild("form", new String[] { "action", "method", "enctype", "encoding" }, new String[] { "/queue/", "post", "UTF-8", "multipart/form-data" });
-		priorityForm.addChild(pageMaker.createFormPasswordInput(core.formPassword));
+		HTMLNode priorityForm = ctx.addFormChild(priorityCell, "/queue/", "queueChangePriorityCell");
 		priorityForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "identifier", identifier });
 		HTMLNode prioritySelect = priorityForm.addChild("select", "name", "priority");
 		for (int p = 0; p < RequestStarter.NUMBER_OF_PRIORITY_CLASSES; p++) {
@@ -687,18 +686,16 @@
 		return priorityCell;
 	}
 
-	private HTMLNode createDeleteCell(PageMaker pageMaker, String identifier, ClientRequest clientRequest) {
+	private HTMLNode createDeleteCell(PageMaker pageMaker, String identifier, ClientRequest clientRequest, ToadletContext ctx) {
 		HTMLNode deleteNode = new HTMLNode("td", "class", "request-delete");
-		HTMLNode deleteForm = deleteNode.addChild("form", new String[] { "action", "method", "enctype", "encoding" }, new String[] { "/queue/", "post", "UTF-8", "multipart/form-data" });
-		deleteForm.addChild(pageMaker.createFormPasswordInput(core.formPassword));
+		HTMLNode deleteForm = ctx.addFormChild(deleteNode, "/queue/", "queueDeleteForm");
 		deleteForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "identifier", identifier });
 		deleteForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "remove_request", "Delete" });
 		
 		// If it's failed, offer to restart it
 		
 		if(clientRequest.hasFinished() && !clientRequest.hasSucceeded() && clientRequest.canRestart()) {
-			HTMLNode retryForm = deleteNode.addChild("form", new String[] { "action", "method", "enctype", "encoding" }, new String[] { "/queue/", "post", "UTF-8", "multipart/form-data" });
-			retryForm.addChild(pageMaker.createFormPasswordInput(core.formPassword));
+			HTMLNode retryForm = ctx.addFormChild(deleteNode, "/queue/", "queueRestartForm");
 			retryForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "identifier", identifier });
 			retryForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "restart_request", "Retry" });
 		}
@@ -706,10 +703,9 @@
 		return deleteNode;
 	}
 	
-	private HTMLNode createPanicBox(PageMaker pageMaker) {
+	private HTMLNode createPanicBox(PageMaker pageMaker, ToadletContext ctx) {
 		HTMLNode panicBox = pageMaker.getInfobox("infobox-alert", "Panic Button");
-		HTMLNode panicForm = pageMaker.getContentNode(panicBox).addChild("form", new String[] { "action", "method" }, new String[] { "/queue/", "post" });
-		panicForm.addChild(pageMaker.createFormPasswordInput(core.formPassword));
+		HTMLNode panicForm = ctx.addFormChild(pageMaker.getContentNode(panicBox), "/queue/", "queuePanicForm");
 		panicForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "remove_AllRequests", "Delete everything without confirmation!" });
 		return panicBox;
 	}
@@ -772,12 +768,11 @@
 		return keyCell;
 	}
 	
-	private HTMLNode createInsertBox(PageMaker pageMaker) {
+	private HTMLNode createInsertBox(PageMaker pageMaker, ToadletContext ctx) {
 		/* the insert file box */
 		HTMLNode insertBox = pageMaker.getInfobox("Insert File");
 		HTMLNode insertContent = pageMaker.getContentNode(insertBox);
-		HTMLNode insertForm = insertContent.addChild("form", new String[] { "action", "method", "enctype", "encoding" }, new String[] { "/queue/", "post", "UTF-8", "multipart/form-data" });
-		insertForm.addChild(pageMaker.createFormPasswordInput(core.formPassword));
+		HTMLNode insertForm = ctx.addFormChild(insertContent, "/queue/", "queueInsertForm");
 		insertForm.addChild("#", "Insert as: ");
 		insertForm.addChild("input", new String[] { "type", "name", "value", "checked" }, new String[] { "radio", "keytype", "chk", "checked" });
 		insertForm.addChild("#", " CHK \u00a0 ");
@@ -797,7 +792,7 @@
 		return insertBox;
 	}
 	
-	private HTMLNode createRequestTable(PageMaker pageMaker, List requests, int[] columns) {
+	private HTMLNode createRequestTable(PageMaker pageMaker, ToadletContext ctx, List requests, int[] columns) {
 		HTMLNode table = new HTMLNode("table", "class", "requests");
 		HTMLNode headerRow = table.addChild("tr", "class", "table-header");
 		headerRow.addChild("th");
@@ -833,7 +828,7 @@
 			ClientRequest clientRequest = (ClientRequest) requestItems.next();
 			HTMLNode requestRow = table.addChild("tr", "class", "priority" + clientRequest.getPriority());
 			
-			requestRow.addChild(createDeleteCell(pageMaker, clientRequest.getIdentifier(), clientRequest));
+			requestRow.addChild(createDeleteCell(pageMaker, clientRequest.getIdentifier(), clientRequest, ctx));
 			for (int columnIndex = 0, columnCount = columns.length; columnIndex < columnCount; columnIndex++) {
 				int column = columns[columnIndex];
 				if (column == LIST_IDENTIFIER) {
@@ -875,7 +870,7 @@
 						requestRow.addChild(createFilenameCell(((ClientPut) clientRequest).getOrigFilename()));
 					}
 				} else if (column == LIST_PRIORITY) {
-					requestRow.addChild(createPriorityCell(pageMaker, clientRequest.getIdentifier(), clientRequest.getPriority()));
+					requestRow.addChild(createPriorityCell(pageMaker, clientRequest.getIdentifier(), clientRequest.getPriority(), ctx));
 				} else if (column == LIST_FILES) {
 					requestRow.addChild(createNumberCell(((ClientPutDir) clientRequest).getNumberOfFiles()));
 				} else if (column == LIST_TOTAL_SIZE) {

Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -58,6 +58,7 @@
 	private boolean advancedDarknetEnabled;
 	private boolean fProxyJavascriptEnabled;
 	private final PageMaker pageMaker;
+	private final NodeClientCore core;
 	
 	static boolean isPanicButtonToBeShown;
 	static final int DEFAULT_FPROXY_PORT = 8888;
@@ -188,6 +189,7 @@
 	 */
 	public SimpleToadletServer(SubConfig fproxyConfig, NodeClientCore core) throws IOException, InvalidConfigValueException {
 
+		this.core = core;
 		int configItemOrder = 0;
 		
 		fproxyConfig.register("enabled", true, configItemOrder++, true, true, "Enable FProxy?", "Whether to enable FProxy and related HTTP services",
@@ -287,7 +289,7 @@
 		}
 	}
 	
-	public SimpleToadletServer(int i, String newbindTo, String allowedHosts, BucketFactory bf, String cssName) throws IOException {
+	public SimpleToadletServer(int i, String newbindTo, String allowedHosts, BucketFactory bf, String cssName, NodeClientCore core) throws IOException {
 		this.port = i;
 		this.bindTo = newbindTo;
 		this.allowedHosts = allowedHosts;
@@ -296,6 +298,7 @@
 		toadlets = new LinkedList();
 		this.cssName = cssName;
 		pageMaker = new PageMaker(cssName);
+		this.core = core;
 	}
 
 	public void start() {
@@ -342,7 +345,7 @@
         Logger.globalSetThreshold(Logger.MINOR);
         Logger.globalAddHook(logger);
         logger.start();
-		SimpleToadletServer server = new SimpleToadletServer(1111, "127.0.0.1", "127.0.0.1", new TempBucketFactory(new FilenameGenerator(new DummyRandomSource(), true, new File("temp-test"), "test-temp-")), "aqua");
+		SimpleToadletServer server = new SimpleToadletServer(1111, "127.0.0.1", "127.0.0.1", new TempBucketFactory(new FilenameGenerator(new DummyRandomSource(), true, new File("temp-test"), "test-temp-")), "aqua", null);
 		server.register(new TrivialToadlet(null), "", true);
 		server.start();
 		System.out.println("Bound to port 1111.");
@@ -423,4 +426,8 @@
 	public synchronized void enableFProxyJavascript(boolean b){
 		fProxyJavascriptEnabled = b;
 	}
+
+	public String getFormPassword() {
+		return core.formPassword;
+	}
 }

Modified: trunk/freenet/src/freenet/clients/http/Spider.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/Spider.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/Spider.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -312,7 +312,7 @@
 				Set visited = new HashSet(visitedURIs);
 				Set failed = new HashSet(failedURIs);
 				contentNode.addChild(createNavbar(pageMaker, runningFetches.size(), queued.size(), visited.size(), failed.size()));
-				contentNode.addChild(createAddBox(pageMaker));
+				contentNode.addChild(createAddBox(pageMaker, context));
 				contentNode.addChild(createList(pageMaker, "Running Fetches", "running", runningFetches.keySet(), maxShownURIs));
 				contentNode.addChild(createList(pageMaker, "Queued URIs", "queued", queued, maxShownURIs));
 				contentNode.addChild(createList(pageMaker, "Visited URIs", "visited", visited, maxShownURIs));
@@ -385,7 +385,7 @@
 		return backbox;
 	}
 	
-	private HTMLNode createAddBox(PageMaker pageMaker) {
+	private HTMLNode createAddBox(PageMaker pageMaker, ToadletContext ctx) {
 		HTMLNode addBox = pageMaker.getInfobox("Add a URI");
 		HTMLNode formNode = pageMaker.getContentNode(addBox).addChild("form", new String[] { "action", "method" }, new String[] { "", "get" });
 		formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "action", "add" });

Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -109,8 +109,7 @@
 		// Generate a Thread-Dump
 		if(node.isUsingWrapper()){
 			HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("Request a Thread Dump to be generated"));
-			HTMLNode threadDumpForm = ctx.getPageMaker().getContentNode(infobox).addChild("form", new String[] { "action", "method" }, new String[] { "/", "POST" });
-			threadDumpForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+			HTMLNode threadDumpForm = ctx.addFormChild(ctx.getPageMaker().getContentNode(infobox), "/", "threadDumpForm");
 			threadDumpForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "getThreadDump", "Generate a Thread Dump" });
 		}
 		

Modified: trunk/freenet/src/freenet/clients/http/ToadletContainer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContainer.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/ToadletContainer.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -24,4 +24,9 @@
 	 * Get the name of the theme to be used by all the Toadlets
 	 */
 	public String getCSSName();
+	
+	/**
+	 * Get the form password
+	 */
+	public String getFormPassword();
 }

Modified: trunk/freenet/src/freenet/clients/http/ToadletContext.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContext.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/ToadletContext.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 
+import freenet.support.HTMLNode;
 import freenet.support.MultiValueTable;
 import freenet.support.io.Bucket;
 import freenet.support.io.BucketFactory;
@@ -52,5 +53,15 @@
 	BucketFactory getBucketFactory();
 	
 	MultiValueTable getHeaders();
+
+	/**
+	 * Add a form node to an HTMLNode under construction. This will have the correct enctype and 
+	 * formPassword set already, so all the caller needs to do is add its specific fields.
+	 * @param parentNode The parent HTMLNode.
+	 * @param target Where the form should be POSTed to.
+	 * @param id HTML name for the form for stylesheet/script access. Will be added as both id and name.
+	 * @return The form HTMLNode.
+	 */
+	HTMLNode addFormChild(HTMLNode parentNode, String target, String id);
 }
 

Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -13,7 +13,9 @@
 import java.util.Enumeration;
 import java.util.TimeZone;
 
+import freenet.node.NodeClientCore;
 import freenet.support.HTMLEncoder;
+import freenet.support.HTMLNode;
 import freenet.support.Logger;
 import freenet.support.MultiValueTable;
 import freenet.support.URIPreEncoder;
@@ -36,6 +38,7 @@
 	private final OutputStream sockOutputStream;
 	private final PageMaker pagemaker;
 	private final BucketFactory bf;
+	private final ToadletContainer container;
 	
 	/** Is the context closed? If so, don't allow any more writes. This is because there
 	 * may be later requests.
@@ -43,12 +46,13 @@
 	private boolean closed;
 	private boolean shouldDisconnect;
 	
-	public ToadletContextImpl(Socket sock, MultiValueTable headers, String CSSName, BucketFactory bf, PageMaker pageMaker) throws IOException {
+	public ToadletContextImpl(Socket sock, MultiValueTable headers, String CSSName, BucketFactory bf, PageMaker pageMaker, ToadletContainer container) throws IOException {
 		this.headers = headers;
 		this.closed = false;
 		sockOutputStream = sock.getOutputStream();
 		this.bf = bf;
 		this.pagemaker = pageMaker;
+		this.container = container;
 	}
 	
 	private void close() {
@@ -238,7 +242,7 @@
 				
 				boolean shouldDisconnect = shouldDisconnectAfterHandled(split[2].equals("HTTP/1.0"), headers);
 				
-				ToadletContextImpl ctx = new ToadletContextImpl(sock, headers, container.getCSSName(), bf, pageMaker);
+				ToadletContextImpl ctx = new ToadletContextImpl(sock, headers, container.getCSSName(), bf, pageMaker, container);
 				ctx.shouldDisconnect = shouldDisconnect;
 				
 				/*
@@ -380,4 +384,14 @@
 	public BucketFactory getBucketFactory() {
 		return bf;
 	}
+
+	public HTMLNode addFormChild(HTMLNode parentNode, String target, String name) {
+		HTMLNode formNode =
+			parentNode.addChild("form", new String[] { "action", "method", "enctype", "id", "name", "accept-charset" }, 
+					new String[] { target, "post", "multipart/form-data", name, name, "utf-8"} );
+		formNode.addChild("input", new String[] { "type", "name", "value" }, 
+				new String[] { "hidden", "formPassword", container.getFormPassword() });
+		
+		return formNode;
+	}
 }

Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java	2006-12-04 16:13:20 UTC (rev 11224)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java	2006-12-04 16:15:14 UTC (rev 11225)
@@ -105,10 +105,9 @@
 			HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query", "Node Update"));
 			HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
 			content.addChild("p").addChild("#", "Are you sure you wish to update your Freenet node?");
-			HTMLNode updateForm = content.addChild("p").addChild("form", new String[] { "action", "method" }, new String[] { "/", "post" });
+			HTMLNode updateForm = ctx.addFormChild(content, "/", "updateConfirmForm");
 			updateForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "cancel", "Cancel" });
 			updateForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "updateconfirm", "Update" });
-			updateForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 			writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
 			return;
 		}else if(request.isPartSet("getThreadDump")) {
@@ -247,8 +246,7 @@
 				HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query", "Frost Instant Note insert"));
 				HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
 				content.addChild("p").addChild("#", "Do you want to insert the following Frost message?");
-				HTMLNode postForm = content.addChild("p").addChild("form", new String[] { "action", "method", "enctype", "encoding" }, new String[] { "/", "post", "UTF-8", "multipart/form-data" });
-				postForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+				HTMLNode postForm = ctx.addFormChild(content.addChild("p"), "/", "finConfirmForm"); 
 				HTMLNode table = postForm.addChild("table", "align", "center");
 				
 				finInputRow(table, "boardname", "Target Board", boardName);
@@ -428,12 +426,11 @@
 			HTMLNode pageNode = ctx.getPageMaker().getPageNode("Add a Bookmark");
 			HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
 			HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("Confirm Bookmark Addition"));
-			HTMLNode addForm = ctx.getPageMaker().getContentNode(infobox).addChild("form", new String[] { "action", "method" }, new String[] { "/", "post" });
+			HTMLNode addForm = ctx.addFormChild(ctx.getPageMaker().getContentNode(infobox), "/", "bookmarkAddForm");
 			addForm.addChild("#", "Please confirm that you want to add the key " + request.getParam("newbookmark") + " to your bookmarks and enter the description that you would prefer:");
 			addForm.addChild("br");
 			addForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "key", request.getParam("newbookmark") });
 			addForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "text", "name", request.getParam("desc") });
-			addForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 			addForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "addbookmark", "Add bookmark" });
 			this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
 			return;
@@ -441,14 +438,13 @@
 			HTMLNode pageNode = ctx.getPageMaker().getPageNode("Link to external resources");
 			HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
 			HTMLNode warnbox = contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-warning", "External link"));
-			HTMLNode externalLinkForm = ctx.getPageMaker().getContentNode(warnbox).addChild("form", new String[] { "action", "method" }, new String[] { "/", "post" });
+			HTMLNode externalLinkForm = ctx.addFormChild(ctx.getPageMaker().getContentNode(warnbox), "/", "confirmExternalLinkForm");
 
 			// FIXME: has request.getParam(GenericReadFilterCallback.magicHTTPEscapeString) been sanityzed ?
 			final String target = request.getParam(GenericReadFilterCallback.magicHTTPEscapeString);
 			externalLinkForm.addChild("#", "Please confirm that you want to go to " + target + ". WARNING: You are leaving FREENET! Clicking on this link WILL seriously jeopardize your anonymity!. It is strongly recommended not to do so!");
 			externalLinkForm.addChild("br");
 			externalLinkForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", GenericReadFilterCallback.magicHTTPEscapeString, target });
-			externalLinkForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 			externalLinkForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "cancel", "Cancel" });
 			externalLinkForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "Go", "Go to the specified link" });
 			this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
@@ -463,7 +459,7 @@
 			if (!e.hasMoreElements()) {
 				infoboxContent.addChild("#", "You currently do not have any bookmarks defined.");
 			} else {
-				HTMLNode manageForm = infoboxContent.addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
+				HTMLNode manageForm = ctx.addFormChild(infoboxContent, ".", "manageBookmarksForm");
 				HTMLNode bookmarkList = manageForm.addChild("ul", "id", "bookmarks");
 				while (e.hasMoreElements()) {
 					Bookmark b = (Bookmark)e.nextElement();
@@ -473,10 +469,9 @@
 					bookmark.addChild("input", new String[] { "type", "name", "value", "style" }, new String[] { "submit", "edit_" + b.hashCode(), "Edit", "float: right;" });
 					bookmark.addChild("a", "href", '/' + b.getKey(), b.getDesc());
 				}
-				manageForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 				manageForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "managebookmarks", "yes" });
 			}
-			contentNode.addChild(createBookmarkEditForm(ctx.getPageMaker(), MODE_ADD, null, "", ""));
+			contentNode.addChild(createBookmarkEditForm(ctx, MODE_ADD, null, "", ""));
 			this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
 			return;
 		}else if (request.isParameterSet("exit")) {
@@ -485,8 +480,7 @@
 			HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query", "Node Shutdown"));
 			HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
 			content.addChild("p").addChild("#", "Are you sure you wish to shut down your Freenet node?");
-			HTMLNode shutdownForm = content.addChild("p").addChild("form", new String[] { "action", "method" }, new String[] { "/", "POST" });
-			shutdownForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+			HTMLNode shutdownForm = ctx.addFormChild(content.addChild("p"), "/", "confirmShutdownForm");
 			shutdownForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "cancel", "Cancel" });
 			shutdownForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "shutdownconfirm", "Shut down" });
 			writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
@@ -497,8 +491,7 @@
 			HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query", "Node Restart"));
 			HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
 			content.addChild("p").addChild("#", "Are you sure you want to restart your Freenet node?");
-			HTMLNode restartForm = content.addChild("p").addChild("form", new String[] { "action", "method" }, new String[] { "/", "POST" });
-			restartForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
+			HTMLNode restartForm = ctx.addFormChild(content.addChild("p"), "/", "confirmRestartForm");
 			restartForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "cancel", "Cancel" });
 			restartForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "restartconfirm", "Restart" });
 			writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
@@ -600,15 +593,16 @@
 			ctx.getPageMaker().getContentNode(errorBox).addChild("#", message);
 		}
 		
-		contentNode.addChild(createBookmarkEditForm(ctx.getPageMaker(), mode, b, origKey, origDesc));
+		contentNode.addChild(createBookmarkEditForm(ctx, mode, b, origKey, origDesc));
 		
 		this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
 	}
 	
-	private HTMLNode createBookmarkEditForm(PageMaker pageMaker, int mode, Bookmark b, String origKey, String origDesc) {
+	private HTMLNode createBookmarkEditForm(ToadletContext ctx, int mode, Bookmark b, String origKey, String origDesc) {
+		PageMaker pageMaker = ctx.getPageMaker();
 		HTMLNode infobox = pageMaker.getInfobox("infobox-normal bookmark-edit", (mode == MODE_ADD) ? "New Bookmark" : "Update Bookmark");
 		HTMLNode content = pageMaker.getContentNode(infobox);
-		HTMLNode editForm = content.addChild("form", new String[] { "action", "method" }, new String[] { ".", "post" });
+		HTMLNode editForm = ctx.addFormChild(content, ".", mode == MODE_ADD ? "addBookmarkForm" : "editBookmarkForm");
 		editForm.addChild("#", "Key: ");
 		editForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "text", "key", origKey });
 		editForm.addChild("br");
@@ -622,7 +616,6 @@
 		}
 		editForm.addChild("input", new String[] { "type", "value", "class" }, new String[] { "submit", "Cancel", "cancel" });
 		editForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "managebookmarks", "yes" });
-		editForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", core.formPassword });
 		return infobox;
 	}
 	




More information about the cvs mailing list