Improve long table display
[hcoop/portal.git] / sec.mlt
diff --git a/sec.mlt b/sec.mlt
index 8885eaa..fd0c55e 100644 (file)
--- a/sec.mlt
+++ b/sec.mlt
@@ -2,7 +2,7 @@
 val yourname = Init.getUserName ();
 
 val nodeNum = case $"node" of
-                 "" => 2
+                 "" => 4
                | node => Web.stoi node;
 val nodeName = Init.nodeName nodeNum;
 
@@ -72,14 +72,26 @@ elseif $"cmd" = "ftp2" then
 elseif $"cmd" = "rule" then
        showNormal := false;
        val rule = $"rule";
-       %>Are you sure you want to request the firewall rule <b><% Web.html uname %>&nbsp;<% Web.html rule %></b> on <b><% Web.html nodeName %></b>?<br>
+
+       if Sec.validRule rule then
+               %>Are you sure you want to request the firewall rule <b><% Web.html uname %>&nbsp;<% Web.html rule %></b> on <b><% Web.html nodeName %></b>?<br>
        <a href="sec?cmd=rule2&node=<% nodeNum %>&uname=<% Web.urlEncode uname %>&rule=<% Web.urlEncode rule %>&msg=<% Web.urlEncode ($"msg") %>">Yes, place the request!</a><%
+       else
+               %>"<% Web.html rule %>" is not a valid firewall rule! Please reread <a href="http://wiki.hcoop.net/wiki/FirewallRules">the instructions</a>, and remember to leave off the initial username portion.<%
+       end
+
 elseif $"cmd" = "rule2" then
-       val id = Sec.Req.add {usr = you, node = nodeNum, data = String.concat ["Add firewall rule \"", uname, " ", $"rule", "\""], msg = $"msg"};
-       if not (Sec.Req.notifyNew id) then
-               %><h3>Error sending e-mail notification</h3><%
+       val rule = $"rule";
+
+       if Sec.validRule rule then
+               val id = Sec.Req.add {usr = you, node = nodeNum, data = String.concat ["Add firewall rule \"", uname, " ", rule, "\""], msg = $"msg"};
+               if not (Sec.Req.notifyNew id) then
+                       %><h3>Error sending e-mail notification</h3><%
+               end
+               %><h3>Request added</h3><%
+       else
+               %>"<% Web.html rule %>" is not a valid firewall rule! Please reread <a href="http://wiki.hcoop.net/wiki/FirewallRules">the instructions</a>, and remember to leave off the initial username portion.<%
        end
-       %><h3>Request added</h3><%
 
 elseif $"modRule" <> "" then
        showNormal := false;
@@ -120,7 +132,7 @@ elseif $"cmd" = "open" then
 <br><hr><br>
 <table class="blanks">
 <tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
