Edit template for controller - Refine params copy and bring DB opens up to spec with UTF8

This commit is contained in:
2025-10-06 10:57:00 +01:00
parent 29f8de63fd
commit ecb846fc6c
119 changed files with 10059 additions and 36 deletions

View File

@@ -0,0 +1,122 @@
<div>
% my $retref = $c->stash("ret");
% my %ret = $retref ? %$retref : (ret => "");
% my @vars = split(/,/, $ret{vars} // "");
% my ($var1, $var2, $var3, $var4, $var5, $var6, $var7) = @vars;
<br>
% if (config->{debug} == 1) {
<pre>
<%= dumper $c->current_route %>
<%= dumper $c->stash("ret") %>
</pre>
% }
% if ($ret{"ret"} eq "") {
<div>
<%= $c->render_to_string(inline => l("pf_FIRST_PAGE_DESCRIPTION")); %>
</div>
% } elsif (index($ret{ret},"SUCCESS") != -1) {
<div>
<!--<h2> Operation Status Report</h2>-->
<%= $c->render_to_string(inline => l($ret{ret}, @vars[0..6])) %>
</div>
% } else {
<div class="text-danger">
<!--<h2> Operation Status Report - Error</h2>-->
<%= $c->render_to_string(inline => l($ret{ret}, @vars[0..6])) %>
</div>
% }
<br>
<h2><%= l "pf_CREATE_RULE" %></h2>
<form action="/smanager/portforwardingb" method="POST">
<br>
<div>
<%= l "pf_SUMMARY_ADD_DESC" %>
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-1">
<%= l "Protocol" %>
</div>
<div class="col-auto">
<%=select_field "proto"=>["TCP","UDP"], class => "form-select" %>
</div>
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-1">
<label for="inputSourcePort" class="col-form-label"><%= l "pf_LABEL_SOURCE_PORT" %></label>
</div>
<div class="col-auto">
<input type="text" name="sport" id="inputSourcePort" class="form-control" aria-describedby="Source Port">
</div>
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-1">
<label for="inputDestinationPort" class="col-form-label"><%= l "pf_LABEL_DESTINATION_PORT" %></label>
</div>
<div class="col-auto">
<input type="text" name="port" id="inputDestinationPort" class="form-control" aria-describedby="Destination Port">
</div>
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-1">
<label for="inputDestinationHost" class="col-form-label"><%= l "pf_LABEL_DESTINATION_HOST" %></label>
</div>
<div class="col-auto">
<input type="text" name="dhost" id="inputDestinationHost" class="form-control" aria-describedby="Destination Host">
</div>
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-1">
<label for="inputAllowHosts" class="col-form-label"><%= l "pf_ALLOW_HOSTS" %></label>
</div>
<div class="col-auto">
<input type="text" name="allow" id="inputAllowHosts" class="form-control" aria-describedby="Allow Hosts">
</div>
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-1">
<label for="inputRuleComment" class="col-form-label"><%= l "pf_RULE_COMMENT" %></label>
</div>
<div class="col-auto">
<input type="text" name="cmmnt" id="inputRuleComment" class="form-control" aria-describedby="Comment">
</div>
</div>
<br>
% my $btn = l("ADD");
<div class="row g-3 align-items-center">
<div class="col-md-1">
<button type="submit" class="btn btn-primary btn-sm"><%= $btn %></button>
</div>
</div>
</form>
</div>

View File

@@ -0,0 +1,98 @@
<div>
% my $proto = $pf_datas->{proto};
% my $sport = $pf_datas->{sport};
% my $dport = $pf_datas->{dport};
% my $dhost = $pf_datas->{dhost};
% my $cmmnt = $pf_datas->{cmmnt};
% my $allow = $pf_datas->{allow};
% if (config->{debug} == 1) {
<pre>
<%= dumper $c->current_route %>
<%= dumper $c->stash("ret") %>
<%= dumper %$pf_datas %>
</pre>
% }
<form action="/smanager/portforwardinge" method="POST">
<br>
<div>
<%= l "pf_SUMMARY_REMOVE_DESC" %>
</div>
<br>
<table>
<thead>
<th class="col-md-4">&nbsp</th>
<th class="col-md-4">&nbsp</th>
</thead>
<tbody>
<tr >
<td>
<%= l "Protocol" %>
</td>
<td>
<%= $proto %>
</td>
</tr>
<tr>
<td>
<%= l "pf_LABEL_SOURCE_PORT" %>
</td>
<td>
<%= $sport %>
</td>
<tr>
<tr>
<td>
<%= l "pf_LABEL_DESTINATION_HOST" %>
</td>
<td>
<%= $dport %>
</td>
</tr>
<tr>
<td>
<%= l "pf_LABEL_DESTINATION_PORT" %>
</td>
<td>
<%= $dhost %>
</td>
</tr>
<tr>
<td>
<%= l "pf_RULE_COMMENT" %>
</td>
<td>
<%= $cmmnt %>
</td>
</tr>
<tr>
<td>
<%= l "pf_ALLOW_HOSTS" %>
</td>
<td>
<%= $allow %>
</td>
</tr>
</tbody>
</table>
<br>
<%= hidden_field sport=>$sport %>
<%= hidden_field proto=>$proto %>
% my $btn = l("REMOVE");
<div class="row g-3 align-items-center">
<div class="col-md-1">
<button type="submit" class="btn btn-primary btn-sm"><%= $btn %></button>
</div>
</div>
</form>
</div>

View File

@@ -0,0 +1,111 @@
<div>
% my $retref = $c->stash("ret");
% my %ret = $retref ? %$retref : (ret => "");
% my @vars = split(/,/, $ret{vars} // "");
% my ($var1, $var2, $var3, $var4, $var5, $var6, $var7) = @vars;
% my $numtcpforwards = @$tcpforwards;
% my $numudpforwards = @$udpforwards;
% if ($c->app->config->{debug}) {
<pre>
<%= dumper { ret_data => \%ret } %>
</pre>
% }
% if ($ret{ret} eq "") {
<div>
<%= $c->render_to_string(inline => l("pf_FIRST_PAGE_DESCRIPTION")); %>
</div>
% } elsif (index($ret{ret},"SUCCESS") != -1) {
<div>
<h2> Operation Status Report</h2>
<%= $c->render_to_string(inline => l($ret{ret}, @vars[0..6])) %>
</div>
% } else {
<br>
<div class="text-danger">
<h2> Operation Status Report - Error</h2>
<%= $c->render_to_string(inline => l($ret{ret}, @vars[0..6])) %>
</div>
% }
<br>
<form action="/smanager/portforwardinga" method="POST">
% my $btn = l("pf_CREATE_RULE");
<div class="row g-3 align-items-center">
<div class="col-md-2">
<button type="submit" class="btn btn-primary btn-sm"><%= $btn %></button>
</div>
</div>
</form>
<br>
% if ($empty) {
<br>
<%= l "pf_NO_FORWARDS" %>
% } else {
<br>
<%= l "pf_SHOW_FORWARDS" %>
<br><br>
<table class="table table-bordered">
<thead>
<tr>
<th><%= l "Protocol" %></th>
<th><%= l "pf_LABEL_SOURCE_PORT" %></th>
<th><%= l "pf_LABEL_DESTINATION_HOST" %></th>
<th><%= l "pf_LABEL_DESTINATION_PORT" %></th>
<th><%= l "pf_ALLOW_HOSTS" %></th>
<th><%= l "pf_RULE_COMMENT" %></th>
<th class="text-center"><%= l "ACTION" %></th>
</tr>
</thead>
<tbody>
% my %forwards = ();
% $forwards{TCP} = $tcpforwards;
% $forwards{UDP} = $udpforwards;
% foreach my $proto (sort keys %forwards) {
% if (@{ $forwards{$proto} }) {
% foreach my $entry (@{ $forwards{$proto} }) {
<tr class="align-middle">
% my $sport = $entry->key;
% my $dhost = $entry->prop("DestHost");
% my $dport = $entry->prop("DestPort") || "";
% my $cmmnt = $entry->prop("Comment") || "";
% my $allow = $entry->prop("AllowHosts") || "";
<td><%= $proto %></td>
<td><%= $sport %></td>
<td><%= $dhost %></td>
<td><%= $dport %></td>
<td><%= $allow %></td>
<td><%= $cmmnt %></td>
% my $remove_text = l("REMOVE"); # Localized text
% my $csrf_token = "TOKEN"; # CSRF token for security
% my $actionRemove = qq{
% <a href="portforwardingd?CsrfDef=$csrf_token&trt=DEL&sport=$sport&proto=$proto">
% <button type="button" class="btn btn-primary btn-sm" title="$remove_text" >
% $remove_text
% </button>
% </a>
% };
<td class="text-center"><%= $c->render_to_string(inline => $actionRemove) %></td>
</tr>
% }
% }
% }
% }
</tbody>
</table>
<%= hidden_field "trt" => $pf_datas->{trt} %>
</div>

View File

@@ -0,0 +1,85 @@
<div id="pf_add">
% my $retref= $c->stash("ret");
% my %ret = $retref ? %$retref : (ret => "");
% my @vars = split(/,/, $ret{vars} // "");
% my ($var1, $var2, $var3, $var4, $var5, $var6, $var7) = @vars;
% if ($c->app->config->{debug}) {
<pre>
%= dumper { ret_data => \%ret }
</pre>
% }
% if ($ret{ret} eq "") {
% } elsif (index($ret{ret},"SUCCESS") != -1) {
<br>
<div class="success">
%= $c->render_to_string(inline => l($ret{ret}, @vars[0..6]))
</div>
% } else {
<br>
<div class="sme-error">
%= $c->render_to_string(inline => l($ret{ret}, @vars[0..6]))
</div>
% }
<br />
% my $btn = l("ADD");
% if (config->{debug} == 1) {
</pre>
%= dumper $c->current_route
%= dumper $c->stash("ret")
</pre>
% }
%= form_for "/portforwardingb" => (method => "POST") => begin
<h2>
%=l "pf_CREATE_RULE"
</h2>
<p>
%=l "pf_SUMMARY_ADD_DESC"
</p><br>
<span class=label>
%=l "Protocol"
</span><span class=data>
%=select_field "proto"=>["TCP","UDP"]
</span><br><br>
<span class=label>
%=l "pf_LABEL_SOURCE_PORT"
</span><span class=data>
%=text_field "sport"
</span><br><br>
<span class=label>
%=l "pf_LABEL_DESTINATION_PORT"
</span>
<span class=data>
%=text_field "dport"
</span><br><br>
<span class=label>
%=l "pf_LABEL_DESTINATION_HOST"
</span>
<span class=data>
%=text_field "dhost"
</span><br><br>
<span class=label>
%=l "pf_ALLOW_HOSTS"
</span>
<span class=data>
%=text_field "allow"
</span><br><br>
<span class=label>
%=l "pf_RULE_COMMENT"
</span>
<span class=data>
%=text_field "cmmnt"
</span><br><br>
<p>
<br>
%= submit_button "$btn", class => "action"
</p>
%end
</div>

View File

@@ -0,0 +1,66 @@
<div id="ln_del">
% my $btn = l("REMOVE");
% my $proto = $pf_datas->{proto};
% my $sport = $pf_datas->{sport};
% my $dport = $pf_datas->{dport};
% my $dhost = $pf_datas->{dhost};
% my $cmmnt = $pf_datas->{cmmnt};
% my $allow = $pf_datas->{allow};
% if (config->{debug} == 1) {
<pre>
%= dumper $c->current_route
%= dumper $c->stash("ret")
%= dumper %$pf_datas
</pre>
% }
%= form_for "/portforwardinge" => (method => "POST") => begin
<br>
%= l "pf_SUMMARY_REMOVE_DESC"
</p><br>
<span class=label>
%=l "Protocol"
</span><span class=data>
%=$proto
</span><br><br>
<span class=label>
%=l "pf_LABEL_SOURCE_PORT"
</span><span class=data>
%=$sport
</span><br><br>
<span class=label>
%=l "pf_LABEL_DESTINATION_HOST"
</span>
<span class=data>
%=$dport
</span><br><br>
<span class=label>
%=l "pf_LABEL_DESTINATION_PORT"
</span>
<span class=data>
%=$dhost
</span><br><br>
<span class=label>
%=l "pf_RULE_COMMENT"
</span>
<span class=data>
%=$cmmnt
</span><br><br>
<span class=label>
%=l "pf_ALLOW_HOSTS"
</span>
<span class=data>
%=$allow
</span><br><br>
%#}
%= hidden_field sport=>$sport
%= hidden_field proto=>$proto
<br>
%= submit_button "$btn", class => "action"
</p>
%end
</div>

View File

@@ -0,0 +1,116 @@
<div id="pf_list">
% my $btn = l("pf_CREATE_RULE");
%= form_for "/portforwardinga" => (method => "POST") => begin
% my $numtcpforwards = @$tcpforwards;
% my $numudpforwards = @$udpforwards;
% my $retref= $c->stash("ret");
% my %ret = $retref ? %$retref : (ret => "");
% my @vars = split(/,/, $ret{vars} // "");
% my ($var1, $var2, $var3, $var4, $var5, $var6, $var7) = @vars;
% if ($c->app->config->{debug}) {
<pre>
%= dumper { ret_data => \%ret }
</pre>
% }
% if ($ret{ret} eq "") {
%=l "pf_FIRST_PAGE_DESCRIPTION"
% } elsif (index($ret{ret},"SUCCESS") != -1) {
<br>
<div class="success">
%= $c->render_to_string(inline => l($ret{ret}, @vars[0..6]))
</div>
% } else {
<br>
<div class="sme-error">
%= $c->render_to_string(inline => l($ret{ret}, @vars[0..6]))
</div>
% }
<br />
<p>
<br>
%= submit_button "$btn", class => "action"
</p>
% end
% if ($empty){
<br>
%=l "pf_NO_FORWARDS"
% } else {
<br>
%=l "pf_SHOW_FORWARDS"
<br><br />
<table class="sme-border TableSort"><thead>
<tr>
<th class="sme-border">
%=l "Protocol"
</th>
<th class="sme-border">
%=l "pf_LABEL_SOURCE_PORT"
</th>
<th class="sme-border">
%=l "pf_LABEL_DESTINATION_HOST"
</th>
<th class="sme-border">
%=l "pf_LABEL_DESTINATION_PORT"
</th>
<th class="sme-border">
%=l "pf_ALLOW_HOSTS"
</th>
<th class="sme-border">
%=l "pf_RULE_COMMENT"
</th>
<th class="sme-border">
%=l "ACTION"
</th>
</tr>
</thead><tbody>
% my %forwards = ();
% $forwards{TCP} = $tcpforwards;
% $forwards{UDP} = $udpforwards;
% foreach my $proto (sort keys %forwards) {
% if (@{ $forwards{$proto} }) {
% foreach my $entry (@{ $forwards{$proto} }) {
<tr>
% my $sport = $entry->key;
% my $dhost = $entry->prop("DestHost");
% my $dport = $entry->prop("DestPort") || "";
% my $cmmnt = $entry->prop("Comment") || "";
% my $allow = $entry->prop("AllowHosts") || "";
%= t td => (class => "sme-border") => $proto
%= t td => (class => "sme-border") => $sport
%= t td => (class => "sme-border") => $dhost
%= t td => (class => "sme-border") => $dport
%= t td => (class => "sme-border") => $allow
%= t td => (class => "sme-border") => $cmmnt
<td class="sme-border">
%my $remove_text = l("REMOVE"); # Localized text
%my $csrf_token = "TOKEN"; # CSRF token for security
%my $actionRemove = qq{
% <a href="portforwardingd?CsrfDef=$csrf_token&trt=DEL&sport=$sport&proto=$proto">
% <button type="button" class="sme-remove-button" title="$remove_text" >
% $remove_text
% </button>
% </a>
%};
<%= $c->render_to_string(inline => $actionRemove) %>
</td>
</tr>
% }
% }
%}
%}
</tbody>
</table>
%= hidden_field "trt" => $pf_datas->{trt}
</div>

View File

@@ -0,0 +1,14 @@
'pf_CREATE_PAGE_DESCRIPTION' => 'Select the protocol, the port you wish to forward, the
destination host, and the port on the destination host
that you wish to forward to. If you wish to specify a port
range, enter the lower and upper boundaries separated by a
hyphen. The destination port may be left blank, which will
instruct the firewall to leave the source port
unaltered',
'pf_ERR_CANNOT_REMOVE_NORULE' => 'Cannot remove non-existant rule.',
'pf_ERR_DUPRULE' => 'This rule has already been added, it cannot be added twice.',
'pf_ERR_NO_MASQ_RECORD' => 'Cannot retrieve masq record from the configuration database.',
'pf_ERR_UNSUPPORTED_MODE' => 'Unsupported mode.',
'pf_LABEL_ALLOW_HOSTS' => 'Allow Hosts',
'pf_LABEL_RULE_COMMENT' => 'Rule Comment',
'Port forwarding' => 'Port forwarding',

View File

@@ -0,0 +1,55 @@
#
# Lex file for Portforwarding generated on 2025-07-17 09:52:32
#
'pf_ALLOW_HOSTS' => 'Allow Hosts',
'pf_CREATE_PAGE_DESCRIPTION' => 'Select the protocol, the port you wish to forward, the
destination host, and the port on the destination host
that you wish to forward to. If you wish to specify a port
range, enter the lower and upper boundaries separated by a
hyphen. The destination port may be left blank, which will
instruct the firewall to leave the source port
unaltered',
'pf_CREATE_RULE' => 'Create portforwarding rule',
'pf_ERR_BADAHOST' => 'This does not appear to be a valid IP address list.
ie: 192.168.0.1,192.168.1.1/24',
'pf_ERR_BADIP' => 'This does not appear to be an IP address. You must use
dotted-quad notation, and each of the four numbers should be less
than 256. ie: 192.168.0.5',
'pf_ERR_BADPORT' => 'The ports must be a positive integer less than 65536.',
'pf_ERR_CANNOT_REMOVE_NORULE' => 'Cannot remove non-existant rule.',
'pf_ERR_DUPRULE' => 'This rule has already been added, it cannot be added twice.',
'pf_ERR_NO_MASQ_RECORD' => 'Cannot retrieve masq record from the configuration database.',
'pf_ERR_NONZERO_RETURN_EVENT' => 'Event returned a non-zero return value.',
'pf_ERR_PORT_COLLISION' => 'ERROR: This port or port range conflicts with an existing
rule. Please modify this new rule, or remove the old rule.',
'pf_ERR_UNSUPPORTED_MODE' => 'Unsupported mode.',
'pf_FIRST_PAGE_DESCRIPTION' => 'You can use this panel to modify your firewall rules so
as to open a specific port on this server and forward it
to another port on another host. Doing so will permit
incoming traffic to directly access a private host on
your LAN.
WARNING: Misuse of this feature can seriously compromise the
security of your network. Do not use this feature
lightly, or without fully understanding the implications
of your actions.',
'pf_FORM_TITLE' => 'Configure Port Forwarding',
'pf_IN_SERVERONLY' => 'This server is currently in serveronly mode and portforwarding
is possible only to localhost.',
'pf_LABEL_ALLOW_HOSTS' => 'Allow Hosts',
'pf_LABEL_DESTINATION_HOST' => 'Destination Host IP Address',
'pf_LABEL_DESTINATION_PORT' => 'Destination Port(s)',
'pf_LABEL_RULE_COMMENT' => 'Rule Comment',
'pf_LABEL_SOURCE_PORT' => 'Source Port(s)',
'pf_NO_FORWARDS' => 'There are currently no forwarded ports on the system.',
'pf_RULE_COMMENT' => 'Rule Comment',
'pf_SHOW_FORWARDS' => 'Below you will find a table summarizing the current
port-forwarding rules installed on this server. Click on the
"Remove" link to remove the corresponding rule.',
'pf_SUCCESS' => 'Your change to the port forwarding rules has been successfully saved.',
'pf_SUMMARY_ADD_DESC' => 'The following summarizes the port-forwarding rule
that you are about to add. If you are satisfied with the rule,
click the "Add" button.',
'pf_SUMMARY_REMOVE_DESC' => 'The following summarizes the port-forwarding rule
that you are about to remove. If you are sure you want to
remove the rule, click the "Remove" button.',
'Port forwarding' => 'Port forwarding',