Add in code for mailstats panel in SM2 - not complete
This commit is contained in:
@@ -0,0 +1,294 @@
|
||||
#
|
||||
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 12:46:00
|
||||
#
|
||||
#
|
||||
# Routines to be edited by the developer to provide content and validation for parameters
|
||||
# and provison of the control data for table(s)
|
||||
#
|
||||
use esmith::util;
|
||||
use esmith::util::network;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
use constant FALSE => 0;
|
||||
use constant TRUE => 1;
|
||||
|
||||
|
||||
#The most common ones
|
||||
#my $cdb
|
||||
#my $adb
|
||||
#my $ndb
|
||||
#my $hdb
|
||||
#my $ddb
|
||||
|
||||
# Validation routines - parameters for each panel
|
||||
|
||||
sub validate_TABLE {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('StatsDate')
|
||||
{$ret .= 'Validation for StatsDate failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub validate_CONFIG {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('TextorHTML')
|
||||
{$ret .= 'Validation for TextorHTML failed';}
|
||||
if (! TRUE) #validate $c->param('Email')
|
||||
{$ret .= 'Validation for Email failed';}
|
||||
if (! TRUE) #validate $c->param('EmailHost')
|
||||
{$ret .= 'Validation for EmailHost failed';}
|
||||
if (! TRUE) #validate $c->param('EmailUser')
|
||||
{$ret .= 'Validation for EmailUser failed';}
|
||||
if (! TRUE) #validate $c->param('DBSave')
|
||||
{$ret .= 'Validation for DBSave failed';}
|
||||
if (! TRUE) #validate $c->param('DBHost')
|
||||
{$ret .= 'Validation for DBHost failed';}
|
||||
if (! TRUE) #validate $c->param('DBUser')
|
||||
{$ret .= 'Validation for DBUser failed';}
|
||||
if (! TRUE) #validate $c->param('CountrySelect')
|
||||
{$ret .= 'Validation for CountrySelect failed';}
|
||||
if (! TRUE) #validate $c->param('AccumCountryCodes')
|
||||
{$ret .= 'Validation for AccumCountryCodes failed';}
|
||||
if (! TRUE) #validate $c->param('EnableRHSBL')
|
||||
{$ret .= 'Validation for EnableRHSBL failed';}
|
||||
if (! TRUE) #validate $c->param('EnableRHSBL')
|
||||
{$ret .= 'Validation for EnableRHSBL failed';}
|
||||
if (! TRUE) #validate $c->param('RBLLIST')
|
||||
{$ret .= 'Validation for RBLLIST failed';}
|
||||
if (! TRUE) #validate $c->param('SBLLIST')
|
||||
{$ret .= 'Validation for SBLLIST failed';}
|
||||
if (! TRUE) #validate $c->param('UBLLIST')
|
||||
{$ret .= 'Validation for UBLLIST failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
# Get singleton data for each panel
|
||||
|
||||
sub get_data_for_panel_TABLE {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1'=>'Data for TABLE', #Example
|
||||
# fields from Inputs in TABLE $fields['TABLE']
|
||||
'StatsDate'=>'StatsDate contents',
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
sub get_data_for_panel_CONFIG {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $key = 'mailstats';
|
||||
my %ret = (
|
||||
'Data1'=>'Data for CONFIG', #Example
|
||||
# fields from Inputs in CONFIG $fields['CONFIG']
|
||||
'TextorHTML'=>$cdb->get_prop($key,'TextorHTML') || 'HTML',
|
||||
'Email'=>$cdb->get_prop($key,'Email') || 'admin',
|
||||
'EmailHost'=>$cdb->get_prop($key,'EmailHost') || 'localhost',
|
||||
'EmailPort'=>$cdb->get_prop($key,'EmailPORT') || '25',
|
||||
'EmailUser'=>$cdb->get_prop($key,'EmailUser') || 'admin',
|
||||
'DBSave'=>$cdb->get_prop($key,'SaveDataToMySQL') || 'yes',
|
||||
'DBHost'=>$cdb->get_prop($key,'DBHost') || 'localhost',
|
||||
'DBUser'=>$cdb->get_prop($key,'DBUser') || 'admin',
|
||||
'DBPort'=>$cdb->get_prop($key,'DBPort') || '3306',
|
||||
#'CountrySelect'=>'CountrySelect ',
|
||||
'AccumCountryCodes'=>$cdb->get_prop('qpsmtpd','BadCountries'),
|
||||
'EnableRHSBL'=>$cdb->get_prop('qpsmtpd','RHSBL'),
|
||||
'EnableDNSBL'=>$cdb->get_prop('qpsmtpd','DNSBL'),
|
||||
'EnableURIBL'=>$cdb->get_prop('qpsmtpd','URIBL'),
|
||||
'RBLList'=>$cdb->get_prop('qpsmtpd','RBLList'),
|
||||
'SBLList'=>$cdb->get_prop('qpsmtpd','SBLList'),
|
||||
'UBLList'=>$cdb->get_prop('qpsmtpd','UBLList'),
|
||||
'LevelPort'=>$cdb->get_prop('spamassassin','TagLevel') || '5',
|
||||
'RejectLevel'=>$cdb->get_prop('spamassassin','RejectLevel') || '12'
|
||||
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Get control data for table(s)
|
||||
|
||||
|
||||
|
||||
# Return hash with values from row in which link clicked on table
|
||||
|
||||
sub get_selected_TABLE {
|
||||
my $c = shift;
|
||||
my $selected = shift; #Parameter is name of selected row.
|
||||
my $is_new_record = shift; #Indicates new record required (defaults)
|
||||
my %ret = {};
|
||||
return %ret;
|
||||
}
|
||||
|
||||
sub get_selected_CONFIG {
|
||||
my $c = shift;
|
||||
my $selected = shift; #Parameter is name of selected row.
|
||||
my $is_new_record = shift; #Indicates new record required (defaults)
|
||||
my %ret = {};
|
||||
return %ret;
|
||||
}
|
||||
|
||||
|
||||
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
|
||||
|
||||
sub perform_TABLE {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
my $db = $cdb; #maybe one of the others
|
||||
my $dbkey = 'ChangeThis';
|
||||
# To make it write to DB as comment, delete this (regex) string in each if statement "TRUE\) \#copy or perform with value: .* e.g."
|
||||
|
||||
if (! TRUE) #copy or perform with value: StatsDate e.g. $db->set_prop($dbkey,'StatsDate',$c->param('StatsDate'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for StatsDate';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub perform_CONFIG {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $db = $cdb; #maybe one of the others
|
||||
my $dbkey = 'mailstats';
|
||||
# To make it write to DB as comment, delete this (regex) string in each if statement "TRUE\) \#copy or perform with value: .* e.g."
|
||||
|
||||
if (! $db->set_prop($dbkey,'TextorHTML',$c->param('TextorHTML'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for TextorHTML';}
|
||||
if (! $db->set_prop($dbkey,'Email',$c->param('Email'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for Email';}
|
||||
if (! $db->set_prop($dbkey,'EmailHost',$c->param('EmailHost'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for EmailHost';}
|
||||
if (! $db->set_prop($dbkey,'EmailPort',$c->param('EmailPort'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for EmailPort';}
|
||||
if (! $db->set_prop($dbkey,'EmailUser',$c->param('EmailUser'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for EmailUser';}
|
||||
if (! $db->set_prop($dbkey,'SaveDataToMySQL',$c->param('DBSave'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for DBSave';}
|
||||
if (! $db->set_prop($dbkey,'DBHost',$c->param('DBHost'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for DBHost';}
|
||||
if (! $db->set_prop($dbkey,'DBUser',$c->param('DBUser'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for DBUser';}
|
||||
if (! $db->set_prop($dbkey,'DBPort',$c->param('DBPort'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for DBPort';}
|
||||
#if (! $db->set_prop($dbkey,'CountrySelect',$c->param('CountrySelect'),type=>'service'))
|
||||
# {$ret .= 'Perform/save failed for CountrySelect';}
|
||||
if (! $db->set_prop('qpsmtpd','BadCountries',$c->param('AccumCountryCodes'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for AccumCountryCodes';}
|
||||
if (! $db->set_prop('qpsmtpd','RHSBL',$c->param('EnableRHSBL'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for EnableRHSBL';}
|
||||
if (! $db->set_prop('qpsmtpd','DNSBL',$c->param('EnableDNSBL'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for EnableDNSBL';}
|
||||
if (! $db->set_prop('qpsmtpd','URIBL',$c->param('EnableURIBL'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for EnableURIBL';}
|
||||
if (! $db->set_prop('qpsmtpd','RBLList',$c->param('RBLList'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for RBLLIST';}
|
||||
if (! $db->set_prop('qpsmtpd','SBLList',$c->param('SBLList'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for SBLLIST';}
|
||||
if (! $db->set_prop('qpsmtpd','UBLList',$c->param('UBLList'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for UBLLIST';}
|
||||
if (! $db->set_prop('spamassassin','TagLevel',$c->param('TagLevel'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for TagLevel';}
|
||||
if (! $db->set_prop('spamassassin','RejectLevel',$c->param('RejectLevel'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for RejectLevel';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
sub create_link{
|
||||
# WIP
|
||||
my ($c,$route, $panel, $index) = @_;
|
||||
my $link = "$route?trt=$panel&Selected=$index";
|
||||
return $link;
|
||||
}
|
||||
|
||||
sub get_StatsDate{
|
||||
return ['yesterday']
|
||||
}
|
||||
|
||||
sub get_CountryCodes {
|
||||
return [
|
||||
['Afghanistan' => 'AF'], # Frequent political/malware spam
|
||||
['Argentina' => 'AR'], # 52% spam call rate (highest globally)
|
||||
['Brazil' => 'BR'], # Top spam call origin
|
||||
['China' => 'CN'], # High spam volume
|
||||
['France' => 'FR'], # 43% spam call rate, top email spam source
|
||||
['Germany' => 'DE'], # Significant email spam volume
|
||||
['India' => 'IN'], # High spam call/text volume
|
||||
['Indonesia' => 'ID'], # 51.5% spam call rate
|
||||
['Italy' => 'IT'], # 35.1% spam call rate, email spam source
|
||||
['Malaysia' => 'MY'], # 63% scam calls
|
||||
['Mexico' => 'MX'], # Emerging spam source
|
||||
['Nigeria' => 'NG'], # "Nigerian prince" scams
|
||||
['Pakistan' => 'PK'], # Phishing campaigns
|
||||
['Peru' => 'PE'], # Emerging spam source
|
||||
['Russia' => 'RU'], # Cybercrime associations
|
||||
['Saudi Arabia' => 'SA'], # High spam volume
|
||||
['Spain' => 'ES'], # 43.9% spam call rate, email spam
|
||||
['Turkey' => 'TR'], # Significant spam activity
|
||||
['Ukraine' => 'UA'], # Spam proxy servers
|
||||
['United States' => 'US'], # High email spam volume
|
||||
['Viet Nam' => 'VN'] # Phishing/malware origins
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
sub get_RBL_lists{
|
||||
return (
|
||||
# Other Major Providers
|
||||
"zen.spamhaus.org", # Combines SBL, XBL, and PBL
|
||||
'bl.spamcop.net', # SpamCop Blocklist (user-reported spam)
|
||||
'cbl.abuseat.org', # Composite Blocking List (bot-infected hosts)
|
||||
'b.barracudacentral.org', # Barracuda Reputation Blocklist
|
||||
|
||||
# Specialized Lists
|
||||
'dun.dnsrbl.net', # DNSRBL (DNS-based blacklist)
|
||||
'psbl.surriel.com', # Passive Spam Block List (passive spam traps)
|
||||
'backscatterer.org', # Backscatter/Out-of-Bounce spam sources
|
||||
'dronebl.org', # Drones/Proxy/DDoS sources
|
||||
'dnsbl-1.uceprotect.net',# UCEPROTECT Level 1 (entry-level blocking)[User Query]
|
||||
'dnsbl-2.uceprotect.net' # UCEPROTECT Level 2 (more aggressive)[User Query]
|
||||
);}
|
||||
|
||||
sub get_SBL_list{
|
||||
return (
|
||||
"sbl.spamhaus.org", # Spamhaus Blocklist
|
||||
"xbl.spamhaus.org", # eXploits Blocklist
|
||||
"pbl.spamhaus.org", # Policy Blocklist
|
||||
"auth.spamhaus.org", # Auth Blocklist
|
||||
"multi.surbl.org", # SURBL's multi-level URI checker (domains in email content)
|
||||
"rhsbl.sorbs.net" # Right-Hand Side Blocklist (domain-based, not IP-based)
|
||||
);}
|
||||
|
||||
sub get_URIBL_list{
|
||||
return my @uribl_lists = (
|
||||
"uribl.com", # Primary URIBL service
|
||||
"multi.uribl.com", # Combined URIBL checks
|
||||
"black.uribl.com", # Aggressive blocking list
|
||||
"grey.uribl.com", # Suspicious URI list
|
||||
"white.uribl.com" # Verified safe URI list
|
||||
);}
|
||||
|
||||
1;
|
315
root/usr/share/smanager/lib/SrvMngr/Controller/Mailstats.pm
Normal file
315
root/usr/share/smanager/lib/SrvMngr/Controller/Mailstats.pm
Normal file
@@ -0,0 +1,315 @@
|
||||
package SrvMngr::Controller::Mailstats;
|
||||
#
|
||||
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-05 11:59:08
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Investigation
|
||||
# description : Mailstats
|
||||
# navigation : 4000 700
|
||||
#
|
||||
# name : mailstats, method : get, url : /mailstats, ctlact : Mailstats#main
|
||||
# name : mailstatsu, method : post, url : /mailstatsu, ctlact : Mailstats#do_update
|
||||
# name : mailstatsd, method : get, url : /mailstatsd, ctlact : Mailstats#do_display
|
||||
#
|
||||
# routes : end
|
||||
#
|
||||
# Documentation: https://wiki.contribs.org/Mailstats
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# Scheme of things:
|
||||
#
|
||||
# TBA!!
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use constant FALSE => 0;
|
||||
use constant TRUE => 1;
|
||||
|
||||
use Locale::gettext;
|
||||
use SrvMngr::I18N;
|
||||
use SrvMngr qw(theme_list init_session);
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use esmith::util;
|
||||
use esmith::util::network;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
my $cdb;
|
||||
my $adb;
|
||||
my $ndb;
|
||||
my $hdb;
|
||||
my $ddb;
|
||||
|
||||
require '/usr/share/smanager/lib/SrvMngr/Controller/Mailstats-Custom.pm'; #The code that is to be added by the developer
|
||||
|
||||
sub main {
|
||||
#
|
||||
# Initial entry - route is "/<whatever>"
|
||||
#
|
||||
#set initial panel
|
||||
#for initial panel:
|
||||
#Specifiy panel to enter
|
||||
#load up _data hash with DB fields
|
||||
#load up stash with pointer(s) to control fields hash(= get-))
|
||||
#and a pointer to the prefix_data hash
|
||||
#render initial panel
|
||||
|
||||
my $c = shift;
|
||||
$c->app->log->info( $c->log_req );
|
||||
|
||||
#The most common ones
|
||||
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
my %mst_data = ();
|
||||
my $title = $c->l('mst_Mailstats');
|
||||
my $modul = '';
|
||||
|
||||
$mst_data{'trt'} = 'TABLE';
|
||||
|
||||
#Load any DB entries into the <prefix>_data area so as they are preset in the form
|
||||
# which DB - this only really works if the initial panel is a PARAMS type panel and not a TABLE
|
||||
my $db = $cdb; #pickup local or global db or Default to config
|
||||
|
||||
|
||||
$c->do_display($mst_data{'trt'});
|
||||
|
||||
}
|
||||
|
||||
# Post request with params - submit from the form
|
||||
sub do_update {
|
||||
#
|
||||
# Return after submit pushed on panel (this is a post) - route is "/<whatever>u"
|
||||
# parameters in the params hash.
|
||||
#
|
||||
#load up all params into prefix_data hash:
|
||||
#By panel (series of if statements - only one executed):
|
||||
#call validate-PANEL() - return ret = ok or error message
|
||||
|
||||
#if validation not ok:
|
||||
#render back to current panel with error message in stash
|
||||
#otherwise:
|
||||
#By panel (series of if statements - only one executed):
|
||||
#do whatever is required: call perform-PANEL() - return "ok" or Error Message
|
||||
#call signal-event for any global actions specified (check it exists - error and continue?)
|
||||
#if action smeserver-<whatever>-update exists
|
||||
#signal_event smeserver-<whatever>-update
|
||||
#call signal-event for any specific actions for thids panel (check it exists first - error and continue)
|
||||
#set success in stash
|
||||
#if no "nextpanel" entry:
|
||||
#set firstpanel
|
||||
#else
|
||||
#set nextpanel
|
||||
#call render
|
||||
|
||||
my $c = shift;
|
||||
$c->app->log->info($c->log_req);
|
||||
my $modul = '';
|
||||
|
||||
#The most common ones - you might want to comment out any not used.
|
||||
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
my %mst_data = ();
|
||||
my $title = $c->l('mst_Mailstats');
|
||||
|
||||
# Accessing all POST/GET parameters
|
||||
my $params = $c->req->params->to_hash;
|
||||
|
||||
# Get number of POST parameters
|
||||
#my $num_params = keys scaler %$params;
|
||||
|
||||
#Params are available in the hash "params" - copy to the prefix_data hash
|
||||
#while (my ($key, $value) = each %{$c->req->params->to_hash}) {
|
||||
# $mst_data{$key} = $value;
|
||||
#}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'TABLE'; #hidden control on every form.
|
||||
my $ret = 'ok';
|
||||
|
||||
#Validate the parameters in a custom sub one for each panel (although only one of these will be executed)
|
||||
my $thispanel;
|
||||
|
||||
if ($trt eq 'TABLE'){
|
||||
#Validate form parameters for panel TABLE
|
||||
$ret = $c->validate_TABLE(\%mst_data);
|
||||
$thispanel = 'TABLE';
|
||||
}
|
||||
|
||||
if ($trt eq 'CONFIG'){
|
||||
#Validate form parameters for panel CONFIG
|
||||
$ret = $c->validate_CONFIG(\%mst_data);
|
||||
$thispanel = 'CONFIG';
|
||||
}
|
||||
|
||||
if ($ret ne "ok"){
|
||||
$c->do_display($thispanel);
|
||||
} else {
|
||||
#Do whatever is needed, including writing values to the DB
|
||||
|
||||
|
||||
if ($trt eq 'TABLE'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_TABLE(\%mst_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mst_data => \%mst_data
|
||||
);
|
||||
$c->render(template => "mailstats");
|
||||
} else {
|
||||
$c->stash( success => $c->l('mst_TABLE_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'CONFIG'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_CONFIG(\%mst_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mst_data => \%mst_data
|
||||
);
|
||||
$c->render(template => "mailstats");
|
||||
} else {
|
||||
$c->stash( success => $c->l('mst_CONFIG_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
# and call any signal-events needed
|
||||
#TBD
|
||||
# Setup shared data and call panel
|
||||
if ('none' eq 'none') {
|
||||
$mst_data{'trt'} = 'TABLE';
|
||||
} else {
|
||||
$mst_data{'trt'} = 'none';
|
||||
}
|
||||
$c->do_display($mst_data{'trt'});
|
||||
}
|
||||
}
|
||||
|
||||
sub do_display {
|
||||
#
|
||||
# Return after link clicked in table (this is a get) - route is "/<whatever>d"
|
||||
# Expects ?trt=PANEL&selected="TableRowName" plus any other required
|
||||
#
|
||||
# OR it maybe a post from the main panel to add a new record
|
||||
#
|
||||
#load up all supplied params into prefix_data hash
|
||||
#call get-selected-PANEL() - returns hash of all relevent parameters
|
||||
#load up returned hash into prefix_data
|
||||
#render - to called panel
|
||||
|
||||
my ($c,$trt) = @_;
|
||||
$c->app->log->info($c->log_req);
|
||||
|
||||
#The most common ones - you might want to comment out any not used.
|
||||
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
my %mst_data = ();
|
||||
my $title = $c->l('mst_Mailstats');
|
||||
my $modul = "";
|
||||
|
||||
# Accessing all parameters
|
||||
my %params = $c->req->params->to_hash;
|
||||
|
||||
# Get number of parameters
|
||||
my $num_params = keys %params;
|
||||
|
||||
#Tag as Post or Get (ie. create new entry or edit existing one
|
||||
my $is_new_record = ($c->req->method() eq 'POST');
|
||||
|
||||
#Params are available in the hash "params" - copy to the prefix_data hash
|
||||
#while (my ($key, $value) = each %{$c->req->params->to_hash}) {
|
||||
# $mst_data{$key} = $value;
|
||||
#}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
if (! $trt){
|
||||
$trt = $c->param('trt') || 'TABLE'; #Indicates where to go now
|
||||
}
|
||||
|
||||
# Now add in the params from the selected row from the table
|
||||
|
||||
my %selectedrow;
|
||||
|
||||
if ($trt eq 'TABLE'){
|
||||
#Validate Get selected row (if applicable) TABLE
|
||||
%selectedrow = $c->get_selected_TABLE($mst_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'CONFIG'){
|
||||
#Validate Get selected row (if applicable) CONFIG
|
||||
%selectedrow = $c->get_selected_CONFIG($mst_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
|
||||
#Copy in the selected row params to the prefix_data hash to pass to the panel
|
||||
while (my ($key, $value) = each %selectedrow){
|
||||
$mst_data{$key} = $value;
|
||||
}
|
||||
# Where to go now
|
||||
$mst_data{'trt'} = $trt;
|
||||
|
||||
# Set up other shared data according to the panel to go to
|
||||
|
||||
if ($trt eq 'TABLE'){
|
||||
# pickup any other contents needed and load them into hash shared with panel
|
||||
my %returned_hash;
|
||||
# subroutine returns a hash directly
|
||||
%returned_hash = $c->get_data_for_panel_TABLE();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$mst_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'CONFIG'){
|
||||
# pickup any other contents needed and load them into hash shared with panel
|
||||
my %returned_hash;
|
||||
# subroutine returns a hash directly
|
||||
%returned_hash = $c->get_data_for_panel_CONFIG();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$mst_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# and table control fields
|
||||
|
||||
|
||||
# Data for panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mst_data => \%mst_data
|
||||
);
|
||||
$c->render(template => "mailstats");
|
||||
}
|
||||
1;
|
@@ -0,0 +1,37 @@
|
||||
#
|
||||
# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-05 11:59:08
|
||||
#
|
||||
'mst_Host_name_for_DB_server' => 'Host name for DB server',
|
||||
'mst_Enable_RHSBL_checking' => 'Enable RHSBL checking',
|
||||
'mst_RBL_Servers_to_use' => 'RBL Servers to use',
|
||||
'mst_Port_number_for_email_server' => 'Port number for email server',
|
||||
'mst_User_name_for_DB_sending' => 'User name for DB sending',
|
||||
'mst_Table_of_email_status' => 'Table of email status',
|
||||
'mst_Score_to_fully_reject_emmail' => 'Score to fully reject email',
|
||||
'mst_User_Password_for_email_sending' => 'User Password for email sending',
|
||||
'mst_UBL_Servers_to_use' => 'UBL Servers to use',
|
||||
'mst_Would_you_like_to_save' => 'Would you like to save data in the DB?',
|
||||
'mst_Specify_if_you_would_like' => 'Specify if you would like to receive email in text or HTML form',
|
||||
'mst_Port_number_for_DB_server' => 'Port number for DB server',
|
||||
'mst_Mailstats' => 'mailshots',
|
||||
'mst_Email_filtering_/_exclusion' => 'Email filtering / exclusion',
|
||||
'mst_Score_for_tagging_as_spam,' => 'Score for tagging as spam But queued',
|
||||
'mst_Accumulated_country_codes_(editable)' => 'Accumulated country codes editable',
|
||||
'mst_Date_for_Stats_display' => 'Date for Stats display',
|
||||
'mst_Enable_URIBL_checking' => 'Enable URIBL checking',
|
||||
'mst_CONFIG_panel_action_was_successful' => 'CONFIG panel action was successful',
|
||||
'mst_Email_details' => 'Email details',
|
||||
'mst_User_Password_for_DB_sending' => 'User Password for DB sending',
|
||||
'mst_Email_for_stats' => 'Email for stats',
|
||||
'mst_Select_the_countries_you_would' => 'Select the countries you would like to reject',
|
||||
'mst_Spamassassin_scores_-_tag_and' => 'Spamassassin scores - tag and reject levels',
|
||||
'mst_SBL_Servers_to_use' => 'SBL Servers to use',
|
||||
'mst_Save' => 'Save',
|
||||
'mst_Descriptive_paragraph' => 'Descriptive paragraph',
|
||||
'mst_APPLY' => 'Apply',
|
||||
'mst_Enable_DNSBL_checking' => 'Enable DNSBL checking',
|
||||
'mst_Host_name_for_email_server' => 'Host name for email server',
|
||||
'mst_Details_for_connection_to_database' => 'Details for connection to database for saving email status',
|
||||
'mst_TABLE_panel_action_was_successful' => 'TABLE panel action was successful',
|
||||
'mst_Configure_Mailstats' => 'Configure mailshots',
|
||||
'mst_User_name_for_email_sending' => 'User name for email sending',
|
Reference in New Issue
Block a user