2 local fw = require "luci.model.firewall".init()
3 local wz = fw:get_zone("wan")
4 local lz = fw:get_zone("lan")
7 <div class="cbi-section-create cbi-tblsection-create">
8 <% if wz and lz then %>
10 <table class="cbi-section-table" style="margin-left:5px">
11 <tr class="cbi-section-table-titles">
12 <th class="cbi-section-table-cell left" colspan="4"><%:Open ports on router%>:</th>
14 <tr class="cbi-section-table-descr">
15 <th class="cbi-section-table-cell"><%:Name%></th>
16 <th class="cbi-section-table-cell"><%:Protocol%></th>
17 <th class="cbi-section-table-cell"><%:External port%></th>
18 <th class="cbi-section-table-cell"></th>
20 <tr class="cbi-section-table-row">
21 <td class="cbi-section-table-cell" style="width:130px">
22 <input type="text" class="cbi-input-text" id="_newopen.name" name="_newopen.name" placeholder="<%:New input rule%>" />
24 <td class="cbi-section-table-cell" style="width:110px">
25 <select class="cbi-input-select" id="_newopen.proto" name="_newopen.proto">
26 <option value="tcp udp">TCP+UDP</option>
27 <option value="tcp">TCP</option>
28 <option value="udp">UDP</option>
29 <option value="other"><%:Other...%></option>
32 <td class="cbi-section-table-cell" style="width:110px">
33 <input type="text" class="cbi-input-text" id="_newopen.extport" name="_newopen.extport" />
35 <td class="cbi-section-table-cell left">
36 <input type="submit" class="cbi-button cbi-button-add" name="_newopen.submit" value="<%:Add%>" />
41 <table class="cbi-section-table" style="margin-left:5px">
42 <tr class="cbi-section-table-titles">
43 <th class="cbi-section-table-cell left" colspan="6"><br /><%:New forward rule%>:</th>
45 <tr class="cbi-section-table-descr">
46 <th class="cbi-section-table-cell"><%:Name%></th>
47 <th class="cbi-section-table-cell"><%:Source zone%></th>
48 <th class="cbi-section-table-cell"><%:Destination zone%></th>
49 <th class="cbi-section-table-cell"></th>
51 <tr class="cbi-section-table-row">
52 <td class="cbi-section-table-cell" style="width:130px">
53 <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New forward rule%>" />
55 <td class="cbi-section-table-cell" style="width:110px">
56 <select class="cbi-input-text" id="_newfwd.src" name="_newfwd.src">
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>
62 <td class="cbi-section-table-cell" style="width:110px">
63 <select class="cbi-input-text" id="_newfwd.dest" name="_newfwd.dest">
64 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
65 <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
69 <td class="cbi-section-table-cell left">
70 <input type="submit" class="cbi-button cbi-button-link" name="_newfwd.submit" value="<%:Add and edit...%>" />
75 <script type="text/javascript">//<![CDATA[
76 cbi_validate_field('_newopen.extport', true, 'list(neg(portrange))');
77 cbi_bind(document.getElementById('_newopen.extport'), 'blur',
79 var n = document.getElementById('_newopen.name');
80 var p = document.getElementById('_newopen.proto');
82 /* port name 0=both, 1=tcp, 2=udp, 3=other */
89 if (!this.className.match(/invalid/))
91 var hint = hints[this.value || 0];
94 p.selectedIndex = hint[1];
99 else if (!n.value && this.value)
101 n.value = 'Open' + this.value;
107 cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
110 <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />