Add in mailstats generated code amd add html object to html controls

This commit is contained in:
Brian Read 2025-04-06 07:58:24 +01:00
parent 9f154c586d
commit a5272319f2
10 changed files with 320 additions and 106 deletions

View File

@ -13,6 +13,8 @@ use esmith::AccountsDB;
use esmith::NetworksDB; use esmith::NetworksDB;
use esmith::DomainsDB; use esmith::DomainsDB;
use POSIX 'strftime';
use constant FALSE => 0; use constant FALSE => 0;
use constant TRUE => 1; use constant TRUE => 1;
@ -94,23 +96,31 @@ use constant TRUE => 1;
sub get_data_for_panel_CONFIG { sub get_data_for_panel_CONFIG {
# Return a hash with the fields required which will be loaded into the shared data # Return a hash with the fields required which will be loaded into the shared data
my $c = shift; my $c = shift;
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $key = 'mailstats';
my %ret = ( my %ret = (
'Data1'=>'Data for CONFIG', #Example 'Data1'=>'Data for CONFIG', #Example
# fields from Inputs in CONFIG $fields['CONFIG'] # fields from Inputs in CONFIG $fields['CONFIG']
'TextorHTML'=>'TextorHTML contents', 'TextorHTML'=>$cdb->get_prop($key,'TextorHTML') || 'HTML',
'Email'=>'Email contents', 'Email'=>$cdb->get_prop($key,'Email') || 'admin',
'EmailHost'=>'EmailHost contents', 'EmailHost'=>$cdb->get_prop($key,'EmailHost') || 'localhost',
'EmailUser'=>'EmailUser contents', 'EmailPort'=>$cdb->get_prop($key,'EmailPORT') || '25',
'DBSave'=>'DBSave contents', 'EmailUser'=>$cdb->get_prop($key,'EmailUser') || 'admin',
'DBHost'=>'DBHost contents', 'DBSave'=>$cdb->get_prop($key,'SaveDataToMySQL') || 'yes',
'DBUser'=>'DBUser contents', 'DBHost'=>$cdb->get_prop($key,'DBHost') || 'localhost',
'CountrySelect'=>'CountrySelect contents', 'DBUser'=>$cdb->get_prop($key,'DBUser') || 'admin',
'AccumCountryCodes'=>'AccumCountryCodes contents', 'DBPort'=>$cdb->get_prop($key,'DBPort') || '3306',
'EnableRHSBL'=>'EnableRHSBL contents', #'CountrySelect'=>'CountrySelect ',
'EnableRHSBL'=>'EnableRHSBL contents', 'AccumCountryCodes'=>$cdb->get_prop('qpsmtpd','BadCountries'),
'RBLLIST'=>'RBLLIST contents', 'EnableRHSBL'=>$cdb->get_prop('qpsmtpd','RHSBL'),
'SBLLIST'=>'SBLLIST contents', 'EnableDNSBL'=>$cdb->get_prop('qpsmtpd','DNSBL'),
'UBLLIST'=>'UBLLIST contents', '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; return %ret;
@ -161,38 +171,49 @@ use constant TRUE => 1;
my $c = shift; my $c = shift;
my $prefix_data = shift; #Data hash as parameter my $prefix_data = shift; #Data hash as parameter
my $ret = ""; my $ret = "";
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $db = $cdb; #maybe one of the others my $db = $cdb; #maybe one of the others
my $dbkey = 'ChangeThis'; 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." # 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: TextorHTML e.g. $db->set_prop($dbkey,'TextorHTML',$c->param('TextorHTML'),type=>'service')) if (! $db->set_prop($dbkey,'TextorHTML',$c->param('TextorHTML'),type=>'service'))
{$ret .= 'Perform/save failed for TextorHTML';} {$ret .= 'Perform/save failed for TextorHTML';}
if (! TRUE) #copy or perform with value: Email e.g. $db->set_prop($dbkey,'Email',$c->param('Email'),type=>'service')) if (! $db->set_prop($dbkey,'Email',$c->param('Email'),type=>'service'))
{$ret .= 'Perform/save failed for Email';} {$ret .= 'Perform/save failed for Email';}
if (! TRUE) #copy or perform with value: EmailHost e.g. $db->set_prop($dbkey,'EmailHost',$c->param('EmailHost'),type=>'service')) if (! $db->set_prop($dbkey,'EmailHost',$c->param('EmailHost'),type=>'service'))
{$ret .= 'Perform/save failed for EmailHost';} {$ret .= 'Perform/save failed for EmailHost';}
if (! TRUE) #copy or perform with value: EmailUser e.g. $db->set_prop($dbkey,'EmailUser',$c->param('EmailUser'),type=>'service')) 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';} {$ret .= 'Perform/save failed for EmailUser';}
if (! TRUE) #copy or perform with value: DBSave e.g. $db->set_prop($dbkey,'DBSave',$c->param('DBSave'),type=>'service')) if (! $db->set_prop($dbkey,'SaveDataToMySQL',$c->param('DBSave'),type=>'service'))
{$ret .= 'Perform/save failed for DBSave';} {$ret .= 'Perform/save failed for DBSave';}
if (! TRUE) #copy or perform with value: DBHost e.g. $db->set_prop($dbkey,'DBHost',$c->param('DBHost'),type=>'service')) if (! $db->set_prop($dbkey,'DBHost',$c->param('DBHost'),type=>'service'))
{$ret .= 'Perform/save failed for DBHost';} {$ret .= 'Perform/save failed for DBHost';}
if (! TRUE) #copy or perform with value: DBUser e.g. $db->set_prop($dbkey,'DBUser',$c->param('DBUser'),type=>'service')) if (! $db->set_prop($dbkey,'DBUser',$c->param('DBUser'),type=>'service'))
{$ret .= 'Perform/save failed for DBUser';} {$ret .= 'Perform/save failed for DBUser';}
if (! TRUE) #copy or perform with value: CountrySelect e.g. $db->set_prop($dbkey,'CountrySelect',$c->param('CountrySelect'),type=>'service')) if (! $db->set_prop($dbkey,'DBPort',$c->param('DBPort'),type=>'service'))
{$ret .= 'Perform/save failed for CountrySelect';} {$ret .= 'Perform/save failed for DBPort';}
if (! TRUE) #copy or perform with value: AccumCountryCodes e.g. $db->set_prop($dbkey,'AccumCountryCodes',$c->param('AccumCountryCodes'),type=>'service')) #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';} {$ret .= 'Perform/save failed for AccumCountryCodes';}
if (! TRUE) #copy or perform with value: EnableRHSBL e.g. $db->set_prop($dbkey,'EnableRHSBL',$c->param('EnableRHSBL'),type=>'service')) if (! $db->set_prop('qpsmtpd','RHSBL',$c->param('EnableRHSBL'),type=>'service'))
{$ret .= 'Perform/save failed for EnableRHSBL';} {$ret .= 'Perform/save failed for EnableRHSBL';}
if (! TRUE) #copy or perform with value: EnableRHSBL e.g. $db->set_prop($dbkey,'EnableRHSBL',$c->param('EnableRHSBL'),type=>'service')) if (! $db->set_prop('qpsmtpd','DNSBL',$c->param('EnableDNSBL'),type=>'service'))
{$ret .= 'Perform/save failed for EnableRHSBL';} {$ret .= 'Perform/save failed for EnableDNSBL';}
if (! TRUE) #copy or perform with value: RBLLIST e.g. $db->set_prop($dbkey,'RBLLIST',$c->param('RBLLIST'),type=>'service')) 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';} {$ret .= 'Perform/save failed for RBLLIST';}
if (! TRUE) #copy or perform with value: SBLLIST e.g. $db->set_prop($dbkey,'SBLLIST',$c->param('SBLLIST'),type=>'service')) if (! $db->set_prop('qpsmtpd','SBLList',$c->param('SBLList'),type=>'service'))
{$ret .= 'Perform/save failed for SBLLIST';} {$ret .= 'Perform/save failed for SBLLIST';}
if (! TRUE) #copy or perform with value: UBLLIST e.g. $db->set_prop($dbkey,'UBLLIST',$c->param('UBLLIST'),type=>'service')) if (! $db->set_prop('qpsmtpd','UBLList',$c->param('UBLList'),type=>'service'))
{$ret .= 'Perform/save failed for UBLLIST';} {$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';} if ($ret eq "") {$ret = 'ok';}
return $ret; return $ret;
} }
@ -209,7 +230,92 @@ sub get_StatsDate{
return ['yesterday'] return ['yesterday']
} }
sub get_CountrCodes{ sub get_CountryCodes {
return ['UK'] 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
);}
sub get_mailstat_dates {
my ($directory) = '/opt/mailstats/html';
my @date_pairs;
# Find all matching files in directory
opendir(my $dh, $directory) or die "Can't open directory: $!";
while (my $file = readdir($dh)) {
next unless $file =~ /mailstats_for_(\d{4}-\d{2}-\d{2})\.html$/;
my $date = $1;
if ($date =~ /^(\d{4})-(\d{2})-(\d{2})$/) {
my $formatted_date = strftime("%B %-d %Y", 0, 0, 0, $3, $2-1, $1-1900);
push @date_pairs, [$formatted_date, $date];
}
}
closedir($dh);
# Sort dates chronologically
@date_pairs = sort { $a->[1] cmp $b->[1] } @date_pairs;
return \@date_pairs;
}
1; 1;

View File

@ -1,6 +1,6 @@
package SrvMngr::Controller::Mailstats; package SrvMngr::Controller::Mailstats;
# #
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 13:12:40 # 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 # heading : Investigation

View File

@ -1,5 +1,5 @@
%# %#
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 13:12:40 %# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-05 11:17:38
%# %#
<div id="Mailstats-CONFIG" class="partial Mailstats-CONFIG"> <div id="Mailstats-CONFIG" class="partial Mailstats-CONFIG">
<script> <script>
@ -40,7 +40,7 @@
<p><span class=label> <p><span class=label>
%=l('mst_Hostname_for_email_server') %=l('mst_Host_name_for_email_server')
</span><span class=data> </span><span class=data>
% param 'EmailHost' => $mst_data->{EmailHost} unless param 'EmailHost'; % param 'EmailHost' => $mst_data->{EmailHost} unless param 'EmailHost';
%= text_field 'EmailHost', size => '50', class => 'textinput EmailHost' , pattern=>'.*' , placeholder=>'EmailHost', title =>'Pattern regex mismatch' %= text_field 'EmailHost', size => '50', class => 'textinput EmailHost' , pattern=>'.*' , placeholder=>'EmailHost', title =>'Pattern regex mismatch'
@ -86,7 +86,7 @@
<h2 class='subh2'><%=l('mst_Details_for_connection_to_database')%></h2> <h2 class='subh2'><%=l('mst_Details_for_connection_to_database')%></h2>
<p><span class=label> <p><span class=label>
%=l('mst_Hostname_for_DB_server') %=l('mst_Host_name_for_DB_server')
</span><span class=data> </span><span class=data>
% param 'DBHost' => $mst_data->{DBHost} unless param 'DBHost'; % param 'DBHost' => $mst_data->{DBHost} unless param 'DBHost';
%= text_field 'DBHost', size => '50', class => 'textinput DBHost' , pattern=>'.*' , placeholder=>'DBHost', title =>'Pattern regex mismatch' %= text_field 'DBHost', size => '50', class => 'textinput DBHost' , pattern=>'.*' , placeholder=>'DBHost', title =>'Pattern regex mismatch'
@ -123,22 +123,22 @@
<p><span class=label> <p><span class=label>
%=l('mst_Select_the_countries_you_would') %=l('mst_Select_the_countries_you_would')
</span><span class=data> </span><span class=data>
% my @CountrySelect_options = [['$c->get_CountryCodes()' => '$c->get_CountryCodes()']]; % my @CountrySelect_options = $c->get_CountryCodes();
% param 'CountrySelect' => $mst_data->{CountrySelect} unless param 'CountrySelect'; % param 'CountrySelect' => $mst_data->{CountrySelect} unless param 'CountrySelect';
%= select_field 'CountrySelect' => @CountrySelect_options, class => 'input', id => 'CountrySelect_select' %= select_field 'CountrySelect' => @CountrySelect_options, class => 'input', id => 'CountrySelect_select', multiple => 'multiple'
<br></span> </p> <br></span> </p>
<p><span class=label> <p><span class=label>
%=l('mst_Accumlated_country_codes_(editable)') %=l('mst_Accumulated_country_codes_(editable)')
</span><span class=data> </span><span class=data>
% param 'AccumCountryCodes' => $mst_data->{AccumCountryCodes} unless param 'AccumCountryCodes'; % param 'AccumCountryCodes' => $mst_data->{AccumCountryCodes} unless param 'AccumCountryCodes';
%= text_field 'AccumCountryCodes', size => '50', class => 'textinput AccumCountryCodes' , pattern=>'.*' , placeholder=>'AccumCountryCodes', title =>'Pattern regex mismatch' %= text_field 'AccumCountryCodes', size => '50', class => 'textinput AccumCountryCodes' , pattern=>'.*' , placeholder=>'AccumCountryCodes', title =>'Pattern regex mismatch', id => 'AccumCountryCodes_text'
<br></span></p> <br></span></p>
<p><span class=label> <p><span class=label>
%=l('mst_Enable_RHSBL_checking') %=l('mst_Enable_RHSBL_checking')
</span><span class=data> </span><span class=data>
% my @EnableRHSBL_options = [['yes' => 'yes'], ['no' => 'no']]; % my @EnableRHSBL_options = [['yes' => 'enabled'], ['no' => 'disabled']];
% param 'EnableRHSBL' => $mst_data->{EnableRHSBL} unless param 'EnableRHSBL'; % param 'EnableRHSBL' => $mst_data->{EnableRHSBL} unless param 'EnableRHSBL';
%= select_field 'EnableRHSBL' => @EnableRHSBL_options, class => 'input', id => 'EnableRHSBL_select' %= select_field 'EnableRHSBL' => @EnableRHSBL_options, class => 'input', id => 'EnableRHSBL_select'
<br></span> </p> <br></span> </p>
@ -146,36 +146,44 @@
<p><span class=label> <p><span class=label>
%=l('mst_Enable_DNSBL_checking') %=l('mst_Enable_DNSBL_checking')
</span><span class=data> </span><span class=data>
% my @EnableDNSBL_options = [['yes' => 'yes'], ['no' => 'no']]; % my @EnableDNSBL_options = [['yes' => 'enabled'], ['no' => 'disabled']];
% param 'EnableDNSBL' => $mst_data->{EnableDNSBL} unless param 'EnableDNSBL'; % param 'EnableDNSBL' => $mst_data->{EnableDNSBL} unless param 'EnableDNSBL';
%= select_field 'EnableDNSBL' => @EnableDNSBL_options, class => 'input', id => 'EnableDNSBL_select' %= select_field 'EnableDNSBL' => @EnableDNSBL_options, class => 'input', id => 'EnableDNSBL_select'
<br></span> </p> <br></span> </p>
<p><span class=label>
%=l('mst_Enable_URIBL_checking')
</span><span class=data>
% my @EnableURIBL_options = [['yes' => 'enabled'], ['no' => 'disabled']];
% param 'EnableURIBL' => $mst_data->{EnableURIBL} unless param 'EnableURIBL';
%= select_field 'EnableURIBL' => @EnableURIBL_options, class => 'input', id => 'EnableURIBL_select'
<br></span> </p>
<p><span class=label> <p><span class=label>
%=l('mst_RBL_Servers_to_use') %=l('mst_RBL_Servers_to_use')
</span><span class=data> </span><span class=data>
% param 'RBLLIST' => $mst_data->{RBLLIST} unless param 'RBLLIST'; % param 'RBLList' => $mst_data->{RBLList} unless param 'RBLList';
%= text_field 'RBLLIST', size => '50', class => 'textinput RBLLIST' , pattern=>'.*' , placeholder=>'RBLLIST', title =>'Pattern regex mismatch' %= text_field 'RBLList', size => '50', class => 'textinput RBLList' , pattern=>'.*' , placeholder=>'RBLList', title =>'Pattern regex mismatch'
<br></span></p> <br></span></p>
<p><span class=label> <p><span class=label>
%=l('mst_SBL_Servers_to_use') %=l('mst_SBL_Servers_to_use')
</span><span class=data> </span><span class=data>
% param 'SBLLIST' => $mst_data->{SBLLIST} unless param 'SBLLIST'; % param 'SBLList' => $mst_data->{SBLList} unless param 'SBLList';
%= text_field 'SBLLIST', size => '50', class => 'textinput SBLLIST' , pattern=>'.*' , placeholder=>'SBLLIST', title =>'Pattern regex mismatch' %= text_field 'SBLList', size => '50', class => 'textinput SBLList' , pattern=>'.*' , placeholder=>'SBLList', title =>'Pattern regex mismatch'
<br></span></p> <br></span></p>
<p><span class=label> <p><span class=label>
%=l('mst_UBL_Servers_to_use') %=l('mst_UBL_Servers_to_use')
</span><span class=data> </span><span class=data>
% param 'UBLLIST' => $mst_data->{UBLLIST} unless param 'UBLLIST'; % param 'UBLList' => $mst_data->{UBLList} unless param 'UBLList';
%= text_field 'UBLLIST', size => '50', class => 'textinput UBLLIST' , pattern=>'.*' , placeholder=>'UBLLIST', title =>'Pattern regex mismatch' %= text_field 'UBLList', size => '50', class => 'textinput UBLList' , pattern=>'.*' , placeholder=>'UBLList', title =>'Pattern regex mismatch'
<br></span></p> <br></span></p>
<h2 class='subh4'><%=l('mst_Spamassassin_parameters_for_rejecting_email')%></h2> <h2 class='subh4'><%=l('mst_Spamassassin_scores_-_tag_and')%></h2>
<p><span class='label'> <p><span class='label'>
%=l('mst_Score_over_which_email_will') %=l('mst_Score_to_fully_reject_emmail')
</span><span class=data> </span><span class=data>
% param 'RejectLevel' => $mst_data->{RejectLevel} unless param 'RejectLevel'; % param 'RejectLevel' => $mst_data->{RejectLevel} unless param 'RejectLevel';
%=number_field 'RejectLevel', class => 'numb21' %=number_field 'RejectLevel', class => 'numb21'
@ -183,13 +191,17 @@
<p><span class='label'> <p><span class='label'>
%=l('mst_Score_over_which_email_will') %=l('mst_Score_for_tagging_as_spam,')
</span><span class=data> </span><span class=data>
% param 'TagLevel' => $mst_data->{TagLevel} unless param 'TagLevel'; % param 'TagLevel' => $mst_data->{TagLevel} unless param 'TagLevel';
%=number_field 'TagLevel', class => 'numb22' %=number_field 'TagLevel', class => 'numb22'
</span></p> </span></p>
<span class='data'>
%= submit_button l('mst_Save'), class => 'action subm23'
</span>
%# Probably finally by a submit. %# Probably finally by a submit.
%end %end
</div> </div>

View File

@ -1,5 +1,5 @@
%# %#
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 13:12:40 %# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-05 11:59:08
%# %#
<div id="Mailstats-TABLE" class="partial Mailstats-TABLE"> <div id="Mailstats-TABLE" class="partial Mailstats-TABLE">
<script> <script>
@ -39,12 +39,12 @@
<p><span class=label> <p><span class=label>
%=l('mst_Date_for_Stats_display') %=l('mst_Date_for_Stats_display')
</span><span class=data> </span><span class=data>
% my @StatsDate_options = [['$c->get_StatsDate()' => '$c->get_StatsDate()']]; % my @StatsDate_options = $c->get_mailstat_dates();
% param 'StatsDate' => $mst_data->{StatsDate} unless param 'StatsDate'; % param 'StatsDate' => $mst_data->{StatsDate} unless param 'StatsDate';
%= select_field 'StatsDate' => @StatsDate_options, class => 'input', id => 'StatsDate_select' %= select_field 'StatsDate' => @StatsDate_options, class => 'input', id => 'StatsDate_select'
<br></span> </p> <br></span> </p>
<object data="<%='mailstats/$c-&gt;stash(&quot;url&quot;)' %>" title="<%= $c->stash('title') %>" type="text/html" ><%= $c->stash('title') %> not found</object> <object id = 'mailstats_object' data="<%='mailstats/$c-&gt;stash(&quot;url&quot;)' %>" title="<%= $c->stash('title') %>" type="text/html" ><%= $c->stash('title') %> not found</object>
%# Probably finally by a submit. %# Probably finally by a submit.

View File

@ -1,5 +1,5 @@
/* /*
Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 13:12:40 Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-05 11:59:08
*/ */
.Mailstats-panel {} .Mailstats-panel {}
.name {} .name {}
@ -31,13 +31,15 @@ Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.
.pass13 {} .pass13 {}
.endg2 {} .endg2 {}
.subh3 {} .subh3 {}
.sele14 {} .mult14 {}
.text15 {} .text15 {}
.sele16 {} .sele16 {}
.sele17 {} .sele17 {}
.sele24 {}
.text18 {} .text18 {}
.text19 {} .text19 {}
.text20 {} .text20 {}
.subh4 {} .subh4 {}
.numb21 {} .numb21 {}
.numb22 {} .numb22 {}
.subm23 {}

View File

@ -1,5 +1,5 @@
%# %#
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 13:12:40 %# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-05 11:59:08
%# %#
% layout 'default', title => "Sme server 2 - Mailstats", share_dir => './'; % layout 'default', title => "Sme server 2 - Mailstats", share_dir => './';
%# css specific to this panel: %# css specific to this panel:

View File

@ -1,5 +1,66 @@
// //
//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 13:12:40 //Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-05 11:17:38
// //
$(document).ready(function() { $(document).ready(function() {
}); });
// Initialize multiselect with existing text values
function initMultiselect() {
const multiselect = document.getElementById('CountrySelect_select');
const textInput = document.getElementById('AccumCountryCodes_text');
// Split text input values and select corresponding options
textInput.value.split(',').forEach(value => {
const option = Array.from(multiselect.options).find(opt => opt.value === value.trim());
if (option) option.selected = true;
});
}
// Update text input when multiselect changes
function updateTextInput() {
const multiselect = document.getElementById('CountrySelect_select');
const textInput = document.getElementById('AccumCountryCodes_text');
// Get selected values as comma-separated string
const selectedValues = Array.from(multiselect.selectedOptions)
.map(option => option.value)
.join(',');
textInput.value = selectedValues;
}
// Initialize on page load
document.addEventListener('DOMContentLoaded', () => {
initMultiselect();
// Add change listener to multiselect
document.getElementById('CountrySelect_select')
.addEventListener('click', updateTextInput);
});
// Initialize select with current object content
document.addEventListener('DOMContentLoaded', () => {
const objectElement = document.getElementById('mailstats_object');
const selectElement = document.getElementById('StatsDate_select');
// Extract current date from object's data URL
const currentDate = objectElement.data.match(/mailstats_for_(\d{4}-\d{2}-\d{2})\.html/)?.[1];
if (currentDate) {
selectElement.value = currentDate;
}
});
// Update object content when selection changes
document.getElementById('StatsDate_select').addEventListener('change', function() {
const selectedDate = this.value;
const objectElement = document.getElementById('mailstats_object');
// Update object's data source
objectElement.data = `mailstats_for_${selectedDate}.html`;
// Force refresh using clone method (cross-browser workaround)
const clone = objectElement.cloneNode(true);
objectElement.replaceWith(clone);
});

View File

@ -1,35 +1,37 @@
# #
# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 13:12:40 # 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_Score_over_which_email_will' => 'Score over which email will be fully rejected', 'mst_Host_name_for_DB_server' => 'Host name for DB server',
'mst_User_Password_for_DB_sending' => 'User Password for DB sending', 'mst_Enable_RHSBL_checking' => 'Enable RHSBL checking',
'mst_Hostname_for_email_server' => 'hostage for email server', 'mst_RBL_Servers_to_use' => 'RBL Servers to use',
'mst_User_name_for_email_sending' => 'User name for email sending', 'mst_Port_number_for_email_server' => 'Port number for email server',
'mst_Email_details' => 'Email details', 'mst_User_name_for_DB_sending' => 'User name for DB sending',
'mst_Mailstats' => 'mailshots',
'mst_Email_filtering_/_exclusion' => 'Email filtering / exclusion',
'mst_CONFIG_panel_action_was_successful' => 'CONFIG panel action was successful',
'mst_Table_of_email_status' => 'Table of email status', '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_User_Password_for_email_sending' => 'User Password for email sending',
'mst_UBL_Servers_to_use' => 'UBL Servers to use', 'mst_UBL_Servers_to_use' => 'UBL Servers to use',
'mst_Hostname_for_DB_server' => 'hostage for DB server',
'mst_Accumlated_country_codes_(editable)' => 'accumulated country codes editable',
'mst_Date_for_Stats_display' => 'Date for Stats display',
'mst_Enable_DNSBL_checking' => 'Enable DNSBL checking',
'mst_Details_for_connection_to_database' => 'Details for connection to database for saving email status',
'mst_SBL_Servers_to_use' => 'SBL Servers to use',
'mst_APPLY' => 'Apply',
'mst_Port_number_for_DB_server' => 'Port number for DB server',
'mst_Select_the_countries_you_would' => 'Select the countries you would like to reject',
'mst_Descriptive_paragraph' => 'Descriptive paragraph',
'mst_Port_number_for_email_server' => 'Port number for email server',
'mst_Email_for_stats' => 'Email for stats',
'mst_Would_you_like_to_save' => 'Would you like to save data in the DB?', 'mst_Would_you_like_to_save' => 'Would you like to save data in the DB?',
'mst_Score_over_which_email_will' => 'Score over which email will be tagged as spam But queued', 'mst_Specify_if_you_would_like' => 'Specify if you would like to receive email in text or HTML form',
'mst_Spamassassin_parameters_for_rejecting_email' => 'Spamassassin parameters for rejecting email', '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_TABLE_panel_action_was_successful' => 'TABLE panel action was successful',
'mst_Enable_RHSBL_checking' => 'Enable RHSBL checking',
'mst_Specify_if_you_would_like' => 'Specify if you would like to receive email in text for HTML form',
'mst_RBL_Servers_to_use' => 'RBL Servers to use',
'mst_User_name_for_DB_sending' => 'User name for DB sending',
'mst_Configure_Mailstats' => 'Configure mailshots', 'mst_Configure_Mailstats' => 'Configure mailshots',
'mst_User_name_for_email_sending' => 'User name for email sending',

View File

@ -10,6 +10,16 @@
<br></span> </p> <br></span> </p>
]]></Select> ]]></Select>
<MultiSelect><![CDATA[
<p><span class=label>
%=l('${prefix}_${Label}')
</span><span class=data>
% my @${Name}_options = ${structure:OptionsInPerl};
% param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
%= select_field '${Name}' => @${Name}_options, class => 'input', id => '${Name}_select', multiple => 'multiple'
<br></span> </p>
]]></MultiSelect>
<Textarea><![CDATA[ <Textarea><![CDATA[
@ -17,7 +27,7 @@
%=l('${prefix}_${Label}') %=l('${prefix}_${Label}')
</span><span class=data> </span><span class=data>
% param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}'; % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
%= text_area '${Name}', cols=>${cols | 40}, rows=>${rows | 10}, Readonly=>'${Readonly | false}' %= text_area '${Name}', cols=>${cols | 40}, rows=>${rows | 10}, Readonly=>'${Readonly | false}','
</span><br> </span><br>
]]></Textarea> ]]></Textarea>
@ -43,7 +53,7 @@
%=l('${prefix}_${Label}') %=l('${prefix}_${Label}')
</span><span class=data> </span><span class=data>
% param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}'; % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
%= text_field '${Name}', size => '${size | 50}', class => 'textinput ${Name}' , pattern=>'${regexp | ".*"}' , placeholder=>'${placeholder | Name}', title =>'Pattern regex mismatch' %= text_field '${Name}', size => '${size | 50}', class => 'textinput ${Name}' , pattern=>'${regexp | ".*"}' , placeholder=>'${placeholder | Name}', title =>'Pattern regex mismatch', id => '${Name}_text'
<br></span></p> <br></span></p>
]]></Text> ]]></Text>
@ -277,7 +287,7 @@
</Endgroup> </Endgroup>
<object><![CDATA[ <object><![CDATA[
<object data="<%='${url}' %>" title="<%= $c->stash('title') %>" type="text/html" ><%= $c->stash('title') %> not found</object> <object data="<%='${url}' %>" title="<%= $c->stash('title') %>" type="text/html" ><%= $c->stash('title') %> not found</object>, id => '${Name}_object
]]> ]]>
</object> </object>

View File

@ -37,7 +37,7 @@
Input4:{ Input4:{
Name:'TextorHTML', Name:'TextorHTML',
Type:'Select', Type:'Select',
Label: 'Specify if you would like to receive email in text for HTML form', Label: 'Specify if you would like to receive email in text or HTML form',
Options: [ Options: [
{ {
'Value': 'HTML', 'Value': 'HTML',
@ -66,7 +66,7 @@
}, },
Input5:{ Input5:{
Name:'EmailHost', Name:'EmailHost',
Label:'Hostname for email server', Label:'Host name for email server',
Type:'Text', Type:'Text',
Value:'localhost' Value:'localhost'
}, },
@ -108,7 +108,7 @@
SubHeader2:'Details for connection to database for saving email status', SubHeader2:'Details for connection to database for saving email status',
Input10:{ Input10:{
Name:'DBHost', Name:'DBHost',
Label:'Hostname for DB server', Label:'Host name for DB server',
Type:'Text', Type:'Text',
Value:'localhost' Value:'localhost'
}, },
@ -135,14 +135,14 @@
Input14:{ Input14:{
Name:'CountrySelect', Name:'CountrySelect',
Label:'Select the countries you would like to reject', Label:'Select the countries you would like to reject',
Type:'Select', Type:'MultiSelect',
Options:[{'Value':'$c->get_CountryCodes()', Options:[{'Value':'$c->get_CountryCodes()',
'Text':'$c->get_CountryCodes()'}] 'Text':'$c->get_CountryCodes()'}]
}, },
Input15:{ Input15:{
Name:'AccumCountryCodes', Name:'AccumCountryCodes',
Type:'Text', Type:'Text',
Label:'Accumlated country codes (editable)', Label:'Accumulated country codes (editable)',
Value:'' Value:''
}, },
Input16:{ Input16:{
@ -151,11 +151,11 @@
Type:'Select', Type:'Select',
Options: [ Options: [
{ {
'Value': 'yes', 'Value': 'enabled',
'Text': 'yes' 'Text': 'yes'
}, },
{ {
'Value': 'no', 'Value': 'disabled',
'Text': 'no' 'Text': 'no'
} }
] ]
@ -166,45 +166,66 @@
Type:'Select', Type:'Select',
Options: [ Options: [
{ {
'Value': 'yes', 'Value': 'enabled',
'Text': 'yes' 'Text': 'yes'
}, },
{ {
'Value': 'no', 'Value': 'disabled',
'Text': 'no'
}
]
},
Input24:{
Name:'EnableURIBL',
Label:'Enable URIBL checking',
Type:'Select',
Options: [
{
'Value': 'enabled',
'Text': 'yes'
},
{
'Value': 'disabled',
'Text': 'no' 'Text': 'no'
} }
] ]
}, },
Input18:{ Input18:{
Name:'RBLLIST', Name:'RBLList',
Type:'Text', Type:'Text',
Label:'RBL Servers to use', Label:'RBL Servers to use',
Value:'' Value:''
}, },
Input19:{ Input19:{
Name:'SBLLIST', Name:'SBLList',
Type:'Text', Type:'Text',
Label:'SBL Servers to use', Label:'SBL Servers to use',
Value:'' Value:''
}, },
Input20:{ Input20:{
Name:'UBLLIST', Name:'UBLList',
Type:'Text', Type:'Text',
Label:'UBL Servers to use', Label:'UBL Servers to use',
Value:'' Value:''
}, },
SubHeader4:'Spamassassin parameters for rejecting email', SubHeader4:'Spamassassin scores - tag and reject levels',
Input21:{ Input21:{
Name:'RejectLevel', Name:'RejectLevel',
Label:'Score over which email will be fully rejected', Label:'Score to fully reject emmail',
Type:'Number', Type:'Number',
Value:'12' Value:'12'
}, },
Input22:{ Input22:{
Name:'TagLevel', Name:'TagLevel',
Label:'Score over which email will be tagged as spam, but queued', Label:'Score for tagging as spam, but queued',
Type:'Number', Type:'Number',
Value:'4' Value:'4'
},
Input23: {
Type: 'Submit',
Value: 'Save',
Name: 'Save',
Label: null
} }
} }
] ]