-<tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td></tr>
 <tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr>
 <tr> <td>Request:</td> <td><% #data req %></td> </tr>
 <tr> <td>Msg:</td> <td colspan="2"><% Web.html (#msg req) %></td> </tr>
@@ -141,7 +153,7 @@ elseif $"cmd" = "list" then
 <br><hr><br>
 <table class="blanks">
 <tr> <td>By:</td> <td colspan="2"><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
-<tr> <td>Time:</td> <td colspan="2"><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td colspan="2"><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td></tr>
 <tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr>
 <tr> <td>Request:</td> <td><% #data req %></td> </tr>
 <tr> <td>Reason:</td> <td colspan="2"><% Web.html (#msg req) %></td> </tr>
@@ -165,7 +177,7 @@ elseif $"mod" <> "" then
 <input type="hidden" name="save" value="<% id %>">
 <table class="blanks">
 <tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr>
-<tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td></tr>
 <tr> <td>Status:</td> <td><select name="status">
        <option value="0"<% if #status req = Sec.Req.NEW then %> selected<% end %>>New</option>
        <option value="1"<% if #status req = Sec.Req.INSTALLED then %> selected<% end %>>Installed</option>
@@ -173,9 +185,9 @@ elseif $"mod" <> "" then
 </select></td> </tr>
 <tr> <td>Node:</td> <td><select name="node">
 <% foreach node in Init.listNodes () do %>
-       <option value="<% #id node %>"<% if nodeNum = #node req then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>)</option>
+       <option value="<% #id node %>"<% if #id node = #node req then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>)</option>
 <% end %></select></td> </tr>
-<tr> <td>Request:</td> <td><input name="req" value="<% #data req %>"></td> </tr>
+<tr> <td>Request:</td> <td><input name="req" value="<% Web.html (#data req) %>"></td> </tr>
 <tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr>
 <tr> <td><input type="submit" value="Save"></td> </tr>
 </table>
@@ -189,10 +201,8 @@ elseif $"mod" <> "" then
        val oldStatus = #status req;
        val newStatus = Sec.Req.statusFromInt (Web.stoi ($"status"));
        Sec.Req.modify {req with node = nodeNum, data = $"req", msg = $"msg", status = newStatus};
-       if oldStatus <> newStatus then
-               if not (Sec.Req.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then
-                       %><h3>Error sending e-mail notification</h3><%
-               end
+       if not (Sec.Req.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then
+               %><h3>Error sending e-mail notification</h3><%
        end
        %><h3>Request modified</h3>
        Back to: <a href="sec?cmd=open">open requests</a>, <a href="sec?cmd=list">all requests</a>
@@ -237,7 +247,11 @@ if showNormal then %>
 </form>
 </table>
 
-<h3>Request socket permissions change</h3>
+<!--h3>Request socket permissions change</h3>
+
+<p>You need to request socket permissions before you are able to open any network connections. While you will be limited by firewall rules even then, any requests for firewall rules you enter in the "Reason" blank here <b>will be ignored</b>. Please use the separate form at the bottom of this page for that. There is no need to wait until a request for socket permissions has been granted before starting to request firewall rules.</p>
+
+<p>Keep in mind that, if your request is granted, it will never apply to existing log-in sessions. Close them and re-connect to take advantage of your new privileges.</p>
 
 <form action="sec" method="post">
 <input type="hidden" name="node" value="<% nodeNum %>">
@@ -269,7 +283,7 @@ if showNormal then %>
 <tr> <td>Reason:</td> <td><textarea name="msg" wrap="soft" rows="3" cols="80"></textarea></td> </tr>
 <tr> <td><input type="submit" value="Request"></td> </tr>
 </table>
-</form>
+</form-->
 
 <h3>Request change to your <tt>cron</tt> permissions</h3>
 
@@ -324,9 +338,11 @@ end%>
 
 <h3>Request a new firewall rule</h3>
 
-<p>You can find a description of rule formats <a href="http://wiki.hcoop.net/wiki/FirewallRules">on our wiki</a>. Enter here the rule you want, without the initial <tt>user</tt> portion.</p>
+<p>You can find a description of rule formats <a href="http://wiki.hcoop.net/FirewallRules">on our wiki</a>. Enter here the rule you want, without the initial <tt>user</tt> portion.</p>
+
+<p>When requesting a <tt>Server</tt> or <tt>ProxiedServer</tt> rule, use a port above <tt>50000</tt> (there is a list of <a href="http://wiki.hcoop.net/wiki/AllocatedFirewallPorts">allocated ports</a>). We may grant <tt>Server</tt> requests for ports under <tt>50000</tt> if it can be justified, but never for a <tt>ProxiedServer</tt>.</p>
 
-<p>Please note that <b>your firewall rule will be useless</b> if you don't first request the corresponding socket privileges at the top of this page.</p>
+<p>We very rarely grant requests for Client rules that don't include remote host whitelists. For example, important security concerns make it a bad idea for us to give anybody blanket IRC permissions. Instead, request specific servers. We will refuse such requests that include networks that are popularly considered fronts for illegal activity.</p>
 
 <form action="sec" method="post">
 <input type="hidden" name="node" value="<% nodeNum %>">