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

View File

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

View File

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

View File

@ -19,15 +19,18 @@ use esmith::ConfigDB;
use esmith::DomainsDB; use esmith::DomainsDB;
#use esmith::FormMagick::Panel::ibays; #use esmith::FormMagick::Panel::ibays;
our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; #our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db"; #our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my ($adb,$cdb);
sub main { sub main {
my $c = shift; my $c = shift;
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my %iba_datas = (); my %iba_datas = ();
my $title = $c->l('iba_FORM_TITLE'); 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; my @ibays;
if ($adb) { if ($adb) {
@ -42,6 +45,8 @@ sub do_display {
my $rt = $c->current_route; my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LIST'); my $trt = ($c->param('trt') || 'LIST');
my $ibay = $c->param('ibay') || ''; 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 = 'DEL' if ( $ibay );
#$trt = 'ADD' if ( $rt eq 'ibayadd' ); #$trt = 'ADD' if ( $rt eq 'ibayadd' );
@ -116,6 +121,8 @@ sub do_update {
$iba_datas{'trt'} = $trt; $iba_datas{'trt'} = $trt;
my $result = ''; my $result = '';
my $res; 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') { if ($trt eq 'ADD') {
my $name = ($c->param('ibay') || ''); 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 Data::Dumper;
use esmith::util; use esmith::util;
use esmith::HostsDB; 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 $ret = "OK";
my ($network_db);
sub main { sub main {
my $c = shift; my $c = shift;
@ -26,6 +27,7 @@ sub main {
my %ln_datas = (); my %ln_datas = ();
$ln_datas{return} = ""; $ln_datas{return} = "";
my $title = $c->l('ln_LOCAL NETWORKS'); my $title = $c->l('ln_LOCAL NETWORKS');
$network_db = esmith::NetworksDB->open() || die("Couldn't open networks db");
my $modul = ''; my $modul = '';
$ln_datas{trt} = 'LIST'; $ln_datas{trt} = 'LIST';
my @localnetworks; my @localnetworks;
@ -47,6 +49,7 @@ sub do_display {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my $rt = $c->current_route; my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LIST'); my $trt = ($c->param('trt') || 'LIST');
$network_db = esmith::NetworksDB->open() || die("Couldn't open networks db");
$trt = 'DEL' if ($rt eq 'localnetworksdel'); $trt = 'DEL' if ($rt eq 'localnetworksdel');
$trt = 'ADD' if ($rt eq 'localnetworksadd'); $trt = 'ADD' if ($rt eq 'localnetworksadd');
$trt = 'ADD1' if ($rt eq 'localnetworksadd1'); $trt = 'ADD1' if ($rt eq 'localnetworksadd1');
@ -81,7 +84,7 @@ sub do_display {
if ($trt eq 'DEL1') { if ($trt eq 'DEL1') {
#After Remove clicked on Delete network panel #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 $localnetwork = $c->param("localnetwork");
my $delete_hosts = $c->param("deletehost") || "1"; #default to deleting them. 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"); my $rec = $network_db->get($localnetwork) || die("Failed to find network on db:$localnetwork");
@ -135,7 +138,7 @@ sub do_display {
sub remove_network { sub remove_network {
my $network = shift; my $network = shift;
my $network_db = esmith::NetworksDB->open(); $network_db = esmith::NetworksDB->open();
my $record = $network_db->get($network); my $record = $network_db->get($network);
my $delete_hosts = shift; my $delete_hosts = shift;
@ -265,3 +268,4 @@ sub add_network {
); );
} ## end else [ if ($totalHosts == 1) ] } ## end else [ if ($totalHosts == 1) ]
} ## end sub add_network } ## end sub add_network
1;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -144,7 +144,9 @@ true
%changelog %changelog
* Fri Feb 07 2025 Brian Read <brianr@koozali.org> 11.0.0-49.sme * 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 * Wed Jan 29 2025 Brian Read <brianr@koozali.org> 11.0.0-48.sme
- Make Country flag display independant of the internet. [SME: 12893] - Make Country flag display independant of the internet. [SME: 12893]