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

on maintenance () {
		<<9/8/02; 4:46:12 PM by JES
			<<Fixed a typo. Implemented the Reset search enging index function, with a confirmation page.
		<<8/18/02; 10:08:53 PM by JES
			<<Created. Render a page of server maintenance functions.
	local (pta = html.getPageTableAddress ());
	pta^.title = "Maintenance";
	local (htmltext);
	on add (s) {
		htmltext = htmltext + (s + "\r");};
	local (backupConfirmText = "", searchConfirmText = "");
	if pta^.method == "POST" {
		local (adrargs = @pta^.postArgs);
		case true { //figure out which button the user clicked
			defined (adrargs^.backupNow) {
				thread.callScript (@manilaSuite.backups.backupAllSites, {});
				local (notificationlist = config.manila.backups.notifyList);
				if typeOf (notificationlist) == listType {
					notificationlist = "";
					local (oneaddr);
					for oneaddr in config.manila.backups.notifyList {
						notificationlist = notificationlist + oneaddr + ", "};
					notificationlist = string.delete (notificationlist, sizeOf (notificationlist) - 1, 2)};
				backupConfirmText = "Manila site backups have been started. When the backups are complete, an email notification will be sent to " + notificationlist + " when the backup operation is complete."};
			defined (adrargs^.indexNow) {
				local (adr);
				for adr in @config.manila.sites {
					local (adrsite = adr^);
					try {adrsite^.["#newsSite"].search.indexQueue.flRunning = true}};
				searchConfirmText = "All Manila sites on this server have been scheduled to be re-indexed by the Search Engine Server."};
			defined (adrargs^.resetIndex) {
				add ("<form method=\"POST\">");
				add ("<p>Are you sure you want to completely reset the entire search engine index?</p><p>This operation cannot be undone.</p>");
				add ("<p><br /><input type=\"submit\" name=\"cancel\" value=\"Cancel\" />   <input type=\"submit\" name=\"resetIndexConfirm\" value=\"Reset Index\" /></p>");
				add ("</form>");
				return (htmltext)};
			defined (adrargs^.resetIndexConfirm) { ();
				local (indexpath = ());
				local (adrindex = @[indexpath].index);
				local (adrpageinfo = @[indexpath].pageInfo);
				new (tableType, adrindex);
				new (tableType, adrpageinfo);
				fileMenu.saveMyRoot (adrindex);
				searchConfirmText = "The search engine index has been completely reset. Sites for which indexing is enabled will have new or changed pages indexed."}}};
	bundle { //explanatory text
		add ("<p>This page provides access to server-wide maintenance functions like Backups, Search Engine Indexing options.</p>")};
	bundle { //database update options
		add ("<h4><a name=\"updates\"></a>Updates</h4>");
		add ("<form method=\"POST\">");
		bundle { //explanatory text
			add ("<p>Frontier can automatically connect to a server at UserLand, to get new features and bug fixes. Only those parts that have changed since the last update will be installed. To update your databases now, click the Update Now button.</p>")};
		add (mainResponder.adminSite.prefs.updateNowButton (false));
		add ("</form>")};
	add ("<br /><hr size=\"1\">");
	bundle { //backup options
		add ("<h4><a name=\"manilaBackups\"></a>Backup Manila Sites</h4>");
		add ("<form method=\"POST\">");
		bundle { //explanatory text
			add ("<p>To make an immediate backup of all sites which have automatic backups enabled, click the Backup Now button.</p>")};
		bundle { //Backup Now and Backup All Sites buttons
			add ("<p><br /><input type=\"submit\" name=\"backupNow\" value=\"Backup Now\" /></p>")};
		if backupConfirmText == "" {
			add ("<p><br />You can enable backups for any site by clicking the site's name on the <a href=\"" + mainResponder.adminSite.urls.home + "\">home page</a>, and then clicking the enable link, in the Backups section.</p>")}
		else {
			add ("<br /><b>" + backupConfirmText + "</b></p>")};
		add ("</form>")};
	add ("<br /><hr size=\"1\">");
	bundle { //search engine indexing options
		add ("<h4><a name=\"searchEngine\"></a>Search Engine</h4>");
		if config.mainResponder.prefs.flSearchEngine {
			add ("<form method=\"POST\">");
			bundle { //explanatory text
				add ("<p>To re-index all Manila sites for which Search Engine Indexing is enabled, click the Index Now button. To clear the Search Engine index completely, click the Reset Index button.</p>")};
			bundle { //Index Now and Reset Index buttons
				add ("<p><br /><input type=\"submit\" name=\"indexNow\" value=\"Index Now\" />   <input type=\"submit\" name=\"resetIndex\" value=\"Reset Index\" /></p>")};
			add ("</form>");
			if searchConfirmText != "" {
				add ("<b><br /><b>" + searchConfirmText + "</b></p>")}}
		else { //disabled -- let the admin know
			add ("<p>Search Engine Indexing options are unavailable because the Search Engine is currently disabled. To turn on the Search Engine, use the Search Engine settings page.</p>")}};
	return (htmltext)}

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.