applications/luci-firewall: fix wrong location of cbi templates
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 20 Dec 2011 15:09:38 +0000 (15:09 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 20 Dec 2011 15:09:38 +0000 (15:09 +0000)
applications/luci-firewall/luasrc/view/cbi_addforward.htm [deleted file]
applications/luci-firewall/luasrc/view/cbi_addrule.htm [deleted file]
applications/luci-firewall/luasrc/view/cbi_addsnat.htm [deleted file]
applications/luci-firewall/luasrc/view/firewall/cbi_addforward.htm [new file with mode: 0644]
applications/luci-firewall/luasrc/view/firewall/cbi_addrule.htm [new file with mode: 0644]
applications/luci-firewall/luasrc/view/firewall/cbi_addsnat.htm [new file with mode: 0644]

diff --git a/applications/luci-firewall/luasrc/view/cbi_addforward.htm b/applications/luci-firewall/luasrc/view/cbi_addforward.htm
deleted file mode 100644 (file)
index 6a49266..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<div class="cbi-section-create cbi-tblsection-create">
-       <br />
-       <table class="cbi-section-table" style="width:700px; margin-left:5px">
-               <tr class="cbi-section-table-titles">
-                       <th class="cbi-section-table-cell" colspan="6"><%:New port forward%>:</th>
-               </tr>
-               <tr class="cbi-section-table-descr">
-                       <th class="cbi-section-table-cell"><%:Name%></th>
-                       <th class="cbi-section-table-cell"><%:Protocol%></th>
-                       <th class="cbi-section-table-cell"><%:External port%></th>
-                       <th class="cbi-section-table-cell"><%:Internal IP address%></th>
-                       <th class="cbi-section-table-cell"><%:Internal port%></th>
-                       <th class="cbi-section-table-cell"></th>
-               </tr>
-               <tr class="cbi-section-table-row">
-                       <td class="cbi-section-table-cell">
-                               <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New port forward%>" />
-                       </td>
-                       <td class="cbi-section-table-cell" style="width:110px">
-                               <select class="cbi-input-select" id="_newfwd.proto" name="_newfwd.proto">
-                                       <option value="tcp udp">TCP+UDP</option>
-                                       <option value="tcp">TCP</option>
-                                       <option value="udp">UDP</option>
-                                       <option value="other"><%:Other...%></option>
-                               </select>
-                       </td>
-                       <td class="cbi-section-table-cell" style="width:110px">
-                               <input type="text" class="cbi-input-text" id="_newfwd.extport" name="_newfwd.extport" />
-                       </td>
-                       <td class="cbi-section-table-cell" style="width:110px">
-                               <input type="text" class="cbi-input-text" id="_newfwd.intaddr" name="_newfwd.intaddr" />
-                       </td>
-                       <td class="cbi-section-table-cell" style="width:110px">
-                               <input type="text" class="cbi-input-text" id="_newfwd.intport" name="_newfwd.intport" />
-                       </td>
-                       <td class="cbi-section-table-cell">
-                               <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
-                       </td>
-               </tr>
-       </table>
-
-       <script type="text/javascript">//<![CDATA[
-               cbi_validate_field('_newfwd.extport', true, 'portrange');
-               cbi_validate_field('_newfwd.intaddr', true, 'host');
-               cbi_validate_field('_newfwd.intport', true, 'portrange');
-
-               cbi_combobox_init('_newfwd.intaddr', {
-                       <% local i, e; for i, e in ipairs(luci.sys.net.arptable()) do -%>
-                               <%- if i > 1 then %>,<% end -%>'<%=e["IP address"]%>': '<%=e["IP address"]%>'
-                       <%- end %> }, '', '<%: -- custom -- %>');
-
-               cbi_bind(document.getElementById('_newfwd.extport'), 'blur',
-                       function() {
-                               var n = document.getElementById('_newfwd.name');
-                               var p = document.getElementById('_newfwd.proto');
-                               var i = document.getElementById('_newfwd.intport');
-                               var hints = {
-                               /*  port    name     0=both, 1=tcp, 2=udp, 3=other */
-                                       21:   [ 'FTP',   1 ],
-                                       22:   [ 'SSH',   1 ],
-                                       53:   [ 'DNS',   0 ],
-                                       80:   [ 'HTTP',  1 ],
-                                       443:  [ 'HTTPS', 1 ],
-                                       3389: [ 'RDP',   1 ],
-                                       5900: [ 'VNC',   1 ],
-                               };
-
-                               if (!this.className.match(/invalid/))
-                               {
-                                       if (!i.value) i.value = this.value;
-
-                                       var hint = hints[this.value || 0] || hints[i.value || 0];
-                                       if (hint)
-                                       {
-                                               p.selectedIndex = hint[1];
-
-                                               if (!n.value)
-                                                       n.value = hint[0];
-                                       }
-                                       else if (!n.value)
-                                       {
-                                               n.value = 'Forward' + this.value;
-                                       }
-                               }
-                       });
-
-
-               cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
-       //]]></script>
-</div>
diff --git a/applications/luci-firewall/luasrc/view/cbi_addrule.htm b/applications/luci-firewall/luasrc/view/cbi_addrule.htm
deleted file mode 100644 (file)
index 473f9f4..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-<%
-       local fw = require "luci.model.firewall".init()
-       local wz = fw:get_zone("wan")
-       local lz = fw:get_zone("lan")
-%>
-
-<div class="cbi-section-create cbi-tblsection-create">
-       <% if wz and lz then %>
-               <br />
-               <table class="cbi-section-table" style="margin-left:5px">
-                       <tr class="cbi-section-table-titles">
-                               <th class="cbi-section-table-cell left" colspan="4"><%:Open ports on router%>:</th>
-                       </tr>
-                       <tr class="cbi-section-table-descr">
-                               <th class="cbi-section-table-cell"><%:Name%></th>
-                               <th class="cbi-section-table-cell"><%:Protocol%></th>
-                               <th class="cbi-section-table-cell"><%:External port%></th>
-                               <th class="cbi-section-table-cell"></th>
-                       </tr>
-                       <tr class="cbi-section-table-row">
-                               <td class="cbi-section-table-cell" style="width:130px">
-                                       <input type="text" class="cbi-input-text" id="_newopen.name" name="_newopen.name" placeholder="<%:New input rule%>" />
-                               </td>
-                               <td class="cbi-section-table-cell" style="width:110px">
-                                       <select class="cbi-input-select" id="_newopen.proto" name="_newopen.proto">
-                                               <option value="tcp udp">TCP+UDP</option>
-                                               <option value="tcp">TCP</option>
-                                               <option value="udp">UDP</option>
-                                               <option value="other"><%:Other...%></option>
-                                       </select>
-                               </td>
-                               <td class="cbi-section-table-cell" style="width:110px">
-                                       <input type="text" class="cbi-input-text" id="_newopen.extport" name="_newopen.extport" />
-                               </td>
-                               <td class="cbi-section-table-cell left">
-                                       <input type="submit" class="cbi-button cbi-button-add" name="_newopen.submit" value="<%:Add%>" />
-                               </td>
-                       </tr>
-               </table>
-
-               <table class="cbi-section-table" style="margin-left:5px">
-                       <tr class="cbi-section-table-titles">
-                               <th class="cbi-section-table-cell left" colspan="6"><br /><%:New forward rule%>:</th>
-                       </tr>
-                       <tr class="cbi-section-table-descr">
-                               <th class="cbi-section-table-cell"><%:Name%></th>
-                               <th class="cbi-section-table-cell"><%:Source zone%></th>
-                               <th class="cbi-section-table-cell"><%:Destination zone%></th>
-                               <th class="cbi-section-table-cell"></th>
-                       </tr>
-                       <tr class="cbi-section-table-row">
-                               <td class="cbi-section-table-cell" style="width:130px">
-                                       <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New forward rule%>" />
-                               </td>
-                               <td class="cbi-section-table-cell" style="width:110px">
-                                       <select class="cbi-input-text" id="_newfwd.src" name="_newfwd.src">
-                                               <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
-                                                       <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
-                                               <%- end %>
-                                       </select>
-                               </td>
-                               <td class="cbi-section-table-cell" style="width:110px">
-                                       <select class="cbi-input-text" id="_newfwd.dest" name="_newfwd.dest">
-                                               <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
-                                                       <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
-                                               <%- end %>
-                                       </select>
-                               </td>
-                               <td class="cbi-section-table-cell left">
-                                       <input type="submit" class="cbi-button cbi-button-link" name="_newfwd.submit" value="<%:Add and edit...%>" />
-                               </td>
-                       </tr>
-               </table>
-
-               <script type="text/javascript">//<![CDATA[
-                       cbi_validate_field('_newopen.extport', true, 'list(portrange)');
-                       cbi_bind(document.getElementById('_newopen.extport'), 'blur',
-                               function() {
-                                       var n = document.getElementById('_newopen.name');
-                                       var p = document.getElementById('_newopen.proto');
-                                       var hints = {
-                                       /*  port    name     0=both, 1=tcp, 2=udp, 3=other */
-                                               22:   [ 'SSH',   1 ],
-                                               53:   [ 'DNS',   0 ],
-                                               80:   [ 'HTTP',  1 ],
-                                               443:  [ 'HTTPS', 1 ],
-                                       };
-
-                                       if (!this.className.match(/invalid/))
-                                       {
-                                               var hint = hints[this.value || 0];
-                                               if (hint)
-                                               {
-                                                       p.selectedIndex = hint[1];
-
-                                                       if (!n.value)
-                                                               n.value = hint[0];
-                                               }
-                                               else if (!n.value && this.value)
-                                               {
-                                                       n.value = 'Open' + this.value;
-                                               }
-                                       }
-                               });
-
-
-                       cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
-               //]]></script>
-       <% else %>
-               <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
-       <% end %>
-</div>
diff --git a/applications/luci-firewall/luasrc/view/cbi_addsnat.htm b/applications/luci-firewall/luasrc/view/cbi_addsnat.htm
deleted file mode 100644 (file)
index 28bb22d..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<%
-       local fw = require "luci.model.firewall".init()
-       local nw = require "luci.model.network".init()
-       local wz = fw:get_zone("wan")
-       local lz = fw:get_zone("lan")
-%>
-
-<div class="cbi-section-create cbi-tblsection-create">
-       <% if wz and lz then %>
-               <br />
-               <table class="cbi-section-table" style="width:700px; margin-left:5px">
-                       <tr class="cbi-section-table-titles">
-                               <th class="cbi-section-table-cell left" colspan="6"><%:New source NAT%>:</th>
-                       </tr>
-                       <tr class="cbi-section-table-descr">
-                               <th class="cbi-section-table-cell"><%:Name%></th>
-                               <th class="cbi-section-table-cell"><%:Source zone%></th>
-                               <th class="cbi-section-table-cell"><%:Destination zone%></th>
-                               <th class="cbi-section-table-cell"><%:To source IP%></th>
-                               <th class="cbi-section-table-cell"><%:To source port%></th>
-                               <th class="cbi-section-table-cell"></th>
-                       </tr>
-                       <tr class="cbi-section-table-row">
-                               <td class="cbi-section-table-cell">
-                                       <input type="text" class="cbi-input-text" id="_newsnat.name" name="_newsnat.name" placeholder="<%:New SNAT rule%>" />
-                               </td>
-                               <td class="cbi-section-table-cell" style="width:110px">
-                                       <select class="cbi-input-text" id="_newsnat.src" name="_newsnat.src">
-                                               <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
-                                                       <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
-                                               <%- end %>
-                                       </select>
-                               </td>
-                               <td class="cbi-section-table-cell" style="width:110px">
-                                       <select class="cbi-input-text" id="_newsnat.dest" name="_newsnat.dest">
-                                               <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
-                                                       <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
-                                               <%- end %>
-                                       </select>
-                               </td>
-                               <td class="cbi-section-table-cell" style="width:110px">
-                                       <input type="text" class="cbi-input-text" id="_newsnat.dip" name="_newsnat.dip" />
-                               </td>
-                               <td class="cbi-section-table-cell" style="width:110px">
-                                       <input type="text" class="cbi-input-text" id="_newsnat.dport" name="_newsnat.dport" placeholder="<%:Do not rewrite%>" />
-                               </td>
-                               <td class="cbi-section-table-cell">
-                                       <input type="submit" class="cbi-button cbi-button-link" name="_newsnat.submit" value="<%:Add and edit...%>" />
-                               </td>
-                       </tr>
-               </table>
-
-               <script type="text/javascript">//<![CDATA[
-                       cbi_validate_field('_newsnat.dport', true, 'portrange');
-                       cbi_combobox_init('_newsnat.dip', {
-                               <% local c, k, v = 0; for k, v in ipairs(nw:get_interfaces()) do -%>
-                                       <%- local a; for k, a in ipairs(v:ipaddrs()) do c = c + 1 -%>
-                                               <% if c > 1 then %>,<% end %>'<%=a:host():string()%>': '<%=a:host():string()%> (<%=v:shortname()%>)',
-                                       <%- end %>
-                               <%- end %> }, '<%: -- Please choose -- %>', '<%: -- custom -- %>');
-               //]]></script>
-       <% else %>
-               <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
-       <% end %>
-</div>
diff --git a/applications/luci-firewall/luasrc/view/firewall/cbi_addforward.htm b/applications/luci-firewall/luasrc/view/firewall/cbi_addforward.htm
new file mode 100644 (file)
index 0000000..6a49266
--- /dev/null
@@ -0,0 +1,90 @@
+<div class="cbi-section-create cbi-tblsection-create">
+       <br />
+       <table class="cbi-section-table" style="width:700px; margin-left:5px">
+               <tr class="cbi-section-table-titles">
+                       <th class="cbi-section-table-cell" colspan="6"><%:New port forward%>:</th>
+               </tr>
+               <tr class="cbi-section-table-descr">
+                       <th class="cbi-section-table-cell"><%:Name%></th>
+                       <th class="cbi-section-table-cell"><%:Protocol%></th>
+                       <th class="cbi-section-table-cell"><%:External port%></th>
+                       <th class="cbi-section-table-cell"><%:Internal IP address%></th>
+                       <th class="cbi-section-table-cell"><%:Internal port%></th>
+                       <th class="cbi-section-table-cell"></th>
+               </tr>
+               <tr class="cbi-section-table-row">
+                       <td class="cbi-section-table-cell">
+                               <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New port forward%>" />
+                       </td>
+                       <td class="cbi-section-table-cell" style="width:110px">
+                               <select class="cbi-input-select" id="_newfwd.proto" name="_newfwd.proto">
+                                       <option value="tcp udp">TCP+UDP</option>
+                                       <option value="tcp">TCP</option>
+                                       <option value="udp">UDP</option>
+                                       <option value="other"><%:Other...%></option>
+                               </select>
+                       </td>
+                       <td class="cbi-section-table-cell" style="width:110px">
+                               <input type="text" class="cbi-input-text" id="_newfwd.extport" name="_newfwd.extport" />
+                       </td>
+                       <td class="cbi-section-table-cell" style="width:110px">
+                               <input type="text" class="cbi-input-text" id="_newfwd.intaddr" name="_newfwd.intaddr" />
+                       </td>
+                       <td class="cbi-section-table-cell" style="width:110px">
+                               <input type="text" class="cbi-input-text" id="_newfwd.intport" name="_newfwd.intport" />
+                       </td>
+                       <td class="cbi-section-table-cell">
+                               <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
+                       </td>
+               </tr>
+       </table>
+
+       <script type="text/javascript">//<![CDATA[
+               cbi_validate_field('_newfwd.extport', true, 'portrange');
+               cbi_validate_field('_newfwd.intaddr', true, 'host');
+               cbi_validate_field('_newfwd.intport', true, 'portrange');
+
+               cbi_combobox_init('_newfwd.intaddr', {
+                       <% local i, e; for i, e in ipairs(luci.sys.net.arptable()) do -%>
+                               <%- if i > 1 then %>,<% end -%>'<%=e["IP address"]%>': '<%=e["IP address"]%>'
+                       <%- end %> }, '', '<%: -- custom -- %>');
+
+               cbi_bind(document.getElementById('_newfwd.extport'), 'blur',
+                       function() {
+                               var n = document.getElementById('_newfwd.name');
+                               var p = document.getElementById('_newfwd.proto');
+                               var i = document.getElementById('_newfwd.intport');
+                               var hints = {
+                               /*  port    name     0=both, 1=tcp, 2=udp, 3=other */
+                                       21:   [ 'FTP',   1 ],
+                                       22:   [ 'SSH',   1 ],
+                                       53:   [ 'DNS',   0 ],
+                                       80:   [ 'HTTP',  1 ],
+                                       443:  [ 'HTTPS', 1 ],
+                                       3389: [ 'RDP',   1 ],
+                                       5900: [ 'VNC',   1 ],
+                               };
+
+                               if (!this.className.match(/invalid/))
+                               {
+                                       if (!i.value) i.value = this.value;
+
+                                       var hint = hints[this.value || 0] || hints[i.value || 0];
+                                       if (hint)
+                                       {
+                                               p.selectedIndex = hint[1];
+
+                                               if (!n.value)
+                                                       n.value = hint[0];
+                                       }
+                                       else if (!n.value)
+                                       {
+                                               n.value = 'Forward' + this.value;
+                                       }
+                               }
+                       });
+
+
+               cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
+       //]]></script>
+</div>
diff --git a/applications/luci-firewall/luasrc/view/firewall/cbi_addrule.htm b/applications/luci-firewall/luasrc/view/firewall/cbi_addrule.htm
new file mode 100644 (file)
index 0000000..473f9f4
--- /dev/null
@@ -0,0 +1,112 @@
+<%
+       local fw = require "luci.model.firewall".init()
+       local wz = fw:get_zone("wan")
+       local lz = fw:get_zone("lan")
+%>
+
+<div class="cbi-section-create cbi-tblsection-create">
+       <% if wz and lz then %>
+               <br />
+               <table class="cbi-section-table" style="margin-left:5px">
+                       <tr class="cbi-section-table-titles">
+                               <th class="cbi-section-table-cell left" colspan="4"><%:Open ports on router%>:</th>
+                       </tr>
+                       <tr class="cbi-section-table-descr">
+                               <th class="cbi-section-table-cell"><%:Name%></th>
+                               <th class="cbi-section-table-cell"><%:Protocol%></th>
+                               <th class="cbi-section-table-cell"><%:External port%></th>
+                               <th class="cbi-section-table-cell"></th>
+                       </tr>
+                       <tr class="cbi-section-table-row">
+                               <td class="cbi-section-table-cell" style="width:130px">
+                                       <input type="text" class="cbi-input-text" id="_newopen.name" name="_newopen.name" placeholder="<%:New input rule%>" />
+                               </td>
+                               <td class="cbi-section-table-cell" style="width:110px">
+                                       <select class="cbi-input-select" id="_newopen.proto" name="_newopen.proto">
+                                               <option value="tcp udp">TCP+UDP</option>
+                                               <option value="tcp">TCP</option>
+                                               <option value="udp">UDP</option>
+                                               <option value="other"><%:Other...%></option>
+                                       </select>
+                               </td>
+                               <td class="cbi-section-table-cell" style="width:110px">
+                                       <input type="text" class="cbi-input-text" id="_newopen.extport" name="_newopen.extport" />
+                               </td>
+                               <td class="cbi-section-table-cell left">
+                                       <input type="submit" class="cbi-button cbi-button-add" name="_newopen.submit" value="<%:Add%>" />
+                               </td>
+                       </tr>
+               </table>
+
+               <table class="cbi-section-table" style="margin-left:5px">
+                       <tr class="cbi-section-table-titles">
+                               <th class="cbi-section-table-cell left" colspan="6"><br /><%:New forward rule%>:</th>
+                       </tr>
+                       <tr class="cbi-section-table-descr">
+                               <th class="cbi-section-table-cell"><%:Name%></th>
+                               <th class="cbi-section-table-cell"><%:Source zone%></th>
+                               <th class="cbi-section-table-cell"><%:Destination zone%></th>
+                               <th class="cbi-section-table-cell"></th>
+                       </tr>
+                       <tr class="cbi-section-table-row">
+                               <td class="cbi-section-table-cell" style="width:130px">
+                                       <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New forward rule%>" />
+                               </td>
+                               <td class="cbi-section-table-cell" style="width:110px">
+                                       <select class="cbi-input-text" id="_newfwd.src" name="_newfwd.src">
+                                               <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
+                                                       <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
+                                               <%- end %>
+                                       </select>
+                               </td>
+                               <td class="cbi-section-table-cell" style="width:110px">
+                                       <select class="cbi-input-text" id="_newfwd.dest" name="_newfwd.dest">
+                                               <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
+                                                       <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
+                                               <%- end %>
+                                       </select>
+                               </td>
+                               <td class="cbi-section-table-cell left">
+                                       <input type="submit" class="cbi-button cbi-button-link" name="_newfwd.submit" value="<%:Add and edit...%>" />
+                               </td>
+                       </tr>
+               </table>
+
+               <script type="text/javascript">//<![CDATA[
+                       cbi_validate_field('_newopen.extport', true, 'list(portrange)');
+                       cbi_bind(document.getElementById('_newopen.extport'), 'blur',
+                               function() {
+                                       var n = document.getElementById('_newopen.name');
+                                       var p = document.getElementById('_newopen.proto');
+                                       var hints = {
+                                       /*  port    name     0=both, 1=tcp, 2=udp, 3=other */
+                                               22:   [ 'SSH',   1 ],
+                                               53:   [ 'DNS',   0 ],
+                                               80:   [ 'HTTP',  1 ],
+                                               443:  [ 'HTTPS', 1 ],
+                                       };
+
+                                       if (!this.className.match(/invalid/))
+                                       {
+                                               var hint = hints[this.value || 0];
+                                               if (hint)
+                                               {
+                                                       p.selectedIndex = hint[1];
+
+                                                       if (!n.value)
+                                                               n.value = hint[0];
+                                               }
+                                               else if (!n.value && this.value)
+                                               {
+                                                       n.value = 'Open' + this.value;
+                                               }
+                                       }
+                               });
+
+
+                       cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
+               //]]></script>
+       <% else %>
+               <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
+       <% end %>
+</div>
diff --git a/applications/luci-firewall/luasrc/view/firewall/cbi_addsnat.htm b/applications/luci-firewall/luasrc/view/firewall/cbi_addsnat.htm
new file mode 100644 (file)
index 0000000..28bb22d
--- /dev/null
@@ -0,0 +1,65 @@
+<%
+       local fw = require "luci.model.firewall".init()
+       local nw = require "luci.model.network".init()
+       local wz = fw:get_zone("wan")
+       local lz = fw:get_zone("lan")
+%>
+
+<div class="cbi-section-create cbi-tblsection-create">
+       <% if wz and lz then %>
+               <br />
+               <table class="cbi-section-table" style="width:700px; margin-left:5px">
+                       <tr class="cbi-section-table-titles">
+                               <th class="cbi-section-table-cell left" colspan="6"><%:New source NAT%>:</th>
+                       </tr>
+                       <tr class="cbi-section-table-descr">
+                               <th class="cbi-section-table-cell"><%:Name%></th>
+                               <th class="cbi-section-table-cell"><%:Source zone%></th>
+                               <th class="cbi-section-table-cell"><%:Destination zone%></th>
+                               <th class="cbi-section-table-cell"><%:To source IP%></th>
+                               <th class="cbi-section-table-cell"><%:To source port%></th>
+                               <th class="cbi-section-table-cell"></th>
+                       </tr>
+                       <tr class="cbi-section-table-row">
+                               <td class="cbi-section-table-cell">
+                                       <input type="text" class="cbi-input-text" id="_newsnat.name" name="_newsnat.name" placeholder="<%:New SNAT rule%>" />
+                               </td>
+                               <td class="cbi-section-table-cell" style="width:110px">
+                                       <select class="cbi-input-text" id="_newsnat.src" name="_newsnat.src">
+                                               <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
+                                                       <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
+                                               <%- end %>
+                                       </select>
+                               </td>
+                               <td class="cbi-section-table-cell" style="width:110px">
+                                       <select class="cbi-input-text" id="_newsnat.dest" name="_newsnat.dest">
+                                               <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
+                                                       <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
+                                               <%- end %>
+                                       </select>
+                               </td>
+                               <td class="cbi-section-table-cell" style="width:110px">
+                                       <input type="text" class="cbi-input-text" id="_newsnat.dip" name="_newsnat.dip" />
+                               </td>
+                               <td class="cbi-section-table-cell" style="width:110px">
+                                       <input type="text" class="cbi-input-text" id="_newsnat.dport" name="_newsnat.dport" placeholder="<%:Do not rewrite%>" />
+                               </td>
+                               <td class="cbi-section-table-cell">
+                                       <input type="submit" class="cbi-button cbi-button-link" name="_newsnat.submit" value="<%:Add and edit...%>" />
+                               </td>
+                       </tr>
+               </table>
+
+               <script type="text/javascript">//<![CDATA[
+                       cbi_validate_field('_newsnat.dport', true, 'portrange');
+                       cbi_combobox_init('_newsnat.dip', {
+                               <% local c, k, v = 0; for k, v in ipairs(nw:get_interfaces()) do -%>
+                                       <%- local a; for k, a in ipairs(v:ipaddrs()) do c = c + 1 -%>
+                                               <% if c > 1 then %>,<% end %>'<%=a:host():string()%>': '<%=a:host():string()%> (<%=v:shortname()%>)',
+                                       <%- end %>
+                               <%- end %> }, '<%: -- Please choose -- %>', '<%: -- custom -- %>');
+               //]]></script>
+       <% else %>
+               <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
+       <% end %>
+</div>