public void sendReply_cgibin_configdo_cgi(MyHTTPServer socket, List<HTTPRequestData> requestData, String cookie) throws Exception
	{
		List<String> reply = new ArrayList<String>();

		configNotWrittenToDisk = true;

		addHTTP200(reply, cookie);
		addPageHeader(reply, "");

		HTTPRequestData nRows = MyHTTPServer.findRecord(requestData, "nRows");
		if (nRows != null && nRows.getData() != null)
		{
			int newNRows = Integer.valueOf(nRows.getData());
			if (newNRows < 3)
				reply.add("New number of rows invalid, must be >= 3.<BR>\n");
			else
				config.setNRows(newNRows);
		}

		HTTPRequestData minRowHeight = MyHTTPServer.findRecord(requestData, "min-row-height");
		if (minRowHeight != null && minRowHeight.getData() != null) {
			config.setMinRowHeight(Integer.valueOf(minRowHeight.getData()));
		}

		HTTPRequestData nCols = MyHTTPServer.findRecord(requestData, "problem-columns");
		if (nCols != null && nCols.getData() != null)
		{
			int newNCols = Integer.valueOf(nCols.getData());
			if (newNCols < 1)
				reply.add("New number of rows invalid, must be >= 1.<BR>\n");
			else
				config.setNProblemCols(newNCols);
		}

		HTTPRequestData transparency = MyHTTPServer.findRecord(requestData, "transparency");
		if (transparency != null && transparency.getData() != null)
		{
			float newTransparency = Float.valueOf(transparency.getData());
			if (newTransparency < 0.0 || newTransparency > 1.0)
				reply.add("Transparency must be between 0.0 and 1.0 (both inclusive)");
			else
				config.setTransparency(newTransparency);
		}

		HTTPRequestData headerTransparency = MyHTTPServer.findRecord(requestData, "header-transparency");
		if (headerTransparency != null && headerTransparency.getData() != null)
		{
			float newTransparency = Float.valueOf(headerTransparency.getData());
			if (newTransparency < 0.0 || newTransparency > 1.0)
				reply.add("Transparency (for header) must be between 0.0 and 1.0 (both inclusive)");
			else
				config.setHeaderTransparency(newTransparency);
		}

		HTTPRequestData sparkline_size = MyHTTPServer.findRecord(requestData, "sparkline-size");
		if (sparkline_size != null && sparkline_size.getData() != null)
		{
			int newSparklineSize = Integer.valueOf(sparkline_size.getData());
			if (newSparklineSize < 0 || newSparklineSize >= 1000)
				reply.add("Transparency must be between 0 (inclusive) and 1000");
			else
				config.setSparkLineWidth(newSparklineSize);
		}

		String maxAge = getField(requestData, "max-check-age");
		config.setMaxCheckAge(maxAge.equals("") ? -1 : Long.valueOf(maxAge));

		config.setFlexibleNColumns(getCheckBox(requestData, "flexible-n-columns"));

		config.setMaxQualityGraphics(getCheckBox(requestData, "max-quality-graphics"));

		config.setFontName(getFieldDecoded(requestData, "font"));

		config.setProxyHost(getFieldDecoded(requestData, "proxy-host"));
		config.setProxyPort(Integer.valueOf(getFieldDecoded(requestData, "proxy-port")));

		if (!config.getNoNetworkChange())
		{
			config.setHTTPServerListenAdapter(getFieldDecoded(requestData, "network-interface"));
			System.out.println("PORT: " + getFieldDecoded(requestData, "network-port") + "|");
			config.setHTTPServerListenPort(Integer.valueOf(getFieldDecoded(requestData, "network-port")));
		}

		config.setWarningFontName(getFieldDecoded(requestData, "warning-font"));

		config.setCriticalFontName(getFieldDecoded(requestData, "critical-font"));

		config.setTextColor(getField(requestData, "textColor"));
		config.setWarningTextColor(getField(requestData, "warningTextColor"));
		config.setCriticalTextColor(getField(requestData, "criticalTextColor"));
		// config.setHeaderColorName(getField(requestData, "header-color"));

		config.setBackgroundColor(getField(requestData, "backgroundColor"));
		String fadeTo = getField(requestData, "bgcolor-fade-to");
		if (fadeTo == null || fadeTo.equals("NULL") == true)
			config.setBackgroundColorFadeTo(null);
		else
			config.setBackgroundColorFadeTo(fadeTo);

		String problemBarFadeTo = getField(requestData, "problem-row-gradient");
		if (problemBarFadeTo == null || problemBarFadeTo.equals("NULL") == true)
			config.setProblemRowGradient(null);
		else
			config.setProblemRowGradient(problemBarFadeTo);

		config.setBackgroundColorOkStatus(getField(requestData, "bgColorOk"));
		config.setWarningBgColor(getField(requestData, "warning-bg-color"));
		config.setWarningBgColorSoft(getField(requestData, "warning-bg-color-soft"));
		config.setCriticalBgColor(getField(requestData, "critical-bg-color"));
		config.setCriticalBgColorSoft(getField(requestData, "critical-bg-color-soft"));
		config.setNagiosUnknownBgColor(getField(requestData, "unknown-bg-color"));
		config.setSetBgColorToState(getCheckBox(requestData, "color-bg-to-state"));

		String sleepTime = getField(requestData, "sleepTime");
		if (sleepTime != null && sleepTime.equals("") == false)
		{
			int newSleepTime = Integer.valueOf(sleepTime);
			if (newSleepTime < 1)
				reply.add("New refresh interval is invalid, must be >= 1<BR>\n");
			else
			{
				CoffeeSaint.log.add("Setting sleep interval to: " + newSleepTime);
				config.setSleepTime(newSleepTime);
			}
		}

		String wcTo = getField(requestData, "webcam-timeout");
		int wcToVal = -1;
		if (wcTo == null || wcTo.trim().equals("") == true)
			wcToVal = -1;
		else
			wcToVal = Integer.valueOf(wcTo);
		if (wcToVal <= 0 || wcToVal > config.getSleepTime())
			wcToVal = -1;
		config.setWebcamTimeout(wcToVal);

		String webExpireTime = getField(requestData, "web-expire-time");
		if (webExpireTime != null && webExpireTime.equals("") == false)
		{
			int newWebExpireTime = Integer.valueOf(webExpireTime);
			if (newWebExpireTime < 1)
				reply.add("New authentication timeout is invalid, must be >= 1<BR>\n");
			else
				config.setWebSessionExpire(newWebExpireTime);
		}

		String sparkline_mode = getField(requestData, "sparkline-mode");
		if (sparkline_mode != null)
		{
			if (sparkline_mode.equals("avg-sd"))
				config.setSparklineGraphMode(SparklineGraphMode.AVG_SD);
			else if (sparkline_mode.equals("min-max"))
				config.setSparklineGraphMode(SparklineGraphMode.MIN_MAX);
		}

		String noProblemsText = getFieldDecoded(requestData, "no-problems-text");
		if (noProblemsText != null)
		{
			if (noProblemsText.trim().equals(""))
				config.setNoProblemsText(null);
			else
				config.setNoProblemsText(noProblemsText);
		}
		String noProblemsTextPosition = getField(requestData, "no-problems-text-position");
		if (noProblemsTextPosition != null && noProblemsTextPosition.equals("") == false)
			config.setNoProblemsTextPosition(noProblemsTextPosition);

		String stateProblemsText = getFieldDecoded(requestData, "state-problems-text");
		if (stateProblemsText != null)
		{
			if (stateProblemsText.trim().equals(""))
				config.setStateProblemsText(null);
			else
				config.setStateProblemsText(stateProblemsText);
		}

		String usernameField = getFieldDecoded(requestData, "web-username");
		String passwordField1 = getFieldDecoded(requestData, "web-password1");
		String passwordField2 = getFieldDecoded(requestData, "web-password2");
		if (usernameField != null && passwordField1 != null && passwordField2 != null)
		{
			if (passwordField1.equals(passwordField2))
			{
				usernameField = usernameField.trim();
				if (usernameField.equals(""))
					config.setWebUsername(null);
				else
					config.setWebUsername(usernameField);

				if (passwordField1.equals(""))
					config.setWebPassword(null);
				else
					config.setWebPassword(passwordField1);
			}
			else
			{
				reply.add("Passwords did not match, username+password <B>not</B> changed.<BR>\n");
			}
		}

		config.setAlwaysNotify(getCheckBox(requestData, "always_notify"));

		config.setHeaderAlwaysBGColor(getCheckBox(requestData, "header-always-bgcolor"));

		config.setAlsoAcknowledged(getCheckBox(requestData, "also_acknowledged"));

		config.setAlsoScheduledDowntime(getCheckBox(requestData, "also_scheduled_downtime"));

		config.setAlsoSoftState(getCheckBox(requestData, "also_soft_State"));

		config.setAlsoDisabledActiveChecks(getCheckBox(requestData, "also_disabled_active_checks"));

		config.setShowServicesForHostWithProblems(getCheckBox(requestData, "show_services_for_host_with_problems"));

		config.setHostSDOrAckShowServices(getCheckBox(requestData, "host_scheduled_downtime_or_ack_show_services"));

		config.setShowFlapping(getCheckBox(requestData, "show-flapping"));

		config.setShowFlappingIcon(getCheckBox(requestData, "show-flapping-icon"));

		config.setHostAcknowledgedShowServices(getCheckBox(requestData, "host_also_acknowledged"));
		config.setHostScheduledDowntimeShowServices(getCheckBox(requestData, "host_also_scheduled_downtime"));

		config.setCounter(getCheckBox(requestData, "counter"));

		String newFSMode = getField(requestData, "fullscreen");
		if (newFSMode != null)
		{
			if (newFSMode.equalsIgnoreCase("none"))
				config.setFullscreen(FullScreenMode.NONE);
			else if (newFSMode.equalsIgnoreCase("undecorated"))
				config.setFullscreen(FullScreenMode.UNDECORATED);
			else if (newFSMode.equalsIgnoreCase("fullscreen"))
				config.setFullscreen(FullScreenMode.FULLSCREEN);
			else if (newFSMode.equalsIgnoreCase("allmonitors"))
				config.setFullscreen(FullScreenMode.ALLMONITORS);
		}

		String useScreen = getFieldDecoded(requestData, "use-screen");
		if (useScreen == null || useScreen.equals("ALL"))
			config.setUseScreen(null);
		else
			config.setUseScreen(useScreen);

		String counterPosition = getField(requestData, "counter-position");
		if (counterPosition != null)
			config.setCounterPosition(counterPosition);

		String newLogo = getFieldDecoded(requestData, "logo-url");
		if (newLogo != null)
		{
			if (newLogo.trim().equals(""))
				config.setLogo(null);
			else
				config.setLogo(newLogo);
		}
		String logoPosition = getField(requestData, "logo-position");
		if (logoPosition != null && logoPosition.equals("") == false)
			config.setLogoPosition(logoPosition);

		if (config.getDisableHTTPFileselect() == false)
		{
			String brainFile = getField(requestData, "brain-file").trim();
			config.setBrainFileName(brainFile.equals("") ? null : brainFile);

			String performanceFile = getField(requestData, "performance-data").trim();
			config.setPerformanceDataFileName(performanceFile.equals("") ? null : performanceFile);

			String latencyFile = getField(requestData, "latency-file").trim();
			config.setLatencyFile(latencyFile.equals("") ? null : latencyFile);
		}

		String newWebcam = getFieldDecoded(requestData, "newWebcam");
		String newWebcamType = getFieldDecoded(requestData, "newWebcamType");
		if (newWebcam != null && newWebcam.equals("") == false && newWebcamType != null && newWebcamType.equals("") == false)
			config.addImageUrl(newWebcamType + " " + newWebcam);

		for(HTTPRequestData webcam : requestData)
		{
			try
			{
				String fieldName = webcam.getName();
				if (fieldName.substring(0, 7).equals("webcam_"))
				{
					int hash = Integer.valueOf(fieldName.substring(7));
					config.removeImageUrl(hash);
				}
			}
			catch(IndexOutOfBoundsException ioobe)
			{
				// ignore, probably not a webcam-field
			}
		}

		config.setProblemSound(getFieldDecoded(requestData, "warning-sound"));

		config.setAdaptImageSize(getCheckBox(requestData, "adapt-img"));

		config.setAllowHTTPCompression(getCheckBox(requestData, "disable-http-compression"));

		config.setAntiAlias(getCheckBox(requestData, "anti-alias"));

		config.setRandomWebcam(getCheckBox(requestData, "random-img"));

		config.setReduceTextWidth(getCheckBox(requestData, "reduce-textwidth"));

		config.setHeader(getFieldDecoded(requestData, "header"));

		String newFooter = getFieldDecoded(requestData, "footer");
		if (newFooter.trim().equals(""))
			config.setFooter(null);
		else
			config.setFooter(newFooter);

		config.setPrefers(getFieldDecoded(requestData, "prefer"));
		config.setHostsFilterExclude(getFieldDecoded(requestData, "hosts-filter-exclude-list"));
		config.setHostsFilterInclude(getFieldDecoded(requestData, "hosts-filter-include-list"));
		config.setServicesFilterExclude(getFieldDecoded(requestData, "services-filter-exclude-list"));
		config.setServicesFilterInclude(getFieldDecoded(requestData, "services-filter-include-list"));

		config.setScrollingHeader(getCheckBox(requestData, "scrolling-header"));
		config.setScrollingFooter(getCheckBox(requestData, "scrolling-footer"));
		config.setScrollIfNotFit(getCheckBox(requestData, "scroll-if-not-fitting"));

		String splitter = getFieldDecoded(requestData, "scroll-splitter");
		if (splitter != null)
		{
			splitter = splitter.trim();

			if (splitter.equals(""))
				config.setLineScrollSplitter(null);
			else
				config.setLineScrollSplitter(splitter);
		}

		config.setDrawProblemServiceSplitLine(getCheckBox(requestData, "draw-problems-service-split-line"));

		config.setNoProblemsTextBg(getCheckBox(requestData, "no-problems-text-with-bg-color"));

		String scrollSpeed = getField(requestData, "scroll-pixels-per-sec");
		if (scrollSpeed != null && scrollSpeed.trim().equals("") == false)
		{
			int newScrollSpeed = Integer.valueOf(scrollSpeed);
			if (newScrollSpeed < 1)
				reply.add("New pixels/sec-value is invalid, must be >= 1<BR>\n");
			else
				config.setScrollingPixelsPerSecond(newScrollSpeed);
		}

		config.setHostIssue(getFieldDecoded(requestData, "host-issue"));

		config.setServiceIssue(getFieldDecoded(requestData, "service-issue"));

		config.setShowHeader(getCheckBox(requestData, "show-header"));

		config.setFlash(getCheckBox(requestData, "flash"));

		boolean son = getCheckBox(requestData, "sort-order-numeric");
		boolean sor = getCheckBox(requestData, "sort-order-reverse");
		config.setSortOrder(getFieldDecoded(requestData, "sort-order"), son, sor);

		config.setVerbose(getCheckBox(requestData, "verbose"));

		config.setDisplayUnknown(getCheckBox(requestData, "display-unknown"));

		config.setDoubleBuffering(getCheckBox(requestData, "double-buffering"));

		config.setRowBorder(getCheckBox(requestData, "row-border"));

		String rowBorderHeight = getField(requestData, "upper-row-border-height");
		if (rowBorderHeight != null && rowBorderHeight.trim().equals("") == false)
		{
			int newRowBorderHeight = Integer.valueOf(rowBorderHeight);
			if (newRowBorderHeight < 1 || newRowBorderHeight > 400)
				reply.add("Invalid upper row border height. Must be &gt;= 1.<BR>\n");
			else
				config.setUpperRowBorderHeight(newRowBorderHeight);
		}

		config.setRowBorderColor(getField(requestData, "row-border-color"));
		config.setGraphColor(getField(requestData, "graph-color"));

		// add server
		String server_add_parameters = getFieldDecoded(requestData, "server-add-parameters");
		if (server_add_parameters.equals("") == false)
		{
			NagiosDataSourceType ndst = null;
			NagiosVersion nv = null;

			String type = getField(requestData, "server-add-type");
			if (type.equals("tcp"))
				ndst = NagiosDataSourceType.TCP;
			else if (type.equals("ztcp"))
				ndst = NagiosDataSourceType.ZTCP;
			else if (type.equals("ls"))
				ndst = NagiosDataSourceType.LS;
			else if (type.equals("http"))
				ndst = NagiosDataSourceType.HTTP;
			else if (type.equals("file"))
				ndst = NagiosDataSourceType.FILE;

			String pn = getField(requestData, "nagios-pretty-name");
			if (pn.equals(""))
				pn = null;

			String version = getField(requestData, "server-add-version");
			if (version.equals("1"))
				nv = NagiosVersion.V1;
			else if (version.equals("2"))
				nv = NagiosVersion.V2;
			else if (version.equals("3"))
				nv = NagiosVersion.V3;

			if (ndst == null && nv == null)
			{
				reply.add("Field missing or invalid data in field for server-add.<BR>\n");
			}
			else
			{
				if (ndst == NagiosDataSourceType.TCP || ndst == NagiosDataSourceType.ZTCP)
				{
					int port = 33333;
					int space = server_add_parameters.indexOf(" ");
					if (space != -1)
					{
						port = Integer.valueOf(server_add_parameters.substring(space + 1).trim());
						server_add_parameters = server_add_parameters.substring(0, space);
					}

					String result = CoffeeSaint.testPort(server_add_parameters, port);
					if (result != null)
						reply.add("Error: address " + server_add_parameters + ":" + port + " has an issue (" + result + "). Nagios server was <I>not</I> added.<BR>\n");
					else
						config.addNagiosDataSource(new NagiosDataSource(server_add_parameters, port, nv, ndst == NagiosDataSourceType.ZTCP, pn));
				}
				else if (ndst == NagiosDataSourceType.LS)
				{
					int port = 6557;
					int space = server_add_parameters.indexOf(" ");
					if (space != -1)
					{
						port = Integer.valueOf(server_add_parameters.substring(space + 1).trim());
						server_add_parameters = server_add_parameters.substring(0, space);
					}

					String result = CoffeeSaint.testPort(server_add_parameters, port);
					if (result != null)
						reply.add("Error: address " + server_add_parameters + ":" + port + " has an issue (" + result + "). Nagios server was <I>not</I> added.<BR>\n");
					else
						config.addNagiosDataSource(new NagiosDataSource(server_add_parameters, port, pn));
				}
				else if (ndst == NagiosDataSourceType.HTTP)
				{
					try
					{
						URL url = new URL(URLDecoder.decode(server_add_parameters, "US-ASCII"));
						String username = getFieldDecoded(requestData, "nagios-http-username");
						String password = getFieldDecoded(requestData, "nagios-http-password");
						boolean withAuth = username != null && password != null && username.equals("") == false && password.equals("") == false;
						if (withAuth)
							config.addNagiosDataSource(new NagiosDataSource(url, username, password, nv, pn));
						else
							config.addNagiosDataSource(new NagiosDataSource(url, nv, pn));

						String result = CoffeeSaint.testUrl(url, withAuth);
						if (result != null)
							reply.add("Warning: URL " + server_add_parameters + " seems to be unreachable! (" + result + ")<BR>\n");
					}
					catch(MalformedURLException mue)
					{
						reply.add("Error: URL " + server_add_parameters + " is not valid. Nagios-server was <I>not</> added.<BR>\n");
					}
				}
				else if (ndst == NagiosDataSourceType.FILE)
					config.addNagiosDataSource(new NagiosDataSource(server_add_parameters, nv, pn));
			}
		}

		for(HTTPRequestData server : requestData)
		{
			try
			{
				String fieldName = server.getName();
				if (fieldName.substring(0, 9).equals("serverid_"))
				{
					int hash = Integer.valueOf(fieldName.substring(9));
					config.removeServer(hash);
				}
			}
			catch(IndexOutOfBoundsException ioobe)
			{
				// ignore, probably not a webcam-field
			}
		}

		String cam_rows = getField(requestData, "cam-rows");
		if (cam_rows.equals("") == false)
		{
			int camRows = Integer.valueOf(cam_rows);
			if (camRows < 1)
				camRows = 1;
			else if (camRows > 8)
				camRows = 8;

			CoffeeSaint.log.add("Setting number of cam-rows to: " + camRows);
			config.setCamRows(camRows);
		}

		String cam_cols = getField(requestData, "cam-cols");
		if (cam_cols.equals("") == false)
		{
			int camCols = Integer.valueOf(cam_cols);
			if (camCols < 1)
				camCols = 1;
			else if (camCols > 8)
				camCols = 8;

			CoffeeSaint.log.add("Setting number of cam-cols to: " + camCols);
			config.setCamCols(camCols);
		}

		config.setKeepAspectRatio(getCheckBox(requestData, "keep-aspect-ratio"));

		reply.add("<BR>\n");
		reply.add("Form processed.<BR>\n");
		reply.add("<BR>\n");
		if (config.getHTTPServerListenAdapter().equals("0.0.0.0") == false)
		{
			String listenAddress = "http://" + config.getHTTPServerListenAdapter() + ":" + config.getHTTPServerListenPort() + "/";
			reply.add("If you changed the networking parameters, please connect to <A HREF=\"" + listenAddress + "\">" + listenAddress + "</A><BR>\n");
		}

		reply.add("<BR>\n");
		reply.add("<A HREF=\"/cgi-bin/config-menu.cgi\">Back to the configuration menu</A>");

		addPageTail(reply, true);

		// in case the number of rows has changed or so
		if (config.getRunGui())
			gui.paint(gui.getGraphics());

		socket.sendReply(reply);
	}