Author: nextgens
Date: 2006-07-31 12:58:47 +0000 (Mon, 31 Jul 2006)
New Revision: 9836

Modified:
   trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
   trunk/freenet/src/freenet/node/Version.java
Log:
916: Send a redirect to the browser when shutting down the node ; include the 
formpassword in the parameters so that the node won't be restarted by accident

Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2006-07-31 
12:29:35 UTC (rev 9835)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2006-07-31 
12:58:47 UTC (rev 9836)
@@ -18,6 +18,7 @@
 import freenet.node.useralerts.UserAlert;
 import freenet.support.HTMLEncoder;
 import freenet.support.Logger;
+import freenet.support.MultiValueTable;
 import freenet.support.io.Bucket;

 public class WelcomeToadlet extends Toadlet {
@@ -47,37 +48,15 @@
                StringBuffer buf = new StringBuffer();

                if (request.getParam("shutdownconfirm").length() > 0) {
-                       // false for no navigation bars, because that would be 
very silly
-                       ctx.getPageMaker().makeHead(buf, "Node Shutdown", 
false);
-                       buf.append("<div class=\"infobox 
infobox-information\">\n");
-                       buf.append("<div class=\"infobox-header\">\n");
-                       buf.append("The Freenet node has been successfully shut 
down\n");
-                       buf.append("</div>\n");
-                       buf.append("<div class=\"infobox-content\">\n");
-                       buf.append("Thank you for using Freenet\n");
-                       buf.append("</div>\n");
-                       buf.append("</div>\n");
-                       ctx.getPageMaker().makeTail(buf);
-                               
-                       writeReply(ctx, 200, "text/html", "OK", buf.toString());
+                       MultiValueTable headers = new MultiValueTable();
+                       headers.put("Location", 
".?shutdownconfirm="+node.formPassword.hashCode());
+                       ctx.sendReplyHeaders(302, "Found", headers, null, 0);
                        this.node.exit();
                        return;
                }else if(request.getParam("restartconfirm").length() > 0){
-                       // false for no navigation bars, because that would be 
very silly
-                       ctx.getPageMaker().makeHead(buf, "Node Restart", false);
-                       buf.append("<div class=\"infobox 
infobox-information\">\n");
-                       buf.append("<div class=\"infobox-header\">\n");
-                       buf.append("The Freenet node is beeing restarted\n");
-                       buf.append("</div>\n");
-                       buf.append("<div class=\"infobox-content\">\n");
-                       buf.append("The restart process might take up to 3 
minutes. <br>");
-                       buf.append("Thank you for using Freenet\n");
-                       buf.append("</div>\n");
-                       buf.append("</div>\n");
-                       ctx.getPageMaker().makeTail(buf);
-                       
-                       writeReply(ctx, 200, "text/html", "OK", buf.toString());
-                       Logger.normal(this, "Node is restarting");
+                       MultiValueTable headers = new MultiValueTable();
+                       headers.put("Location", 
".?restartconfirm="+node.formPassword.hashCode());
+                       ctx.sendReplyHeaders(302, "Found", headers, null, 0);
                        node.getNodeStarter().restart();
                        return;
                }else if(request.getParam("updateconfirm").length() > 0){
@@ -333,6 +312,49 @@

                        this.writeReply(ctx, 200, "text/html", "OK", 
buf.toString());
                        return;
+               }else if (request.getParam("shutdownconfirm").length() > 0) {
+                       if(request.getIntParam("shutdownconfirm") != 
node.formPassword.hashCode()){
+                               MultiValueTable headers = new MultiValueTable();
+                               headers.put("Location", "/");
+                               ctx.sendReplyHeaders(302, "Found", headers, 
null, 0);
+                               return;
+                       }
+                       // false for no navigation bars, because that would be 
very silly
+                       ctx.getPageMaker().makeHead(buf, "Node Shutdown", 
false);
+                       buf.append("<div class=\"infobox 
infobox-information\">\n");
+                       buf.append("<div class=\"infobox-header\">\n");
+                       buf.append("The Freenet node has been successfully shut 
down\n");
+                       buf.append("</div>\n");
+                       buf.append("<div class=\"infobox-content\">\n");
+                       buf.append("Thank you for using Freenet\n");
+                       buf.append("</div>\n");
+                       buf.append("</div>\n");
+                       ctx.getPageMaker().makeTail(buf);
+                       writeReply(ctx, 200, "text/html", "OK", buf.toString());
+                       return;
+               }else if(request.getParam("restartconfirm").length() > 0){
+                       if(request.getIntParam("restartconfirm") != 
node.formPassword.hashCode()){
+                               MultiValueTable headers = new MultiValueTable();
+                               headers.put("Location", "/");
+                               ctx.sendReplyHeaders(302, "Found", headers, 
null, 0);
+                               return;
+                       }
+                       // false for no navigation bars, because that would be 
very silly
+                       ctx.getPageMaker().makeHead(buf, "Node Restart", false);
+                       buf.append("<div class=\"infobox 
infobox-information\">\n");
+                       buf.append("<div class=\"infobox-header\">\n");
+                       buf.append("The Freenet node is beeing restarted\n");
+                       buf.append("</div>\n");
+                       buf.append("<div class=\"infobox-content\">\n");
+                       buf.append("The restart process might take up to 3 
minutes. <br>");
+                       buf.append("Thank you for using Freenet\n");
+                       buf.append("</div>\n");
+                       buf.append("</div>\n");
+                       ctx.getPageMaker().makeTail(buf);
+                       
+                       writeReply(ctx, 200, "text/html", "OK", buf.toString());
+                       Logger.normal(this, "Node is restarting");
+                       return;
                }



Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-07-31 12:29:35 UTC (rev 
9835)
+++ trunk/freenet/src/freenet/node/Version.java 2006-07-31 12:58:47 UTC (rev 
9836)
@@ -18,7 +18,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 915;
+       private static final int buildNumber = 916;

        /** Oldest build of Fred we will talk to */
        private static final int oldLastGoodBuild = 870;


Reply via email to