2 local fw = require "luci.model.firewall".init()
3 local wz = fw:get_zone("wan")
4 local lz = fw:get_zone("lan")
5 local zones = fw:get_zones()
8 <div class="cbi-section-create cbi-tblsection-create">
11 <table class="cbi-section-table" style="margin-left:5px">
12 <tr class="cbi-section-table-titles">
13 <th class="cbi-section-table-cell left" colspan="4"><%:Open ports on router%>:</th>
15 <tr class="cbi-section-table-descr">
16 <th class="cbi-section-table-cell"><%:Name%></th>
17 <th class="cbi-section-table-cell"><%:Protocol%></th>
18 <th class="cbi-section-table-cell"><%:External port%></th>
19 <th class="cbi-section-table-cell"></th>
21 <tr class="cbi-section-table-row">
22 <td class="cbi-section-table-cell" style="width:130px">
23 <input type="text" class="cbi-input-text" id="_newopen.name" name="_newopen.name" placeholder="<%:New input rule%>" />
25 <td class="cbi-section-table-cell" style="width:110px">
26 <select class="cbi-input-select" id="_newopen.proto" name="_newopen.proto">
27 <option value="tcp udp">TCP+UDP</option>
28 <option value="tcp">TCP</option>
29 <option value="udp">UDP</option>
30 <option value="other"><%:Other...%></option>
33 <td class="cbi-section-table-cell" style="width:110px">
34 <input type="text" class="cbi-input-text" id="_newopen.extport" name="_newopen.extport" />
36 <td class="cbi-section-table-cell left">
37 <input type="submit" class="cbi-button cbi-button-add" name="_newopen.submit" value="<%:Add%>" />
42 <% if #zones > 1 then %>
43 <table class="cbi-section-table" style="margin-left:5px">
44 <tr class="cbi-section-table-titles">
45 <th class="cbi-section-table-cell left" colspan="6"><br /><%:New forward rule%>:</th>
47 <tr class="cbi-section-table-descr">
48 <th class="cbi-section-table-cell"><%:Name%></th>
49 <th class="cbi-section-table-cell"><%:Source zone%></th>
50 <th class="cbi-section-table-cell"><%:Destination zone%></th>
51 <th class="cbi-section-table-cell"></th>
53 <tr class="cbi-section-table-row">
54 <td class="cbi-section-table-cell" style="width:130px">
55 <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New forward rule%>" />
57 <td class="cbi-section-table-cell" style="width:110px">
58 <select class="cbi-input-text" id="_newfwd.src" name="_newfwd.src">
59 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
60 <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
64 <td class="cbi-section-table-cell" style="width:110px">
65 <select class="cbi-input-text" id="_newfwd.dest" name="_newfwd.dest">
66 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
67 <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
71 <td class="cbi-section-table-cell left">
72 <input type="submit" class="cbi-button cbi-button-link" name="_newfwd.submit" value="<%:Add and edit...%>" />
77 <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
81 <script type="text/javascript">//<![CDATA[
82 cbi_validate_field('_newopen.extport', true, 'list(neg(portrange))');
83 cbi_bind(document.getElementById('_newopen.extport'), 'blur',
85 var n = document.getElementById('_newopen.name');
86 var p = document.getElementById('_newopen.proto');
88 /* port name 0=both, 1=tcp, 2=udp, 3=other */
95 if (!this.className.match(/invalid/))
97 var hint = hints[this.value || 0];
100 p.selectedIndex = hint[1];
105 else if (!n.value && this.value)
107 n.value = 'Open' + this.value;
113 cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');