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,121 @@
<div>
<table class="table table-bordered">
<thead>
<tr>
<th class="col-md-2"><%= l "rvw_NETWORKING_PARAMS" %></th>
<th class="col-auto">&nbsp</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= l "rvw_SERVER_MODE" %></td>
<td><%= $rvw_datas->{servermode} %></td>
</tr>
<tr>
<td><%= l "rvw_LOCAL_IP_ADDRESS_SUBNET_MASK" %></td>
<td><%= $rvw_datas->{localip} %></td>
</tr>
% if ( $rvw_datas->{publicip} ) {
<tr>
<td><%=l "rvw_INTERNET_VISIBLE_ADDRESS" %></td>
<td><%= $rvw_datas->{publicip} %></td>
</tr>
% }
<tr>
<td><%= l "Gateway"%></td>
<td>
<%= $rvw_datas->{gateway} %>
<%= $rvw_datas->{serveronly} %>
</td>
</tr>
<tr>
<td>Local Networks (not translated?)</td>
<td><%= $c->render_to_string( inline => $rvw_datas->{addlocalnetworks} );%> </td>
<tr>
<tr>
<td><%= l "rvw_DHCP_SERVER" %></td>
<td><%= $rvw_datas->{dhcpserver} %></td>
</tr>
</tbody>
</table>
<table class="table table-bordered">
<thead>
<tr>
<th class="col-md-2"><%= l "rvw_SERVER_NAMES" %></th>
<th class="col-auto">&nbsp</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= l "rvw_DNS_SERVER" %></td>
<td><%= $rvw_datas->{dnsserver} %></td>
</tr>
<tr>
<td><%= l "rvw_WEB_SERVER" %></td>
<td><%= $rvw_datas->{webserver} %></tr>
</tr>
<tr>
<td><%= l "rvw_PROXY_SERVER" %></td>
<td><%= $rvw_datas->{proxyserver} %></tr>
</tr>
<tr>
<td><%= l "rvw_FTP_SERVER" %></td>
<td><%= $rvw_datas->{ftpserver} %></tr>
</tr>
<tr>
<td><%= l "rvw_SMTP_POP_AND_IMAP_MAIL_SERVERS" %></td>
<td><%= $rvw_datas->{smtpserver} %></tr>
</tr>
</tbody>
</table>
<table class="table table-bordered">
<thead>
<tr>
<th class="col-md-2"><%= l "rvw_DOMAIN_INFORMATION" %></th>
<th class="col-auto">&nbsp</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= l "rvw_PRIMARY_DOMAIN" %></td>
<td><%= $rvw_datas->{domainname} %></td>
</tr>
<tr>
<td><%= l "rvw_VIRTUAL_DOMAINS" %></td>
<td><%= $rvw_datas->{virtualdomains} %></td>
</tr>
<tr>
<td><%= l "rvw_PRIMARY_WEB_SITE" %></td>
<td><%= $rvw_datas->{primarywebsite} %></td>
</tr>
<tr>
<td><%= l "rvw_SERVER_MANAGER" %></td>
<td><%= $rvw_datas->{servermanager} %></td>
</tr>
<tr>
<td><%= l "rvw_USER_PASSWORD_PANEL" %></td>
<td><%= $rvw_datas->{usermanager} %></td>
</tr>
<tr>
<td><%= l "rvw_EMAIL_ADDRESSES" %></td>
<td><%= $rvw_datas->{emailaddresses} %></td>
</tr>
</tbody>
</table>
</div>

318
output/Review/Review.new.pm Normal file
View File

