* Fri Feb 07 2025 Brian Read <brianr@koozali.org> 11.0.0-49.sme

- Fix delete of ibay - typo in link
- Move across toMB() sub from formmagick to quota.pm
- Recast DB opening so it is specific to the route rather than global [SME: 12905]
This commit is contained in:
Brian Read 2025-02-07 16:21:42 +00:00
parent 3070e0656c
commit 7ad224998c
12 changed files with 110 additions and 38 deletions

View File

@ -20,9 +20,9 @@ use esmith::DomainsDB;
use esmith::AccountsDB;
#use URI::Escape;
our $ddb = esmith::DomainsDB->open || die "Couldn't open domains db";
our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my ($ddb,$cdb,$adb);
#our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
our $REGEXP_DOMAIN = qq([a-zA-Z0-9\-\.]+);
sub main {
@ -30,6 +30,9 @@ sub main {
$c->app->log->info($c->log_req);
my %dom_datas = ();
my $title = $c->l('dom_FORM_TITLE');
$ddb = esmith::DomainsDB->open || die "Couldn't open domains db";
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$dom_datas{trt} = 'LST';
my @domains;
@ -54,6 +57,9 @@ sub do_display {
my $rt = $c->current_route;
my $trt = $c->param('trt');
my $domain = $c->param('Domain') || '';
$ddb = esmith::DomainsDB->open || die "Couldn't open domains db";
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#$trt = 'DEL' if ( $rt eq 'domaindel1' );
#$trt = 'UPD' if ( $rt eq 'domainupd1' );
@ -121,6 +127,9 @@ sub do_update {
$c->app->log->info($c->log_req);
my $rt = $c->current_route;
my $trt = $c->param('trt');
$ddb = esmith::DomainsDB->open || die "Couldn't open domains db";
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my %dom_datas = ();
my ($res, $result) = '';

View File

@ -18,14 +18,17 @@ use SrvMngr qw(theme_list init_session);
#use Data::Dumper;
#use esmith::FormMagick::Panel::groups;
use esmith::AccountsDB;
our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my ($cdb,$adb);
sub main {
my $c = shift;
$c->app->log->info($c->log_req);
my %grp_datas = ();
my $title = $c->l('grp_FORM_TITLE');
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$grp_datas{trt} = 'LST';
my @groups;
@ -44,6 +47,8 @@ sub do_display {
my $group = $c->param('group');
my %grp_datas = ();
my $title = $c->l('grp_FORM_TITLE');
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$grp_datas{'trt'} = $trt;
if ($trt eq 'ADD') {
@ -99,6 +104,8 @@ sub do_update {
my $title = $c->l('grp_FORM_TITLE');
my ($res, $result) = '';
my %grp_datas = ();
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$grp_datas{'trt'} = $trt;
$grp_datas{'group'} = $groupName;
my @members = ();

View File

@ -25,10 +25,11 @@ use HTML::Entities;
use Net::IPv4Addr qw(ipv4_in_network);
#use URI::Escape;
our $ddb = esmith::DomainsDB->open || die "Couldn't open hostentries db";
our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
our $hdb = esmith::HostsDB->open || die "Couldn't open hosts db";
our $ndb = esmith::NetworksDB->open || die "Couldn't open networks db";
#our $ddb = esmith::DomainsDB->open || die "Couldn't open hostentries db";
#our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
#our $hdb = esmith::HostsDB->open || die "Couldn't open hosts db";
#our $ndb = esmith::NetworksDB->open || die "Couldn't open networks db";
my ($ddb,$cdb,$hdb,$ndb);
sub main {
my $c = shift;
@ -36,6 +37,10 @@ sub main {
my %hos_datas = ();
my $title = $c->l('hos_FORM_TITLE');
my $notif = '';
#my $ddb = esmith::DomainsDB->open || die "Couldn't open hostentries db";
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$hdb = esmith::HostsDB->open || die "Couldn't open hosts db";
$ndb = esmith::NetworksDB->open || die "Couldn't open networks db";
$hos_datas{trt} = 'LIST';
my %dom_hosts = ();
@ -68,6 +73,9 @@ sub do_display {
$trt = 'LST' if ($trt ne 'DEL' && $trt ne 'UPD' && $trt ne 'ADD');
my %hos_datas = ();
my $title = $c->l('hos_FORM_TITLE');
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$hdb = esmith::HostsDB->open || die "Couldn't open hosts db";
$ndb = esmith::NetworksDB->open || die "Couldn't open networks db";
my $notif = '';
$hos_datas{'trt'} = $trt;
@ -112,6 +120,9 @@ sub do_update {
my $trt = ($c->param('trt') || 'LIST');
my %hos_datas = ();
my $title = $c->l('hos_FORM_TITLE');
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$hdb = esmith::HostsDB->open || die "Couldn't open hosts db";
$ndb = esmith::NetworksDB->open || die "Couldn't open networks db";
my $notif = '';
my $result = '';
$hos_datas{'name'} = lc $c->param('Name');

View File

@ -19,15 +19,18 @@ use esmith::ConfigDB;
use esmith::DomainsDB;
#use esmith::FormMagick::Panel::ibays;
our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my ($adb,$cdb);
sub main {
my $c = shift;
$c->app->log->info($c->log_req);
my %iba_datas = ();
my $title = $c->l('iba_FORM_TITLE');
$iba_datas{'trt'} = 'LIST';
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
$iba_datas{'trt'} = 'LIST';
my @ibays;
if ($adb) {
@ -42,6 +45,8 @@ sub do_display {
my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LIST');
my $ibay = $c->param('ibay') || '';
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
#$trt = 'DEL' if ( $ibay );
#$trt = 'ADD' if ( $rt eq 'ibayadd' );
@ -116,6 +121,8 @@ sub do_update {
$iba_datas{'trt'} = $trt;
my $result = '';
my $res;
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
if ($trt eq 'ADD') {
my $name = ($c->param('ibay') || '');

View File

@ -17,8 +17,9 @@ use SrvMngr qw(theme_list init_session subnet_mask get_reg_mask ip_number);
#use Data::Dumper;
use esmith::util;
use esmith::HostsDB;
my $network_db = esmith::NetworksDB->open() || die("Couldn't open networks db");
#my $network_db = esmith::NetworksDB->open() || die("Couldn't open networks db");
my $ret = "OK";
my ($network_db);
sub main {
my $c = shift;
@ -26,6 +27,7 @@ sub main {
my %ln_datas = ();
$ln_datas{return} = "";
my $title = $c->l('ln_LOCAL NETWORKS');
$network_db = esmith::NetworksDB->open() || die("Couldn't open networks db");
my $modul = '';
$ln_datas{trt} = 'LIST';
my @localnetworks;
@ -47,6 +49,7 @@ sub do_display {
$c->app->log->info($c->log_req);
my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LIST');
$network_db = esmith::NetworksDB->open() || die("Couldn't open networks db");
$trt = 'DEL' if ($rt eq 'localnetworksdel');
$trt = 'ADD' if ($rt eq 'localnetworksadd');
$trt = 'ADD1' if ($rt eq 'localnetworksadd1');
@ -81,7 +84,7 @@ sub do_display {
if ($trt eq 'DEL1') {
#After Remove clicked on Delete network panel
my $network_db = esmith::NetworksDB->open() || die("Failed to open Networkdb-1");
$network_db = esmith::NetworksDB->open() || die("Failed to open Networkdb-1");
my $localnetwork = $c->param("localnetwork");
my $delete_hosts = $c->param("deletehost") || "1"; #default to deleting them.
my $rec = $network_db->get($localnetwork) || die("Failed to find network on db:$localnetwork");
@ -135,7 +138,7 @@ sub do_display {
sub remove_network {
my $network = shift;
my $network_db = esmith::NetworksDB->open();
$network_db = esmith::NetworksDB->open();
my $record = $network_db->get($network);
my $delete_hosts = shift;
@ -265,3 +268,4 @@ sub add_network {
);
} ## end else [ if ($totalHosts == 1) ]
} ## end sub add_network
1;

View File

@ -18,12 +18,11 @@ use SrvMngr qw(theme_list init_session);
#use Data::Dumper;
use esmith::util;
use esmith::HostsDB;
our $db = esmith::ConfigDB->open
|| die "Can't open configuration database: $!\n";
our $tcp_db = esmith::ConfigDB->open('portforward_tcp')
|| die "Can't open portforward_tcp database: $!\n";
our $udp_db = esmith::ConfigDB->open('portforward_udp')
|| die "Can't open portforward_udp database: $!\n";
#our $db = esmith::ConfigDB->open || die "Can't open configuration database: $!\n";
#our $tcp_db = esmith::ConfigDB->open('portforward_tcp') || die "Can't open portforward_tcp database: $!\n";
#our $udp_db = esmith::ConfigDB->open('portforward_udp') || die "Can't open portforward_udp database: $!\n";
my ($cdb,$tcp_db,$udp_db);
my %ret = ();
use constant FALSE => 0;
use constant TRUE => 1;
@ -35,6 +34,9 @@ sub main {
$pf_datas{return} = "";
my $title = $c->l('pf_FORM_TITLE');
my $modul = '';
$cdb = esmith::ConfigDB->open || die "Can't open configuration database: $!\n";
$tcp_db = esmith::ConfigDB->open('portforward_tcp') || die "Can't open portforward_tcp database: $!\n";
$udp_db = esmith::ConfigDB->open('portforward_udp') || die "Can't open portforward_udp database: $!\n";
$pf_datas{trt} = 'LIST';
my @tcpforwards = $tcp_db->get_all;
my @udpforwards = $udp_db->get_all;
@ -55,6 +57,9 @@ sub do_display {
$c->app->log->info($c->log_req);
my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LIST');
my $cdb = esmith::ConfigDB->open || die "Can't open configuration database: $!\n";
my $tcp_db = esmith::ConfigDB->open('portforward_tcp') || die "Can't open portforward_tcp database: $!\n";
my $udp_db = esmith::ConfigDB->open('portforward_udp') || die "Can't open portforward_udp database: $!\n";
$trt = 'DEL' if ($rt eq 'portforwardingdel');
$trt = 'ADD' if ($rt eq 'portforwardingadd');
$trt = 'ADD1' if ($rt eq 'portforwardingadd1');
@ -207,8 +212,8 @@ sub add_portforward {
sub get_destination_host {
my $q = shift;
my $dhost = $q->param("dhost");
my $localip = $db->get_prop('InternalInterface', 'IPAddress');
my $external_ip = $db->get_prop('ExternalInterface', 'IPAddress') || $localip;
my $localip = $cdb->get_prop('InternalInterface', 'IPAddress');
my $external_ip = $cdb->get_prop('ExternalInterface', 'IPAddress') || $localip;
if ($dhost =~ /^(127.0.0.1|$localip|$external_ip)$/i) {
@ -354,8 +359,8 @@ sub validate_destination_host {
my $c = shift;
my $dhost = $c->param('dhost');
$dhost =~ s/^\s+|\s+$//g;
my $localip = $db->get_prop('InternalInterface', 'IPAddress');
my $external_ip = $db->get_prop('ExternalInterface', 'IPAddress') || $localip;
my $localip = $cdb->get_prop('InternalInterface', 'IPAddress');
my $external_ip = $cdb->get_prop('ExternalInterface', 'IPAddress') || $localip;
if ($dhost =~ /^(localhost|127.0.0.1|$localip|$external_ip)$/i) {
@ -363,7 +368,7 @@ sub validate_destination_host {
$c->param(-name => 'dhost', -value => 'localhost');
return (ret => 'pf_SUCCESS');
} ## end if ($dhost =~ /^(localhost|127.0.0.1|$localip|$external_ip)$/i)
my $systemmode = $db->get_value('SystemMode');
my $systemmode = $cdb->get_value('SystemMode');
if ($systemmode eq 'serveronly') {
return (ret => 'pf_IN_SERVERONLY');

View File

@ -15,13 +15,15 @@ use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use esmith::FormMagick::Panel::printers;
our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my $adb;
sub main {
my $c = shift;
$c->app->log->info($c->log_req);
my %prt_datas = ();
my $title = $c->l('prt_FORM_TITLE');
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$prt_datas{'trt'} = 'LIST';
my @printerDrivers;
@ -37,6 +39,7 @@ sub do_display {
my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LIST');
my $printer = $c->param('printer') || '';
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#$trt = 'DEL' if ( $printer );
#$trt = 'ADD' if ( $rt eq 'printeradd' );
@ -77,6 +80,7 @@ sub do_update {
my $trt = ($c->param('trt') || 'LIST');
my %prt_datas = ();
my $title = $c->l('prt_FORM_TITLE');
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$prt_datas{'trt'} = $trt;
my ($res, $result) = '';

View File

@ -20,8 +20,9 @@ use SrvMngr qw(theme_list init_session);
use esmith::AccountsDB;
#use URI::Escape;
our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my ($cdb,$adb);
sub main {
my $c = shift;
@ -31,6 +32,8 @@ sub main {
my $notif = '';
$pse_datas{trt} = 'LST';
my @pseudonyms;
#$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
if ($adb) {
@pseudonyms = $adb->pseudonyms();
@ -47,7 +50,9 @@ sub do_display {
my $pseudonym = $c->param('pseudonym') || '';
my $title = $c->l('pse_FORM_TITLE');
my %pse_datas = ();
$pse_datas{'trt'} = $trt;
#$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$pse_datas{'trt'} = $trt;
if ($trt eq 'ADD') {
@ -92,6 +97,8 @@ sub do_update {
my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LST');
my $title = $c->l('pse_FORM_TITLE');
#$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my %pse_datas = ();
$pse_datas{'trt'} = $trt;
my ($res, $result) = '';

View File

@ -19,14 +19,15 @@ use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
#our $db = esmith::ConfigDB->open || die "Couldn't open config db";
our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my $adb;
sub main {
my $c = shift;
$c->app->log->info($c->log_req);
my %quo_datas = ();
my $title = $c->l('quo_FORM_TITLE');
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$quo_datas{'trt'} = 'LIST';
my @userAccounts;
@ -45,6 +46,7 @@ sub do_display {
$trt = 'UPD' if ($user);
my %quo_datas = ();
my $title = $c->l('quo_FORM_TITLE');
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$quo_datas{'trt'} = $trt;
if ($trt eq 'UPD') {
@ -73,6 +75,7 @@ sub do_update {
$quo_datas{trt} = $trt;
my $result = '';
my $res;
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
if ($trt eq 'UPD') {
$quo_datas{user} = ($c->param('user') || '');
@ -156,4 +159,10 @@ sub validate_quota {
or die($c->l('quo_ERR_MODIFYING') . "\n");
return 'OK';
} ## end sub validate_quota
sub toMB
{
my ($self,$kb) = @_;
return sprintf("%.2f", $kb / 1024);
}
1

View File

@ -28,13 +28,15 @@ use esmith::util;
#use Exporter;
#use Carp qw(verbose);
#use esmith::FormMagick::Panel::useraccounts;
our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my ($cdb,$adb);
sub main {
my $c = shift;
$c->app->log->info($c->log_req);
my $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my $notif = '';
my %usr_datas = ();
my $title = $c->l('usr_FORM_TITLE');
@ -53,6 +55,8 @@ sub do_display {
my %usr_datas = ();
my $title = $c->l('usr_FORM_TITLE');
my ($notif, $modul) = '';
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
$usr_datas{'trt'} = $trt;
if ($trt eq 'ADD') {
@ -139,6 +143,8 @@ sub do_update {
$usr_datas{trt} = $trt;
my $title = $c->l('usr_FORM_TITLE');
my ($res, $result) = '';
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
if ($trt eq 'ADD') {

View File

@ -17,7 +17,7 @@ use esmith::AccountsDB;
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw( theme_list init_session is_normal_password );
our $cdb = esmith::ConfigDB->open_ro || die "Couldn't open configuration db";
#our $cdb = esmith::ConfigDB->open_ro || die "Couldn't open configuration db";
sub main {
my $c = shift;
@ -194,6 +194,7 @@ sub check_password {
my $c = shift;
my $password = shift;
my $strength;
my $cdb = esmith::ConfigDB->open_ro || die "Couldn't open configuration db";
my $rec = $cdb->get('passwordstrength');
$strength = ($rec ? ($rec->prop('Users') || 'none') : 'none');
return validate_password($c, $strength, $password);

View File

@ -144,7 +144,9 @@ true
%changelog
* Fri Feb 07 2025 Brian Read <brianr@koozali.org> 11.0.0-49.sme
- Fix delete of ibay [SME: ]
- Fix delete of ibay - typo in link
- Move across toMB() sub from formmagick to quota.pm
- Recast DB opening so it is specific to the route rather than global [SME: 12905]
* Wed Jan 29 2025 Brian Read <brianr@koozali.org> 11.0.0-48.sme
- Make Country flag display independant of the internet. [SME: 12893]