* Mon Jun 09 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-87.sme
- add datetime getYear_list [SME: 13031] - use esmith::*DB::UTF8 to access db flat files [SME: 13027]
This commit is contained in:
@@ -14,7 +14,7 @@ use Mojo::Base 'Mojolicious::Controller';
|
||||
use Locale::gettext;
|
||||
use SrvMngr::I18N;
|
||||
use SrvMngr qw(theme_list init_session ip_number subnet_mask get_reg_mask);
|
||||
use esmith::ConfigDB;
|
||||
use esmith::ConfigDB::UTF8;
|
||||
use esmith::util;
|
||||
use File::Basename;
|
||||
use Exporter;
|
||||
@@ -30,7 +30,7 @@ our @EXPORT = qw( networkAccess_list passwordLogin_list get_ssh_permit_root_logi
|
||||
);
|
||||
|
||||
# get_pptp_sessions
|
||||
my $db; # = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
our $db;
|
||||
|
||||
sub main {
|
||||
my $c = shift;
|
||||
@@ -38,7 +38,7 @@ sub main {
|
||||
my $title = $c->l('rma_FORM_TITLE');
|
||||
my $notif = '';
|
||||
my %rma_datas = ();
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
|
||||
#$rma_datas{ipsecrwSess} = $c->get_ipsecrw_sessions();
|
||||
#$rma_datas{pptpSessions} = $c->get_pptp_sessions();
|
||||
@@ -60,7 +60,7 @@ sub do_action {
|
||||
my $title = $c->l('rma_FORM_TITLE');
|
||||
my ($result, $res, $trt) = '';
|
||||
my %rma_datas = ();
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
$rma_datas{ipsecrwSess} = ($c->param('IpsecrwSess') || '');
|
||||
$rma_datas{ipsecrwReset} = ($c->param('IpsecrwReset') || '');
|
||||
|
||||
@@ -144,7 +144,7 @@ sub passwordLogin_list {
|
||||
}
|
||||
|
||||
sub get_prop {
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
my ($c, $item, $prop) = @_;
|
||||
warn "You must specify a record key" unless $item;
|
||||
warn "You must specify a property name" unless $prop;
|
||||
@@ -155,8 +155,7 @@ sub get_prop {
|
||||
sub get_value {
|
||||
my $c = shift;
|
||||
my $item = shift;
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
return ($db->get($item)->value());
|
||||
} ## end sub get_value
|
||||
|
||||
@@ -205,7 +204,7 @@ sub get_ftp_password_login_access {
|
||||
} ## end sub get_ftp_password_login_access
|
||||
|
||||
sub get_telnet_mode {
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
my $telnet = $db->get('telnet');
|
||||
return ('off') unless $telnet;
|
||||
my $status = $telnet->prop('status') || 'disabled';
|
||||
@@ -215,7 +214,7 @@ sub get_telnet_mode {
|
||||
} ## end sub get_telnet_mode
|
||||
|
||||
sub get_ipsecrw_sessions {
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
my $status = $db->get('ipsec')->prop('RoadWarriorStatus');
|
||||
if (defined($status) && ($status eq 'enabled')) {
|
||||
return ($db->get('ipsec')->prop('RoadWarriorSessions') || '0');
|
||||
@@ -225,7 +224,7 @@ sub get_ipsecrw_sessions {
|
||||
} ## end sub get_ipsecrw_sessions
|
||||
|
||||
sub get_ipsecrw_status {
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
return undef unless ($db->get('ipsec'));
|
||||
return $db->get('ipsec')->prop('RoadWarriorStatus');
|
||||
}
|
||||
@@ -233,7 +232,7 @@ sub get_ipsecrw_status {
|
||||
sub pptp_and_dhcp_range {
|
||||
my $c = shift;
|
||||
my $val = shift || 0;
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
my $dhcp_status = $db->get_prop('dhcpd', 'status') || 'disabled';
|
||||
my $dhcp_end = $db->get_prop('dhcpd', 'end') || '';
|
||||
my $dhcp_start = $db->get_prop('dhcpd', 'start') || '';
|
||||
@@ -251,7 +250,7 @@ sub pptp_and_dhcp_range {
|
||||
|
||||
sub _get_valid_from {
|
||||
my $c = shift;
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
my $rec = $db->get('httpd-admin');
|
||||
return undef unless ($rec);
|
||||
my @vals = (split ',', ($rec->prop('ValidFrom') || ''));
|
||||
@@ -294,11 +293,11 @@ sub validate_network_and_mask {
|
||||
|
||||
sub change_settings {
|
||||
my ($c, %rma_datas) = @_;
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
#------------------------------------------------------------
|
||||
# good; go ahead and change the access.
|
||||
#------------------------------------------------------------
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
my $rec = $db->get('telnet');
|
||||
if ($rec) {
|
||||
if ($rma_datas{telnetAccess} eq "off") {
|
||||
@@ -370,7 +369,7 @@ sub change_settings {
|
||||
sub set_ipsecrw_sessions {
|
||||
my $c = shift;
|
||||
my $sessions = shift;
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
if (defined $sessions) {
|
||||
$db->get('ipsec')->set_prop('RoadWarriorSessions', $sessions);
|
||||
|
||||
@@ -385,7 +384,7 @@ sub add_new_valid_from {
|
||||
my $c = shift;
|
||||
my $net = shift;
|
||||
my $mask = shift;
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
|
||||
# we transform bit mask to regular mask
|
||||
$mask = get_reg_mask($net, $mask);
|
||||
@@ -408,7 +407,7 @@ sub remove_valid_from {
|
||||
my $c = shift;
|
||||
my $remove_nets = shift;
|
||||
my @remove = split /,/, $remove_nets;
|
||||
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
|
||||
$db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
|
||||
|
||||
# my @remove = $c->param('Remove_nets');
|
||||
my @vals = $c->_get_valid_from();
|
||||
@@ -439,4 +438,4 @@ sub remove_valid_from {
|
||||
$db->get('httpd-admin')->set_prop('ValidFrom', $prop);
|
||||
return 1;
|
||||
} ## end sub remove_valid_from
|
||||
1;
|
||||
1;
|
||||
|
Reference in New Issue
Block a user