cbi_addrule.htm 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <%
  2. local fw = require "luci.model.firewall".init()
  3. local zones = fw:get_zones()
  4. %>
  5. <% if #zones > 0 then %>
  6. <h4><%:Open ports on router%></h4>
  7. <div class="table">
  8. <div class="tr cbi-section-table-titles">
  9. <div class="th"><%:Name%></div>
  10. <div class="th"><%:Protocol%></div>
  11. <div class="th"><%:External port%></div>
  12. <div class="th"></div>
  13. </div>
  14. <div class="tr">
  15. <div class="td">
  16. <input type="text" class="cbi-input-text" id="_newopen.name" name="_newopen.name" placeholder="<%:New input rule%>" />
  17. </div>
  18. <div class="td">
  19. <select class="cbi-input-select" id="_newopen.proto" name="_newopen.proto">
  20. <option value="tcp udp">TCP+UDP</option>
  21. <option value="tcp">TCP</option>
  22. <option value="udp">UDP</option>
  23. <option value="other"><%:Other...%></option>
  24. </select>
  25. </div>
  26. <div class="td">
  27. <input type="text" class="cbi-input-text" id="_newopen.extport" name="_newopen.extport" />
  28. </div>
  29. <div class="td bottom">
  30. <input type="submit" class="cbi-button cbi-button-add" name="_newopen.submit" value="<%:Add%>" />
  31. </div>
  32. </div>
  33. </div>
  34. <% end %>
  35. <% if #zones > 1 then %>
  36. <h4><%:New forward rule%></h4>
  37. <div class="table">
  38. <div class="tr cbi-section-table-titles">
  39. <div class="th"><%:Name%></div>
  40. <div class="th"><%:Source zone%></div>
  41. <div class="th"><%:Destination zone%></div>
  42. <div class="th"></div>
  43. </div>
  44. <div class="tr">
  45. <div class="td">
  46. <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New forward rule%>" />
  47. </div>
  48. <div class="td">
  49. <select class="cbi-input-text" id="_newfwd.src" name="_newfwd.src">
  50. <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
  51. <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
  52. <%- end %>
  53. </select>
  54. </div>
  55. <div class="td">
  56. <select class="cbi-input-text" id="_newfwd.dest" name="_newfwd.dest">
  57. <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
  58. <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
  59. <%- end %>
  60. </select>
  61. </div>
  62. <div class="td bottom">
  63. <input type="submit" class="cbi-button cbi-button-link" name="_newfwd.submit" value="<%:Add and edit...%>" />
  64. </div>
  65. </div>
  66. </div>
  67. <% else %>
  68. <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
  69. <% end %>
  70. <% if #zones > 0 then %>
  71. <script type="text/javascript">//<![CDATA[
  72. cbi_validate_field('_newopen.extport', true, 'list(neg(portrange))');
  73. document.getElementById('_newopen.extport').addEventListener('blur',
  74. function() {
  75. var n = document.getElementById('_newopen.name');
  76. var p = document.getElementById('_newopen.proto');
  77. if (!this.className.match(/invalid/))
  78. {
  79. if (!n.value && this.value)
  80. {
  81. n.value = 'Open' + this.value;
  82. }
  83. }
  84. });
  85. //]]></script>
  86. <% end %>