@@ -0,0 +1,318 @@
package SrvMngr::Controller::Review;
#----------------------------------------------------------------------
# heading : Investigation
# description : Review configuration
# navigation : 7000 400
# routes : end
#----------------------------------------------------------------------
use strict;
use warnings;
use Mojo::Base "Mojolicious::Controller";
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use SrvMngr qw(gen_locale_date_string);
use esmith::ConfigDB::UTF8;
use esmith::DomainsDB::UTF8;
use esmith::NetworksDB::UTF8;
#use SrvMngr::Review_sub qw(print_page);
#use smeserver::Panel::review;
our $db;
our $domains ;
our $networks;
sub main {
my $c = shift;
$c->app->log->info($c->log_req);
$db = esmith::ConfigDB::UTF8->open_ro || die "Couldn"t open config db\";
my $title = $c->l("rvw_FORM_TITLE");
my $modul = $c->render_to_string(inline => $c->l("rvw_DESCRIPTION"));
my %rvw_datas = ();
$rvw_datas{"servermode"} = (get_value("", "SystemMode") || "");
$rvw_datas{"localip"} = get_value("$c", "LocalIP") . "/" . get_value("$c", "LocalNetmask");
$rvw_datas{"publicip"} = $c->get_public_ip_address($c);
$rvw_datas{"gateway"} = $c->render_to_string(inline => print2_gateway_stanza($c));
$rvw_datas{"serveronly"} = $c->render_to_string(inline => print2_serveronly_stanza($c));
$rvw_datas{"addlocalnetworks"} = get_local_networks($c);
$rvw_datas{"dhcpserver"} = $c->render_to_string(inline => print2_dhcp_stanza($c));
$rvw_datas{"dnsserver"} = (get_value("", "LocalIP") || "");
$rvw_datas{"webserver"} = "www." . (get_local_domain());
my $port = $db->get_prop(\"squid\", \"TransparentPort\") || 3128;
$rvw_datas{"proxyserver"} = "proxy." . get_local_domain() . \":$port\";
$rvw_datas{"ftpserver"} = "ftp." . get_local_domain();
$rvw_datas{"smtpserver"} = "mail." . get_local_domain();
$rvw_datas{"domainname"} = (get_value("", "DomainName") || "");
$rvw_datas{"virtualdomains"} = $c->render_to_string(inline => gen2_domains($c));
$rvw_datas{"primarywebsite"} = "http://www." . get_value("", "DomainName");
$rvw_datas{"servermanager"} = "https://" . (get_value("", "SystemName") || "localhost") . "/server-manager/";
$rvw_datas{"usermanager"} = "https://" . (get_value("", "SystemName") || "localhost") . "/user-password/";
$rvw_datas{"emailaddresses"} = $c->render_to_string(inline => gen2_email_addresses($c));
#$c->stash( releaseVersion => $c->session->{releaseVersion}, copyRight => $c->session->{copyRight},
#PwdSet => $c->session->{PwdSet}, Unsafe => $c->session->{Unsafe},
$c->stash(
title => $title,
modul => $modul,
rvw_datas => \%rvw_datas,
);
$c->render(template => "review");
} ## end sub main
=head2 gen2_email_addresses
Returns a string of the various forms of email addresses that work
on an SMEServer (mojo v.)
=cut
sub gen2_email_addresses {
my $c = shift;
my $domain = get_value($c, "DomainName");
my $useraccount = $c->l(\"useraccount\");
my $firstname = $c->l(\"firstname\");
my $lastname = $c->l(\"lastname\");
my $out
= \"<I>\"
. $useraccount
. \"</I>\@\"
. $domain . \"<BR>\" . \"<I>\"
. $firstname
. \"</I>.<I>\"
. $lastname
. \"</I>\@\"
. $domain . \"<BR>\" . \"<I>\"
. $firstname
. \"</I>_<I>\"
. $lastname
. \"</I>\@\"
. $domain . \"<BR>\";
return $out;
} ## end sub gen2_email_addresses
=head2 gen2_domains
Returns a string of the domains this SME Server serves or a localized string
saying \"no domains defined\" (mojo ver)
=cut
sub gen2_domains {
my $c = shift;
$domains = esmith::DomainsDB::UTF8->open_ro || die \"Couldn"t open domains";
my @virtual = $domains->get_all_by_prop(type => "domain");
my $numvirtual = @virtual;
if ($numvirtual == 0) {
$c->localise("NO_VIRTUAL_DOMAINS");
} else {
my $out = "";
my $domain;
foreach $domain (sort @virtual) {
if ($out ne "") {
$out .= "<BR>";
}
$out .= $domain->key;
} ## end foreach $domain (sort @virtual)
return $out;
} ## end else [ if ($numvirtual == 0) ]
} ## end sub gen2_domains
=head2 get2_local_networks
Return a <br> delimited string of all the networks this SMEServer is
serving. (mojo ver)
=cut
sub get2_local_networks {
my $c = shift;
$networks = esmith::NetworksDB::UTF8->open_ro || die "Couldn"t open networks\";
my @nets = $networks->get_all_by_prop("type" => "network");
my $numNetworks = @nets;
if ($numNetworks == 0) {
return $c->l("rvw_NO_NETWORKS");
} else {
my $out = \"\";
foreach my $network (sort @nets) {
if ($out ne \"\") {
$out .= \"<BR>\";
}
$out .= $network->key . \"/\" . get_net_prop($c, $network->key, "Mask");
if (defined get_net_prop($c, $network->key, "Router")) {
$out .= \" via \" . get_net_prop($c, $network->key, "Router");
}
} ## end foreach my $network (sort @nets)
return $out;
} ## end else [ if ($numNetworks == 0)]
} ## end sub get2_local_networks
sub get_net_prop {
my $fm = shift;
my $item = shift;
my $prop = shift;
$networks = esmith::NetworksDB::UTF8->open_ro || die \"Couldn"t open networks";
my $record = $networks->get($item);
if ($record) {
return $record->prop($prop);
}
else {
return "";
}
}
sub get_local_networks {
my $fm = shift;
$networks = esmith::NetworksDB::UTF8->open_ro || die "Couldn"t open networks\";
my @nets = $networks->get_all_by_prop("type" => "network");
my $numNetworks = @nets;
if ($numNetworks == 0) {
return $fm->localise("NO_NETWORKS");
}
else {
my $out = \"\";
foreach my $network (sort @nets) {
if ($out ne \"\") {
$out .= \"<BR>\";
}
$out .= $network->key.\"/\" . get_net_prop($fm, $network->key, "Mask");
if ( defined get_net_prop($fm, $network->key, "Router") ) {
$out .= \" via \" . get_net_prop ($fm, $network->key, "Router");
}
}
return $out;
}
}
sub get_local_domain
{
return (get_value("","DomainName"));
}
=head2 print2_gateway_stanza
If this system is a server gateway, show the external ip and gateway ip (mojo ver)
=cut
sub print2_gateway_stanza {
my $c = shift;
if (get_value($c, "SystemMode") =~ /servergateway/) {
my $ip = get_value($c, "ExternalIP");
my $static
= (get_value($c, "AccessType") eq "dedicated")
&& (get_value($c, "ExternalDHCP") eq "off")
&& (get_prop($c, "pppoe", "status") eq "disabled");
if ($static) {
$ip .= \"/\" . get_value($c, "ExternalNetmask");
}
my $out = $c->l("rvw_EXTERNAL_IP_ADDRESS_SUBNET_MASK") . ":" . $ip;
if ($static) {
$out .= $c->l("Gateway") . ":" . get_value($c, "GatewayIP");
}
return $out;
} ## end if (get_value($c, "SystemMode"...))
} ## end sub print2_gateway_stanza
=head2 print2_serveronly_stanza
If this system is a standalone server with net access, show the external
gateway IP (mojo ver)
=cut
sub print2_serveronly_stanza {
my $c = shift;
if ( (get_value($c, "SystemMode") eq "serveronly")
&& get_value($c, "AccessType")
&& (get_value($c, "AccessType") ne \"off\"))
{
return (get_value($c, "GatewayIP"));
} ## end if ((get_value($c, "SystemMode"...)))
} ## end sub print2_serveronly_stanza
=head2 print2_dhcp_stanza
Prints out the current state of dhcp service (mojo ver)
=cut
sub print2_dhcp_stanza {
my $c = shift;
my $out = (get_prop($c, "dhcpd", "status") || "disabled");
if (get_prop($c, "dhcpd", "status") eq "enabled") {
$out .= "<br>" . $c->l("rvw_BEGINNING_OF_DHCP_ADDRESS_RANGE") . ":";
$out .= (get_prop($c, "dhcpd", "start") || "") . "<br>";
$out .= $c->l("rvw_END_OF_DHCP_ADDRESS_RANGE") . ":";
$out .= (get_prop($c, "dhcpd", "end") || "");
} ## end if (get_prop($c, "dhcpd"...))
return $out;
} ## end sub print2_dhcp_stanza
sub get_value {
my $fm = shift;
my $item = shift;
$db = esmith::ConfigDB::UTF8->open_ro || die \"Couldn"t open config db";
my $record = $db->get($item);
if ($record) {
return $record->value();
}
else {
return "";
}
}
sub get_prop {
my $fm = shift if (ref($_[0]) ); # If we"re being called in a formmagick context
# The first argument will always be a fm.
#otherwise, we don"t want to grab it
my $item = shift;
my $prop = shift;
$db = esmith::ConfigDB::UTF8->open_ro || die "Couldn"t open config db\";
my $record = $db->get($item);
if ($record) {
return $record->prop($prop);
}
else {
return "";
}
}
sub get_public_ip_address
{
my $self = shift;
$db = esmith::ConfigDB::UTF8->open_ro || die \"Couldn"t open config db";
my $sysconfig = $db->get("sysconfig");
if ($sysconfig)
{
my $publicIP = $sysconfig->prop("PublicIP");
if ($publicIP)
{
return $publicIP;
}
}
return undef;
}
1;

View File

@@ -0,0 +1,137 @@
% layout "default", title => "Sme server 2 - Review";
% content_for "module" => begin
<div id="central" class="central review-panel module">
<h1> <%= $title %> </h1>
<%= $modul %><br><br>
%= form_for "review" => begin
<b>
%=l "rvw_NETWORKING_PARAMS"
</b><br>
<p><span class=label>
%=l "rvw_SERVER_MODE"
</span>
%= $rvw_datas->{servermode}
</p>
<p><span class=label>
%=l "rvw_LOCAL_IP_ADDRESS_SUBNET_MASK"
</span>
%= $rvw_datas->{localip}
</p>
% if ( $rvw_datas->{publicip} ) {
<p><span class=label>
%=l "rvw_INTERNET_VISIBLE_ADDRESS"
</span>
%= $rvw_datas->{publicip}
</p>
% }
<p><span class=label>
%=l "Gateway"
</span>
%= $rvw_datas->{gateway}
%= $rvw_datas->{serveronly}
</p>
<p><table width="100%"><tr><td class=label><!--span class=label-->
%=l "rvw_ADDITIONAL_LOCAL_NETWORKS"
<!--/span--></td><td>
%= $c->render_to_string( inline => $rvw_datas->{addlocalnetworks} );
</td></tr></table>
</p>
<p><table width="100%"><tr><td class=label>
<!--<p><span class=label>-->
%=l "rvw_DHCP_SERVER"
<!--</span>-->
</td><td>
%= $rvw_datas->{dhcpserver}
<!--</p>-->
</td></tr></table></p>
<br><br><b>
%=l "rvw_SERVER_NAMES"
</b><br>
<p><span class=label>
%=l "rvw_DNS_SERVER"
</span>
%= $rvw_datas->{dnsserver}
</p>
<p><span class=label>
%=l "rvw_WEB_SERVER"
</span>
%= $rvw_datas->{webserver}
</p>
<p><span class=label>
%=l "rvw_PROXY_SERVER"
</span>
%= $rvw_datas->{proxyserver}
</p>
<p><span class=label>
%=l "rvw_FTP_SERVER"
</span>
%= $rvw_datas->{ftpserver}
</p>
<p><span class=label>
%=l "rvw_SMTP_POP_AND_IMAP_MAIL_SERVERS"
</span>
%= $rvw_datas->{smtpserver}
</p>
<br><br><b>
%=l "rvw_DOMAIN_INFORMATION"
</b><br>
<p><span class=label>
%=l "rvw_PRIMARY_DOMAIN"
</span>
%= $rvw_datas->{domainname}
</p>
<!---<p><span class=label>-->
<p><table width="100%"><tr><td class=label>
%=l "rvw_VIRTUAL_DOMAINS"
</td><td>
<!--</span>-->
%= $rvw_datas->{virtualdomains}
</td></tr></table></p>
<!--</p>-->
<p><span class=label>
%=l "rvw_PRIMARY_WEB_SITE"
</span>
%= $rvw_datas->{primarywebsite}
</p>
<p><span class=label>
%=l "rvw_SERVER_MANAGER"
</span>
%= $rvw_datas->{servermanager}
</p>
<p><span class=label>
%=l "rvw_USER_PASSWORD_PANEL"
</span>
%= $rvw_datas->{usermanager}
</p>
<p><table width="100%"><tr><td class=label>
%=l "rvw_EMAIL_ADDRESSES"
</td><td>
%= $rvw_datas->{emailaddresses}
</td></tr></table></p>
% end
</div>
% end

View File

@@ -0,0 +1,3 @@
'Review configuration' => 'Review configuration',
'rvw_HOSTS' => 'Hosts',
'rvw_NO_VIRTUAL_DOMAINS' => 'No virtual domains defined',

View File

@@ -0,0 +1,34 @@
#
# Lex file for Review generated on 2025-07-17 09:52:34
#
'Review configuration' => 'Review configuration',
'rvw_ADDITIONAL_LOCAL_NETWORKS' => 'Additional local networks',
'rvw_BEGINNING_OF_DHCP_ADDRESS_RANGE' => 'Beginning of DHCP address range',
'rvw_DESCRIPTION' => 'This report summarizes the networking, server, and domain
parameters on this server relevant to configuring
the client computers on your network. You may wish to print this
page and use it as a reference.',
'rvw_DHCP_SERVER' => 'DHCP server',
'rvw_DNS_SERVER' => 'DNS server',
'rvw_DOMAIN_INFORMATION' => 'Domain information',
'rvw_EMAIL_ADDRESSES' => 'Email Addresses',
'rvw_END_OF_DHCP_ADDRESS_RANGE' => 'End of DHCP address range',
'rvw_EXTERNAL_IP_ADDRESS_SUBNET_MASK' => 'External IP address / subnet mask',
'rvw_FORM_TITLE' => 'Review configuration',
'rvw_FTP_SERVER' => 'FTP server',
'rvw_HOSTS' => 'Hosts',
'rvw_INTERNET_VISIBLE_ADDRESS' => 'Internet Visible IP Address',
'rvw_LOCAL_IP_ADDRESS_SUBNET_MASK' => 'Local IP address / subnet mask',
'rvw_NETWORKING_PARAMS' => 'Networking Parameters',
'rvw_NO_NETWORKS' => 'No additional networks defined',
'rvw_NO_VIRTUAL_DOMAINS' => 'No virtual domains defined',
'rvw_PRIMARY_DOMAIN' => 'Primary domain',
'rvw_PRIMARY_WEB_SITE' => 'Primary web site',
'rvw_PROXY_SERVER' => 'Proxy server',
'rvw_SERVER_MANAGER' => 'Server manager',
'rvw_SERVER_MODE' => 'Server Mode',
'rvw_SERVER_NAMES' => 'Server names',
'rvw_SMTP_POP_AND_IMAP_MAIL_SERVERS' => 'SMTP, POP, and IMAP mail servers',
'rvw_USER_PASSWORD_PANEL' => 'User password panel',
'rvw_VIRTUAL_DOMAINS' => 'Virtual domains',
'rvw_WEB_SERVER' => 'Web server',