Compare commits
47 Commits
171bd5a141
...
main
Author | SHA1 | Date | |
---|---|---|---|
2f468205bd | |||
c3192df075 | |||
032c544c53 | |||
8c3a0529a3 | |||
a54c9f1c12 | |||
2eb8c32e30 | |||
be348b0b0d | |||
7612dac6b3 | |||
4050d94608 | |||
c700add2a6 | |||
dfa582e6cb | |||
85d274d585 | |||
3fb91ab1f4 | |||
7f02b4f109 | |||
ae2ba92597 | |||
40e83a4bee | |||
2d30d8b124 | |||
588081417b | |||
b6a31f89df | |||
4e7e8f8ed3 | |||
f785f16234 | |||
386e602958 | |||
8977d629e7 | |||
10c7def564 | |||
7b0f9edb91 | |||
8b54f7f61c | |||
6e45347ba3 | |||
93ef6c22c4 | |||
a5272319f2 | |||
9f154c586d | |||
9fe0a050cf | |||
a5205ea14c | |||
75aaf42204 | |||
8ff23b4775 | |||
2378308576 | |||
865a945233 | |||
20175cf5cf | |||
ba982816c0 | |||
e717237726 | |||
51a59b9696 | |||
c7dc45ccb5 | |||
076b604722 | |||
a3c77fe766 | |||
b0393cfe8a | |||
918f49eaf2 | |||
bae566758c | |||
ce91fbab45 |
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
@@ -1,63 +0,0 @@
|
||||
#
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:42:48
|
||||
#
|
||||
#
|
||||
# Routines to be edited by the developer to provide validation for parameters
|
||||
# and provison of the control data for table(s)
|
||||
#
|
||||
use esmith::util;
|
||||
use esmith::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
|
||||
#The most common ones
|
||||
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
# Validation routines - parameters for each panel
|
||||
|
||||
sub validate_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = 'ok';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
# Get control data for tables(s)
|
||||
|
||||
|
||||
# Return hash with values from row in which link clicked on table
|
||||
|
||||
sub get_selected_PARAMS {
|
||||
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_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = 'ok';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
sub create_link{
|
||||
# WIP
|
||||
my ($c,$route, $panel, $index) = shift;
|
||||
my $link = "$route?trt=$panel&Selected=$index";
|
||||
return $link;
|
||||
}
|
||||
1;
|
@@ -1,63 +0,0 @@
|
||||
#
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-18 09:02:36
|
||||
#
|
||||
#
|
||||
# Routines to be edited by the developer to provide validation for parameters
|
||||
# and provison of the control data for table(s)
|
||||
# lcPackageName=json5_dict["PackageName"].lower(),
|
||||
|
||||
use esmith::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
|
||||
#The most common ones
|
||||
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
# Validation routines - parameters for each panel
|
||||
|
||||
sub validate_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = 'ok';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
# Get control data for tables(s)
|
||||
|
||||
|
||||
# Return hash with values from row in which link clicked on table
|
||||
|
||||
sub get_selected_PARAMS {
|
||||
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_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = 'ok';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
sub create_link{
|
||||
# WIP
|
||||
my ($c,$route, $panel, $index) = shift;
|
||||
my $link = "$route?trt=$panel&Selected=$index";
|
||||
return $link;
|
||||
}
|
||||
1;
|
@@ -1,243 +0,0 @@
|
||||
package SrvMngr::Controller::CreateStarterWebsite;
|
||||
#
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:42:48
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Miscellaneous
|
||||
# description : Create Starter Website
|
||||
# navigation : 2000 400
|
||||
#
|
||||
# name : createstarterwebsite, method : get, url : /createstarterwebsite, ctlact : CreateStarterWebsite#main
|
||||
# name : createstarterwebsiteu, method : post, url : /createstarterwebsiteu, ctlact : CreateStarterWebsite#do_update
|
||||
# name : createstarterwebsited, method : get, url : /createstarterwebsited, ctlact : CreateStarterWebsite#do_display
|
||||
#
|
||||
# routes : end
|
||||
#
|
||||
# Documentation: https://wiki.contribs.org/CreateStarterWebsite
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# 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::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
|
||||
#The most common ones
|
||||
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
require '/usr/share/smanager/lib/SrvMngr/Controller/CreateStarterWebsite-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 );
|
||||
|
||||
my %csw_data = ();
|
||||
my $title = $c->l('csw_Create_Starter_Website');
|
||||
my $modul = '';
|
||||
|
||||
$csw_data{'trt'} = 'PARAMS';
|
||||
|
||||
#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
|
||||
|
||||
|
||||
# and table control fields
|
||||
|
||||
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
csw_data => \%csw_data
|
||||
);
|
||||
$c->render( template => "createstarterwebsite" );
|
||||
}
|
||||
|
||||
# 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 %csw_data = ();
|
||||
my $title = $c->l('csw_Create_Starter_Website');
|
||||
|
||||
# Accessing all POST parameters
|
||||
my %params = $c->req->params->to_hash;
|
||||
|
||||
# Get number of POST parameters
|
||||
my $num_params = keys %params;
|
||||
|
||||
#Params are available in the hash "params" - copy to the prefix_data hash
|
||||
while (my ($key, $value) = each %{$c->req->params->to_hash}) {
|
||||
$csw_data{$key} = $value;
|
||||
}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'PARAMS'; #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 'PARAMS'){
|
||||
#Validate form parameters for panel PARAMS
|
||||
$ret = $c->validate_PARAMS(\%csw_data);
|
||||
$thispanel = 'PARAMS';
|
||||
}
|
||||
|
||||
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->render("createstarterwebsite");
|
||||
} else {
|
||||
#Do whatever is needed, including writing values to the DB
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_PARAMS(\%csw_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->render("createstarterwebsite");
|
||||
} else {
|
||||
$c->stash( success => $c->l('csw_PARAMS_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
# and call any signal-events needed
|
||||
|
||||
|
||||
# Setup shared data and call panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
csw_data => \%csw_data
|
||||
);
|
||||
if ('none' eq 'none') {
|
||||
$csw_data{'trt'} = 'PARAMS';
|
||||
} else {
|
||||
$csw_data{'trt'} = 'none';
|
||||
}
|
||||
$c->render("createstarterwebsite");
|
||||
}
|
||||
}
|
||||
|
||||
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 = shift;
|
||||
$c->app->log->info($c->log_req);
|
||||
|
||||
my %csw_data = ();
|
||||
my $title = $c->l('csw_Create_Starter_Website');
|
||||
|
||||
# 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}) {
|
||||
$csw_data{$key} = $value;
|
||||
}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'PARAMS'; #Indicates where to go now
|
||||
|
||||
# Now add in the params from the selected row from the table
|
||||
|
||||
my %selectedrow;
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#Validate form parameters for panel PARAMS
|
||||
%selectedrow = $c->get_selected_PARAMS($csw_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){
|
||||
$csw_data{$key} = $value;
|
||||
}
|
||||
# Where to go now
|
||||
$csw_data{'trt'} = $trt;
|
||||
|
||||
# Data for panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
csw_data => \%csw_data
|
||||
);
|
||||
$c->render("createstarterwebsite");
|
||||
}
|
||||
1;
|
@@ -1,101 +0,0 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:42:48
|
||||
%#
|
||||
<div id="CreateStarterWebsite-PARAMS" class="partial CreateStarterWebsite-PARAMS">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
<h2>
|
||||
%= l('csw_Hello_PARAMS');
|
||||
</h2>
|
||||
% my $btn = l('csw_APPLY');
|
||||
%= form_for "CreateStarterWebsited" => (method => 'POST') => begin
|
||||
|
||||
% param 'trt' => $csw_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $csw_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h1 class='head'><%=l('csw_Create_a_starter_website')%></h1>
|
||||
|
||||
<h2 class='subh'><%=l('csw_Manage_CreateStarterWebsite_settings:')%></h2>
|
||||
|
||||
<p class='paragraph para1'>
|
||||
%=l('csw_To_create_a_simple_web')
|
||||
</p>
|
||||
|
||||
<p class='paragraph para2'>
|
||||
%=l('csw_You_can_leave_any_field')
|
||||
</p>
|
||||
|
||||
<p class='paragraph para3'>
|
||||
%=l('csw_The_text_that_you_enter')
|
||||
</p>
|
||||
|
||||
<p class='paragraph para4'>
|
||||
%=l('csw_Do_not_use_this_optionif')
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('csw_')
|
||||
</span><span class=data>
|
||||
% param 'companyName' => $csw_data->{companyName} unless param 'companyName';
|
||||
%= text_field 'companyName', size => '50', class => 'textinput companyName' , pattern=>'.*' , placeholder=>'companyName'
|
||||
<br></span></p>
|
||||
|
||||
<p class='paragraph para5'>
|
||||
%=l('csw_First_header,_typically_used_for')
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('csw_')
|
||||
</span><span class=data>
|
||||
% param 'header1' => $csw_data->{header1} unless param 'header1';
|
||||
%= text_field 'header1', size => '50', class => 'textinput header1' , pattern=>'.*' , placeholder=>'header1'
|
||||
<br></span></p>
|
||||
|
||||
<p class='paragraph para6'>
|
||||
%=l('csw_Text_following_first_header,_typically')
|
||||
</p>
|
||||
|
||||
<span class=label>
|
||||
%=l('csw_')
|
||||
</span><span class=data>
|
||||
% param 'text1' => $csw_data->{text1} unless param 'text1';
|
||||
%= text_area 'text1', cols=>40, rows=>10
|
||||
</span><br>
|
||||
|
||||
<p class='paragraph para7'>
|
||||
%=l('csw_Second_header,_typically_used_for')
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('csw_')
|
||||
</span><span class=data>
|
||||
% param 'header2' => $csw_data->{header2} unless param 'header2';
|
||||
%= text_field 'header2', size => '50', class => 'textinput header2' , pattern=>'.*' , placeholder=>'header2'
|
||||
<br></span></p>
|
||||
|
||||
<p class='paragraph para8'>
|
||||
%=l('csw_Text_following_second_header,_typically')
|
||||
</p>
|
||||
|
||||
<span class=label>
|
||||
%=l('csw_')
|
||||
</span><span class=data>
|
||||
% param 'text2' => $csw_data->{text2} unless param 'text2';
|
||||
%= text_area 'text2', cols=>40, rows=>10
|
||||
</span><br>
|
||||
|
||||
<p class='paragraph para9'>
|
||||
%=l('csw_When_you_create_this_web')
|
||||
</p>
|
||||
|
||||
<p class='paragraph para10'>
|
||||
%=l('csw_Do_you_wish_to_proceed?')
|
||||
</p>
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:42:48
|
||||
*/
|
||||
.CreateStarterWebsite-panel {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.head {}
|
||||
.subh {}
|
||||
.para1 {}
|
||||
.para2 {}
|
||||
.para3 {}
|
||||
.para4 {}
|
||||
.text1 {}
|
||||
.para5 {}
|
||||
.text2 {}
|
||||
.para6 {}
|
||||
.text3 {}
|
||||
.para7 {}
|
||||
.text4 {}
|
||||
.para8 {}
|
||||
.text5 {}
|
||||
.para9 {}
|
||||
.para10 {}
|
||||
.subm6 {}
|
@@ -1,52 +0,0 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:42:48
|
||||
%#
|
||||
% layout 'default', title => "Sme server 2 - Create Starter Website", share_dir => './';
|
||||
%# css specific to this panel:
|
||||
% content_for 'module' => begin
|
||||
%= stylesheet '/css/createstarterwebsite.css'
|
||||
<div id="module" class="module CreateStarterWebsite-panel">
|
||||
|
||||
% if ($config->{debug} == 1) {
|
||||
<p>
|
||||
%= dumper $c->current_route
|
||||
</p>
|
||||
% }
|
||||
|
||||
<h1><%=$title%></h1>
|
||||
|
||||
% if ( stash('modul') ) {
|
||||
%= $c->render_to_string(inline => stash('modul') );
|
||||
% }
|
||||
|
||||
%if ($csw_data->{first}) {
|
||||
<br><p>
|
||||
%=$c->render_to_string(inline =>$c->l($csw_data->{first}))
|
||||
</p>
|
||||
|
||||
%} elsif ($csw_data->{success}) {
|
||||
<div class='sme-border'>
|
||||
<h2> Operation Status Report</h2><p>
|
||||
%= $c->l($csw_data->{success});
|
||||
</p>
|
||||
</div>
|
||||
|
||||
%} elsif ($csw_data->{error}) {
|
||||
<div class='sme-error'>
|
||||
<h2> Operation Status Report - error</h2><p>
|
||||
%= $c->l($csw_data->{error});
|
||||
</p>
|
||||
</div>
|
||||
%}
|
||||
|
||||
%#Routing to partials according to trt parameter.
|
||||
%#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement'
|
||||
|
||||
% if ($csw_data->{trt} eq "PARAMS") {
|
||||
%= include 'partials/_csw_PARAMS'
|
||||
%}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
%end
|
@@ -1,20 +0,0 @@
|
||||
#
|
||||
# Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:42:48
|
||||
#
|
||||
'csw_You_can_leave_any_field' => 'You can leave any field blank if you do not need it. ',
|
||||
'csw_Do_you_wish_to_proceed?' => 'Do you wish to proceed?',
|
||||
'csw_Text_following_second_header,_typically' => 'Text following second header, Typically used for contact or ordering information:',
|
||||
'csw_Create_Starter_Website' => 'Create Starter Website',
|
||||
'csw_Hello_PARAMS' => 'Hello PARAMS',
|
||||
'csw_The_text_that_you_enter' => 'The text that you enter below will be line wrapped for a nicer appearance in your web page. Leave a blank line whenever you want to start a new paragraph. If you need to force a line break without starting a new paragraph (for example after each line of a mailing address), Then type the four-character sequence',
|
||||
'csw_Text_following_first_header,_typically' => 'Text following first header, Typically used for a paragraph of marketing information. ',
|
||||
'csw_Second_header,_typically_used_for' => 'Second header, Typically used for short phrases such as For more information or To order our products:',
|
||||
'csw_When_you_create_this_web' => 'When you create this web page, The file index. Htm will be overwritten in your web site directory. ',
|
||||
'csw_Manage_CreateStarterWebsite_settings:' => 'Manage CreateStarterWebsite settings:',
|
||||
'csw_Do_not_use_this_optionif' => 'Do not use this optionif you have already customized your web site, Since it will overwrite the index. Htm file in your web site directory. ',
|
||||
'csw_Create_a_starter_website' => 'Create a starter website',
|
||||
'csw_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
||||
'csw_To_create_a_simple_web' => 'To create a simple web page for your company, Fill in the fields below and click onCreate. ',
|
||||
'csw_First_header,_typically_used_for' => 'First header, Typically used for short phrases such as Leader in the field of textile manufacturing',
|
||||
'csw_APPLY' => 'Apply',
|
||||
'csw_' => '',
|
140
Targets/Datetime/Datetime-Custom.pm
Normal file
140
Targets/Datetime/Datetime-Custom.pm
Normal file
@@ -0,0 +1,140 @@
|
||||
#
|
||||
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47
|
||||
#
|
||||
#
|
||||
# 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::UTF8;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB::UTF8;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB::UTF8:
|
||||
|
||||
use constant FALSE => 0;
|
||||
use constant TRUE => 1;
|
||||
|
||||
|
||||
#The most common ones - open DB when required.
|
||||
my $cdb;
|
||||
my $adb;
|
||||
my $ndb;
|
||||
my $hdb;
|
||||
my $ddb;
|
||||
|
||||
#The most common ones - you might want to use these if you need to make sure that the DB is refreshed.
|
||||
#$cdb = esmith::ConfigDB::UTF8->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::UTF8->open() || die("Couldn't open Hosts db");
|
||||
#$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
|
||||
|
||||
|
||||
# Validation routines - parameters for each panel
|
||||
|
||||
sub validate_PARAMS {
|
||||
my $c = shift;
|
||||
my $dat_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = '';
|
||||
|
||||
if (! TRUE) #validate $c->param('time_mode')
|
||||
{$ret .= 'Validation for time_mode failed';}
|
||||
if (! TRUE) #validate $c->param('ntpserver')
|
||||
{$ret .= 'Validation for ntpserver failed';}
|
||||
if (! TRUE) #validate $c->param('year')
|
||||
{$ret .= 'Validation for year failed';}
|
||||
if (! TRUE) #validate $c->param('month')
|
||||
{$ret .= 'Validation for month failed';}
|
||||
if (! TRUE) #validate $c->param('day')
|
||||
{$ret .= 'Validation for day failed';}
|
||||
if (! TRUE) #validate $c->param('hour')
|
||||
{$ret .= 'Validation for hour failed';}
|
||||
if (! TRUE) #validate $c->param('minute')
|
||||
{$ret .= 'Validation for minute failed';}
|
||||
if (! TRUE) #validate $c->param('second')
|
||||
{$ret .= 'Validation for second failed';}
|
||||
if ($ret eq '') {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
# Get singleton data for each panel
|
||||
|
||||
sub get_data_for_panel_PARAMS {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1'=>'Data for PARAMS', #Example
|
||||
# fields from Inputs in PARAMS $fields['PARAMS']
|
||||
'time_mode'=>'time_mode contents',
|
||||
'ntpserver'=>'ntpserver contents',
|
||||
'year'=>'year contents',
|
||||
'month'=>'month contents',
|
||||
'day'=>'day contents',
|
||||
'hour'=>'hour contents',
|
||||
'minute'=>'minute contents',
|
||||
'second'=>'second contents',
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Get control data for table(s)
|
||||
|
||||
|
||||
|
||||
# Return hash with values from row in which link clicked on table
|
||||
|
||||
sub get_selected_PARAMS {
|
||||
my $c = shift;
|
||||
my $selected = shift; #Parameter is name of selected row.
|
||||
my $is_new_record = shift; #Indicates new record required (defaults)
|
||||
my %ret = ();
|
||||
#gather the values here
|
||||
return %ret;
|
||||
}
|
||||
|
||||
|
||||
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
|
||||
|
||||
sub perform_PARAMS {
|
||||
my $c = shift;
|
||||
my $dat_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: time_mode e.g. $db->set_prop($dbkey,'time_mode',$c->param('time_mode'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for time_mode';}
|
||||
if (! TRUE) #copy or perform with value: ntpserver e.g. $db->set_prop($dbkey,'ntpserver',$c->param('ntpserver'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for ntpserver';}
|
||||
if (! TRUE) #copy or perform with value: year e.g. $db->set_prop($dbkey,'year',$c->param('year'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for year';}
|
||||
if (! TRUE) #copy or perform with value: month e.g. $db->set_prop($dbkey,'month',$c->param('month'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for month';}
|
||||
if (! TRUE) #copy or perform with value: day e.g. $db->set_prop($dbkey,'day',$c->param('day'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for day';}
|
||||
if (! TRUE) #copy or perform with value: hour e.g. $db->set_prop($dbkey,'hour',$c->param('hour'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for hour';}
|
||||
if (! TRUE) #copy or perform with value: minute e.g. $db->set_prop($dbkey,'minute',$c->param('minute'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for minute';}
|
||||
if (! TRUE) #copy or perform with value: second e.g. $db->set_prop($dbkey,'second',$c->param('second'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for second';}
|
||||
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;
|
||||
}
|
||||
1;
|
279
Targets/Datetime/Datetime.pm
Normal file
279
Targets/Datetime/Datetime.pm
Normal file
@@ -0,0 +1,279 @@
|
||||
package SrvMngr::Controller::Datetime;
|
||||
#
|
||||
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47
|
||||
# Remember that each route must be unique (else they just overwrite each other).
|
||||
# you cannot have get and post on the same name and url.
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# heading : System
|
||||
# description : Date and time
|
||||
# navigation : 4000 300
|
||||
#
|
||||
# name : datetime, method : get, url : /datetime, ctlact : Datetime#main
|
||||
# name : datetimeu, method : post, url : /datetimeu, ctlact : Datetime#do_update
|
||||
# name : datetimed, method : get, url : /datetimed, ctlact : Datetime#do_display
|
||||
#
|
||||
# routes : end
|
||||
#
|
||||
# Documentation: https://wiki.contribs.org/Datetime
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# 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::UTF8;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB::UTF8;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB::UTF8:
|
||||
|
||||
my $cdb;
|
||||
my $adb;
|
||||
my $ndb;
|
||||
my $hdb;
|
||||
my $ddb;
|
||||
|
||||
my %dat_data;
|
||||
|
||||
require '/usr/share/smanager/lib/SrvMngr/Controller/Datetime-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 - you might want to delete some of these if they are not used.
|
||||
$cdb = esmith::ConfigDB::UTF8->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::UTF8->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
|
||||
|
||||
%dat_data = ();
|
||||
my $title = $c->l('dat_Date_and_time');
|
||||
my $modul = '';
|
||||
|
||||
$dat_data{'trt'} = 'PARAMS';
|
||||
|
||||
#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($dat_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 delete some of these if they are not used.
|
||||
$cdb = esmith::ConfigDB::UTF8->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::UTF8->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
|
||||
|
||||
my $title = $c->l('dat_Date_and_time');
|
||||
|
||||
# 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}) {
|
||||
# $dat_data{$key} = $value;
|
||||
#}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'PARAMS'; #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 'PARAMS'){
|
||||
#Validate form parameters for panel PARAMS
|
||||
$ret = $c->validate_PARAMS(\%dat_data);
|
||||
$thispanel = 'PARAMS';
|
||||
}
|
||||
|
||||
if ($ret ne 'ok'){
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->do_display($thispanel);
|
||||
} else {
|
||||
#Do whatever is needed, including writing values to the DB
|
||||
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_PARAMS(\%dat_data);
|
||||
if ($ret ne 'ok') {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
dat_data => \%dat_data
|
||||
);
|
||||
$c->render(template => "datetime");
|
||||
} else {
|
||||
$c->stash( success => $c->l('dat_PARAMS_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') {
|
||||
$dat_data{'trt'} = 'PARAMS';
|
||||
} else {
|
||||
$dat_data{'trt'} = 'none';
|
||||
}
|
||||
$c->do_display($dat_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 delete some of these if they are not used.
|
||||
$cdb = esmith::ConfigDB::UTF8->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::UTF8->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
|
||||
|
||||
my $title = $c->l('dat_Date_and_time');
|
||||
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}) {
|
||||
# $dat_data{$key} = $value;
|
||||
#}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
if (! $trt){
|
||||
$trt = $c->param('trt') || 'PARAMS'; #Indicates where to go now
|
||||
}
|
||||
|
||||
# Now add in the params from the selected row from the table
|
||||
|
||||
my %selectedrow;
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#Validate Get selected row (if applicable) PARAMS
|
||||
%selectedrow = $c->get_selected_PARAMS($dat_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){
|
||||
$dat_data{$key} = $value;
|
||||
}
|
||||
# Where to go now
|
||||
$dat_data{'trt'} = $trt;
|
||||
|
||||
# Set up other shared data according to the panel to go to
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
# 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_PARAMS();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$dat_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# and table control fields
|
||||
|
||||
|
||||
# Data for panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
dat_data => \%dat_data
|
||||
);
|
||||
$c->render(template => "datetime");
|
||||
}
|
||||
1;
|
102
Targets/Datetime/_dat_PARAMS.html.ep
Normal file
102
Targets/Datetime/_dat_PARAMS.html.ep
Normal file
@@ -0,0 +1,102 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47
|
||||
%#
|
||||
<div id="Datetime-PARAMS" class="partial Datetime-PARAMS">
|
||||
%# <script>
|
||||
%# window.onload = function() {
|
||||
%# SelectInput();
|
||||
%# };
|
||||
%# </script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $dat_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('dat_APPLY');
|
||||
|
||||
% $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table
|
||||
|
||||
%= form_for "datetimeu" => (method => 'POST') => begin
|
||||
% param 'trt' => $dat_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $dat_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h1 class='head'><%=l('Date_and_time_configuration')%></h1>
|
||||
|
||||
<h2 class='subh'><%=l('dat_Time_Configuration')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('dat_Time_Setting_Mode:')
|
||||
</span><span class=data>
|
||||
% my @time_mode_options = [['NTP server' => 'dat_ntp_server'], ['Set manually' => 'dat_manually_set']];
|
||||
% param 'time_mode' => $dat_data->{time_mode} unless param 'time_mode';
|
||||
%= select_field 'time_mode' => @time_mode_options, class => 'input', id => 'time_mode_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p class='paragraph para1'>
|
||||
%=l('dat_The_server_is_periodically_synchronizing')
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('dat_Set_Date_and_Time:')
|
||||
</span><span class=data>
|
||||
% param 'ntpserver' => $dat_data->{ntpserver} unless param 'ntpserver';
|
||||
%= text_field 'ntpserver', size => '50', class => 'textinput ntpserver' , pattern=>'.*' , placeholder=>'ntpserver', title =>'Pattern regex mismatch', id => 'ntpserver_text'
|
||||
<br></span></p>
|
||||
|
||||
<p class='paragraph para2'>
|
||||
%=l('dat_Choose_this_option_to_stop')
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('dat_Year:')
|
||||
</span><span class=data>
|
||||
% my @year_options = [['2025' => '2025'], ['2026' => '2026'], ['2027' => '2027'], ['2028' => '2028'], ['2029' => '2029'], ['2030' => '2030'], ['2031' => '2031'], ['2032' => '2032'], ['2033' => '2033'], ['2034' => '2034'], ['2035' => '2035'], ['2036' => '2036'], ['2037' => '2037'], ['2038' => '2038'], ['2039' => '2039'], ['2040' => '2040'], ['2041' => '2041'], ['2042' => '2042'], ['2043' => '2043'], ['2044' => '2044'], ['2045' => '2045'], ['2046' => '2046'], ['2047' => '2047'], ['2048' => '2048'], ['2049' => '2049'], ['2050' => '2050'], ['2051' => '2051'], ['2052' => '2052'], ['2053' => '2053'], ['2054' => '2054'], ['2055' => '2055']];
|
||||
% param 'year' => $dat_data->{year} unless param 'year';
|
||||
%= select_field 'year' => @year_options, class => 'input', id => 'year_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('dat_Month:')
|
||||
</span><span class=data>
|
||||
% my @month_options = [['01' => '01'], ['02' => '02'], ['03' => '03'], ['04' => '04'], ['05' => '05'], ['06' => '06'], ['07' => '07'], ['08' => '08'], ['09' => '09'], ['10' => '10'], ['11' => '11'], ['12' => '12']];
|
||||
% param 'month' => $dat_data->{month} unless param 'month';
|
||||
%= select_field 'month' => @month_options, class => 'input', id => 'month_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('dat_Hour:')
|
||||
</span><span class=data>
|
||||
% param 'day' => $dat_data->{day} unless param 'day';
|
||||
%= text_field 'day', size => '50', class => 'textinput day' , pattern=>'.*' , placeholder=>'day', title =>'Pattern regex mismatch', id => 'day_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('dat_Hour:')
|
||||
</span><span class=data>
|
||||
% my @hour_options = [['00' => '00'], ['01' => '01'], ['02' => '02'], ['03' => '03'], ['04' => '04'], ['05' => '05'], ['06' => '06'], ['07' => '07'], ['08' => '08'], ['09' => '09'], ['10' => '10'], ['11' => '11'], ['12' => '12'], ['13' => '13'], ['14' => '14'], ['15' => '15'], ['16' => '16'], ['17' => '17'], ['18' => '18'], ['19' => '19'], ['20' => '20'], ['21' => '21'], ['22' => '22'], ['23' => '23']];
|
||||
% param 'hour' => $dat_data->{hour} unless param 'hour';
|
||||
%= select_field 'hour' => @hour_options, class => 'input', id => 'hour_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('dat_Second:')
|
||||
</span><span class=data>
|
||||
% param 'minute' => $dat_data->{minute} unless param 'minute';
|
||||
%= text_field 'minute', size => '50', class => 'textinput minute' , pattern=>'.*' , placeholder=>'minute', title =>'Pattern regex mismatch', id => 'minute_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('dat_second')
|
||||
</span><span class=data>
|
||||
% param 'second' => $dat_data->{second} unless param 'second';
|
||||
%= text_field 'second', size => '50', class => 'textinput second' , pattern=>'.*' , placeholder=>'second', title =>'Pattern regex mismatch', id => 'second_text'
|
||||
<br></span></p>
|
||||
|
||||
<span class='data'>
|
||||
%= submit_button l('dat_Save'), class => 'action subm9'
|
||||
</span>
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
19
Targets/Datetime/datetime.css
Normal file
19
Targets/Datetime/datetime.css
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47
|
||||
*/
|
||||
.Datetime-panel {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.head {}
|
||||
.subh {}
|
||||
.sele1 {}
|
||||
.para1 {}
|
||||
.text2 {}
|
||||
.para2 {}
|
||||
.sele3 {}
|
||||
.sele4 {}
|
||||
.text5 {}
|
||||
.sele6 {}
|
||||
.text7 {}
|
||||
.text8 {}
|
||||
.subm9 {}
|
56
Targets/Datetime/datetime.html.ep
Normal file
56
Targets/Datetime/datetime.html.ep
Normal file
@@ -0,0 +1,56 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47
|
||||
%#
|
||||
% layout 'default', title => "Sme server 2 - Date and time", share_dir => './';
|
||||
%# css specific to this panel:
|
||||
% content_for 'module' => begin
|
||||
%= stylesheet '/css/datetime.css'
|
||||
%= javascript '/js/datetime.js'
|
||||
<div id="module" class="module Datetime-panel">
|
||||
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $c->current_route
|
||||
%= dumper $dat_data->{trt}
|
||||
</pre>
|
||||
% }
|
||||
|
||||
<h1><%=$title%></h1>
|
||||
|
||||
% if ( stash('modul')) {
|
||||
%= $c->render_to_string(inline => stash('modul') );
|
||||
% }
|
||||
|
||||
%if ($c->stash('first')) {
|
||||
<br><p>
|
||||
%=$c->render_to_string(inline =>$c->l($c->stash('first')))
|
||||
</p>
|
||||
|
||||
%} elsif ($c->stash('success')) {
|
||||
<div class='success '>
|
||||
<p>
|
||||
%= $c->l($c->stash('success'));
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
%} elsif ($c->stash('error')) {
|
||||
<div class='sme-error'>
|
||||
<p>
|
||||
%= $c->l($c->stash('error'));
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
%}
|
||||
|
||||
%#Routing to partials according to trt parameter.
|
||||
%#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement'
|
||||
|
||||
% if ($dat_data->{trt} eq "PARAMS") {
|
||||
%= include 'partials/_dat_PARAMS'
|
||||
%}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
%end
|
5
Targets/Datetime/datetime.js
Normal file
5
Targets/Datetime/datetime.js
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47
|
||||
//
|
||||
$(document).ready(function() {
|
||||
});
|
18
Targets/Datetime/datetime_en.lex
Normal file
18
Targets/Datetime/datetime_en.lex
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47
|
||||
#
|
||||
'dat_second' => 'Second',
|
||||
'dat_Year:' => 'years',
|
||||
'dat_Hour:' => 'hours',
|
||||
'dat_Date_and_time' => 'Date and time',
|
||||
'dat_Choose_this_option_to_stop' => 'Choose this option to stop synchronizing the system clock to the NTP server When the NTP service is disabled You can set the system date and time manually from this page',
|
||||
'dat_Month:' => 'months',
|
||||
'dat_Set_Date_and_Time:' => 'Set Date and time',
|
||||
'dat_Save' => 'Save',
|
||||
'dat_Second:' => 'second',
|
||||
'dat_Time_Setting_Mode:' => 'Time Setting model',
|
||||
'dat_Time_Configuration' => 'Time Configuration',
|
||||
'dat_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
||||
'dat_The_server_is_periodically_synchronizing' => 'The server is periodically synchronizing the system clock to the network time protocol (NTP) server specified below To synchronize to a different NTP server Enter a different hostage or IP address in the field below',
|
||||
'Date_and_time_configuration' => 'And time configuration',
|
||||
'dat_APPLY' => 'Apply',
|
@@ -1,87 +0,0 @@
|
||||
#
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:30:26
|
||||
#
|
||||
#
|
||||
# Routines to be edited by the developer to provide validation for parameters
|
||||
# and provison of the control data for table(s)
|
||||
#
|
||||
use esmith::util;
|
||||
use esmith::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
|
||||
#The most common ones
|
||||
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
# Validation routines - parameters for each panel
|
||||
|
||||
sub validate_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = 'ok';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
# Get control data for tables(s)
|
||||
|
||||
sub get_Table1 {
|
||||
# Return an array of hashes of the contents for each row and column for Table1
|
||||
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||
my $c = shift;
|
||||
my $control_data = $self->stash('Table1');
|
||||
my @ret = {}
|
||||
# foreach my $colHead (@$control_data) {
|
||||
# my ret{$colHead} = "$colhead-1"
|
||||
# };
|
||||
return \@ret
|
||||
}
|
||||
|
||||
sub get_Table2 {
|
||||
# Return an array of hashes of the contents for each row and column for Table2
|
||||
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||
my $c = shift;
|
||||
my $control_data = $self->stash('Table2');
|
||||
my @ret = {}
|
||||
# foreach my $colHead (@$control_data) {
|
||||
# my ret{$colHead} = "$colhead-1"
|
||||
# };
|
||||
return \@ret
|
||||
}
|
||||
|
||||
|
||||
# Return hash with values from row in which link clicked on table
|
||||
|
||||
sub get_selected_PARAMS {
|
||||
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_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = 'ok';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
sub create_link{
|
||||
# WIP
|
||||
my ($c,$route, $panel, $index) = shift;
|
||||
my $link = "$route?trt=$panel&Selected=$index";
|
||||
return $link;
|
||||
}
|
||||
1;
|
@@ -1,87 +0,0 @@
|
||||
#
|
||||
# Routines to be edited by the developer to provide validation for parameters
|
||||
# and provison of the control data for table(s)
|
||||
#
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-16 11:18
|
||||
#
|
||||
|
||||
use esmith::util;
|
||||
use esmith::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
|
||||
#The most common ones
|
||||
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
# Validation routines - parameters for each panel
|
||||
|
||||
sub validate_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = 'ok';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
# Get control data for tables(s)
|
||||
|
||||
sub get_Table1 {
|
||||
# Return an array of hashes of the contents for each row and column for Table1
|
||||
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||
my $c = shift;
|
||||
my $control_data = $self->stash('Table1');
|
||||
my @ret = {}
|
||||
# foreach my $colHead (@$control_data) {
|
||||
# my ret{$colHead} = "$colhead-1"
|
||||
# };
|
||||
return \@ret
|
||||
}
|
||||
|
||||
sub get_Table2 {
|
||||
# Return an array of hashes of the contents for each row and column for Table2
|
||||
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||
my $c = shift;
|
||||
my $control_data = $self->stash('Table2');
|
||||
my @ret = {}
|
||||
# foreach my $colHead (@$control_data) {
|
||||
# my ret{$colHead} = "$colhead-1"
|
||||
# };
|
||||
return \@ret
|
||||
}
|
||||
|
||||
|
||||
# Return hash with values from row in which link clicked on table
|
||||
|
||||
sub get_selected_PARAMS {
|
||||
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_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = 'ok';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
sub create_link{
|
||||
# WIP
|
||||
my ($c,$route, $panel, $index) = shift;
|
||||
my $link = "$route?trt=$panel&Selected=$index";
|
||||
return $link;
|
||||
}
|
||||
1;
|
@@ -1,245 +0,0 @@
|
||||
package SrvMngr::Controller::DiskUsage;
|
||||
#
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:30:26
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Miscellaneous
|
||||
# description : Disk Usage
|
||||
# navigation : 2000 400
|
||||
#
|
||||
# name : diskusage, method : get, url : /diskusage, ctlact : DiskUsage#main
|
||||
# name : diskusageu, method : post, url : /diskusageu, ctlact : DiskUsage#do_update
|
||||
# name : diskusaged, method : get, url : /diskusaged, ctlact : DiskUsage#do_display
|
||||
#
|
||||
# routes : end
|
||||
#
|
||||
# Documentation: https://wiki.contribs.org/DiskUsage
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# 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::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
|
||||
#The most common ones
|
||||
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
require '/usr/share/smanager/lib/SrvMngr/Controller/DiskUsage-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 );
|
||||
|
||||
my %du_data = ();
|
||||
my $title = $c->l('du_Disk_Usage');
|
||||
my $modul = '';
|
||||
|
||||
$du_data{'trt'} = 'PARAMS';
|
||||
|
||||
#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
|
||||
|
||||
|
||||
# and table control fields
|
||||
$c->stash(Table1=>$c->get_Table1());
|
||||
$c->stash(Table2=>$c->get_Table2());
|
||||
|
||||
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
du_data => \%du_data
|
||||
);
|
||||
$c->render( template => "diskusage" );
|
||||
}
|
||||
|
||||
# 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 %du_data = ();
|
||||
my $title = $c->l('du_Disk_Usage');
|
||||
|
||||
# Accessing all POST parameters
|
||||
my %params = $c->req->params->to_hash;
|
||||
|
||||
# Get number of POST parameters
|
||||
my $num_params = keys %params;
|
||||
|
||||
#Params are available in the hash "params" - copy to the prefix_data hash
|
||||
while (my ($key, $value) = each %{$c->req->params->to_hash}) {
|
||||
$du_data{$key} = $value;
|
||||
}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'PARAMS'; #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 'PARAMS'){
|
||||
#Validate form parameters for panel PARAMS
|
||||
$ret = $c->validate_PARAMS(\%du_data);
|
||||
$thispanel = 'PARAMS';
|
||||
}
|
||||
|
||||
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->render("diskusage");
|
||||
} else {
|
||||
#Do whatever is needed, including writing values to the DB
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_PARAMS(\%du_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->render("diskusage");
|
||||
} else {
|
||||
$c->stash( success => $c->l('du_PARAMS_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
# and call any signal-events needed
|
||||
|
||||
|
||||
# Setup shared data and call panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
du_data => \%du_data
|
||||
);
|
||||
if ('none' eq 'none') {
|
||||
$du_data{'trt'} = 'PARAMS';
|
||||
} else {
|
||||
$du_data{'trt'} = 'none';
|
||||
}
|
||||
$c->render("diskusage");
|
||||
}
|
||||
}
|
||||
|
||||
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 = shift;
|
||||
$c->app->log->info($c->log_req);
|
||||
|
||||
my %du_data = ();
|
||||
my $title = $c->l('du_Disk_Usage');
|
||||
|
||||
# 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}) {
|
||||
$du_data{$key} = $value;
|
||||
}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'PARAMS'; #Indicates where to go now
|
||||
|
||||
# Now add in the params from the selected row from the table
|
||||
|
||||
my %selectedrow;
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#Validate form parameters for panel PARAMS
|
||||
%selectedrow = $c->get_selected_PARAMS($du_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){
|
||||
$du_data{$key} = $value;
|
||||
}
|
||||
# Where to go now
|
||||
$du_data{'trt'} = $trt;
|
||||
|
||||
# Data for panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
du_data => \%du_data
|
||||
);
|
||||
$c->render("diskusage");
|
||||
}
|
||||
1;
|
@@ -1,83 +0,0 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:30:26
|
||||
%#
|
||||
<div id="DiskUsage-PARAMS" class="partial DiskUsage-PARAMS">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
<h2>
|
||||
%= l('du_Hello_PARAMS');
|
||||
</h2>
|
||||
% my $btn = l('du_APPLY');
|
||||
%= form_for "DiskUsaged" => (method => 'POST') => begin
|
||||
|
||||
% param 'trt' => $du_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $du_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h1><%=l('du_Disk_usage')%></h1>
|
||||
|
||||
<h2><%=l('du_Manage_DiskUsage_settings:')%></h2>
|
||||
|
||||
<p class='paragraph para1'>
|
||||
%=l('du_Wed_Sep_11_19:01:00_BST')
|
||||
</p>
|
||||
|
||||
<pre class='preformatted pref1'>
|
||||
Filesystem Size Used Avail Use% Mounted on
|
||||
/dev/mapper/main-root 29G 4.8G 24G 17% /
|
||||
devtmpfs 2.0G 0 2.0G 0% /dev
|
||||
tmpfs 2.0G 12K 2.0G 1% /dev/shm
|
||||
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
|
||||
tmpfs 2.0G 648K 2.0G 1% /run
|
||||
/dev/sda1 497M 111M 386M 23% /boot'
|
||||
</pre>
|
||||
|
||||
|
||||
<br /><table class="sme-border TableSort sme-table tabl1 ">
|
||||
<thead class='tabl1'>
|
||||
<tr table-head-row>
|
||||
<th class='sme-border table-head-col table-head-col-I-bays '><%=l('du_I-bays')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Usage '><%=l('du_Usage')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Path '><%=l('du_Path')%></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class='tabl1'>
|
||||
% my $control_data = $self->stash('Table1');
|
||||
% foreach my $row (@$control_data) {
|
||||
<tr class='table-row'>
|
||||
<td class='sme-border table-col table-col-Table1-I-bays'><%=$c->render_to_string(inline=>$row->{'Table1-I-bays'})%></td>
|
||||
<td class='sme-border table-col table-col-Table1-Usage'><%=$c->render_to_string(inline=>$row->{'Table1-Usage'})%></td>
|
||||
<td class='sme-border table-col table-col-Table1-Path'><%=$c->render_to_string(inline=>$row->{'Table1-Path'})%></td>
|
||||
</tr>
|
||||
%}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<br /><table class="sme-border TableSort sme-table tabl2 ">
|
||||
<thead class='tabl2'>
|
||||
<tr table-head-row>
|
||||
<th class='sme-border table-head-col table-head-col-Users '><%=l('du_Users')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Usage '><%=l('du_Usage')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Path '><%=l('du_Path')%></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class='tabl2'>
|
||||
% my $control_data = $self->stash('Table2');
|
||||
% foreach my $row (@$control_data) {
|
||||
<tr class='table-row'>
|
||||
<td class='sme-border table-col table-col-Table2-Users'><%=$c->render_to_string(inline=>$row->{'Table2-Users'})%></td>
|
||||
<td class='sme-border table-col table-col-Table2-Usage'><%=$c->render_to_string(inline=>$row->{'Table2-Usage'})%></td>
|
||||
<td class='sme-border table-col table-col-Table2-Path'><%=$c->render_to_string(inline=>$row->{'Table2-Path'})%></td>
|
||||
</tr>
|
||||
%}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:30:26
|
||||
*/
|
||||
.DiskUsage-panel {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.head {}
|
||||
.subh {}
|
||||
.para1 {}
|
||||
.pref1 {}
|
||||
.tabl1 {}
|
||||
thead .tabl1 {}
|
||||
tbody .tabl1 {}
|
||||
.tabl2 {}
|
||||
thead .tabl2 {}
|
||||
tbody .tabl2 {}
|
@@ -1,52 +0,0 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:30:26
|
||||
%#
|
||||
% layout 'default', title => "Sme server 2 - Disk Usage", share_dir => './';
|
||||
%# css specific to this panel:
|
||||
% content_for 'module' => begin
|
||||
%= stylesheet '/css/diskusage.css'
|
||||
<div id="module" class="module DiskUsage-panel">
|
||||
|
||||
% if ($config->{debug} == 1) {
|
||||
<p>
|
||||
%= dumper $c->current_route
|
||||
</p>
|
||||
% }
|
||||
|
||||
<h1><%=$title%></h1>
|
||||
|
||||
% if ( stash('modul') ) {
|
||||
%= $c->render_to_string(inline => stash('modul') );
|
||||
% }
|
||||
|
||||
%if ($du_data->{first}) {
|
||||
<br><p>
|
||||
%=$c->render_to_string(inline =>$c->l($du_data->{first}))
|
||||
</p>
|
||||
|
||||
%} elsif ($du_data->{success}) {
|
||||
<div class='sme-border'>
|
||||
<h2> Operation Status Report</h2><p>
|
||||
%= $c->l($du_data->{success});
|
||||
</p>
|
||||
</div>
|
||||
|
||||
%} elsif ($du_data->{error}) {
|
||||
<div class='sme-error'>
|
||||
<h2> Operation Status Report - error</h2><p>
|
||||
%= $c->l($du_data->{error});
|
||||
</p>
|
||||
</div>
|
||||
%}
|
||||
|
||||
%#Routing to partials according to trt parameter.
|
||||
%#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement'
|
||||
|
||||
% if ($du_data->{trt} eq "PARAMS") {
|
||||
%= include 'partials/_du_PARAMS'
|
||||
%}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
%end
|
@@ -1,14 +0,0 @@
|
||||
#
|
||||
# Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-22 11:30:26
|
||||
#
|
||||
'du_I-bays' => 'I-bays',
|
||||
'du_APPLY' => 'Apply',
|
||||
'du_Disk_Usage' => 'Disk Usage',
|
||||
'du_Hello_PARAMS' => 'Hello PARAMS',
|
||||
'du_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
||||
'du_Wed_Sep_11_19:01:00_BST' => 'Wed Sep 11 19:01:00 BST 2024',
|
||||
'du_Path' => 'Path',
|
||||
'du_Usage' => 'Usage',
|
||||
'du_Users' => 'Users',
|
||||
'du_Disk_usage' => 'Disk usage',
|
||||
'du_Manage_DiskUsage_settings:' => 'Manage DiskUsage settings:',
|
0
Targets/Diskusage/Diskusage-Custom.pm
Normal file → Executable file
0
Targets/Diskusage/Diskusage-Custom.pm
Normal file → Executable file
0
Targets/Diskusage/Diskusage.pm
Normal file → Executable file
0
Targets/Diskusage/Diskusage.pm
Normal file → Executable file
0
Targets/Diskusage/_d_PARAMS.html.ep
Normal file → Executable file
0
Targets/Diskusage/_d_PARAMS.html.ep
Normal file → Executable file
0
Targets/Diskusage/diskusage.css
Normal file → Executable file
0
Targets/Diskusage/diskusage.css
Normal file → Executable file
0
Targets/Diskusage/diskusage.html.ep
Normal file → Executable file
0
Targets/Diskusage/diskusage.html.ep
Normal file → Executable file
0
Targets/Diskusage/diskusage_en.lex
Normal file → Executable file
0
Targets/Diskusage/diskusage_en.lex
Normal file → Executable file
1096
Targets/Emailsettings/Emailsettings-Custom.pm
Normal file
1096
Targets/Emailsettings/Emailsettings-Custom.pm
Normal file
File diff suppressed because it is too large
Load Diff
440
Targets/Emailsettings/Emailsettings.pm
Normal file
440
Targets/Emailsettings/Emailsettings.pm
Normal file
@@ -0,0 +1,440 @@
|
||||
package SrvMngr::Controller::Emailsettings;
|
||||
#
|
||||
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
# Remember that each route must be unique (else they just overwrite each other).
|
||||
# you cannot have get and post on the same name and url.
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# heading : System
|
||||
# description : E-Mail
|
||||
# navigation : 4000 400
|
||||
#
|
||||
# name : emailsettings, method : get, url : /emailsettings, ctlact : Emailsettings#main
|
||||
# name : emailsettingsu, method : post, url : /emailsettingsu, ctlact : Emailsettings#do_update
|
||||
# name : emailsettingsd, method : get, url : /emailsettingsd, ctlact : Emailsettings#do_display
|
||||
#
|
||||
# routes : end
|
||||
#
|
||||
# Documentation: https://wiki.contribs.org/Emailsettings
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# 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::UTF8;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB::UTF8;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB::UTF8;
|
||||
|
||||
my $cdb;
|
||||
my $adb;
|
||||
my $ndb;
|
||||
my $hdb;
|
||||
my $ddb;
|
||||
|
||||
my %mai_data;
|
||||
|
||||
require '/usr/share/smanager/lib/SrvMngr/Controller/Emailsettings-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 - you might want to delete some of these if they are not used.
|
||||
$cdb = esmith::ConfigDB::UTF8->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::UTF8->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
|
||||
|
||||
%mai_data = ();
|
||||
my $title = $c->l('mai_E-Mail');
|
||||
my $modul = '';
|
||||
|
||||
$mai_data{'trt'} = 'FRONT';
|
||||
|
||||
#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($mai_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 delete some of these if they are not used.
|
||||
$cdb = esmith::ConfigDB::UTF8->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::UTF8->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
|
||||
|
||||
my $title = $c->l('mai_E-Mail');
|
||||
|
||||
# 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}) {
|
||||
# $mai_data{$key} = $value;
|
||||
#}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'FRONT'; #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 'FRONT'){
|
||||
#Validate form parameters for panel FRONT
|
||||
$ret = $c->validate_FRONT(\%mai_data);
|
||||
$thispanel = 'FRONT';
|
||||
}
|
||||
|
||||
if ($trt eq 'ACC'){
|
||||
#Validate form parameters for panel ACC
|
||||
$ret = $c->validate_ACC(\%mai_data);
|
||||
$thispanel = 'ACC';
|
||||
}
|
||||
|
||||
if ($trt eq 'FIL'){
|
||||
#Validate form parameters for panel FIL
|
||||
$ret = $c->validate_FIL(\%mai_data);
|
||||
$thispanel = 'FIL';
|
||||
}
|
||||
|
||||
if ($trt eq 'REC'){
|
||||
#Validate form parameters for panel REC
|
||||
$ret = $c->validate_REC(\%mai_data);
|
||||
$thispanel = 'REC';
|
||||
}
|
||||
|
||||
if ($trt eq 'DEL'){
|
||||
#Validate form parameters for panel DEL
|
||||
$ret = $c->validate_DEL(\%mai_data);
|
||||
$thispanel = 'DEL';
|
||||
}
|
||||
|
||||
if ($ret ne 'ok'){
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->do_display($thispanel);
|
||||
} else {
|
||||
#Do whatever is needed, including writing values to the DB
|
||||
|
||||
|
||||
if ($trt eq 'FRONT'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_FRONT(\%mai_data);
|
||||
if ($ret ne 'ok') {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mai_data => \%mai_data
|
||||
);
|
||||
$c->render(template => "emailsettings");
|
||||
return
|
||||
} else {
|
||||
$c->stash( success => $c->l('mai_FRONT_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'ACC'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_ACC(\%mai_data);
|
||||
if ($ret ne 'ok') {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mai_data => \%mai_data
|
||||
);
|
||||
$c->render(template => "emailsettings");
|
||||
return
|
||||
} else {
|
||||
$c->stash( success => $c->l('mai_ACC_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'FIL'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_FIL(\%mai_data);
|
||||
if ($ret ne 'ok') {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mai_data => \%mai_data
|
||||
);
|
||||
$c->render(template => "emailsettings");
|
||||
return
|
||||
} else {
|
||||
$c->stash( success => $c->l('mai_FIL_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'REC'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_REC(\%mai_data);
|
||||
if ($ret ne 'ok') {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mai_data => \%mai_data
|
||||
);
|
||||
$c->render(template => "emailsettings");
|
||||
return
|
||||
} else {
|
||||
$c->stash( success => $c->l('mai_REC_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'DEL'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_DEL(\%mai_data);
|
||||
if ($ret ne 'ok') {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mai_data => \%mai_data
|
||||
);
|
||||
$c->render(template => "emailsettings");
|
||||
return
|
||||
} else {
|
||||
$c->stash( success => $c->l('mai_DEL_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') {
|
||||
$mai_data{'trt'} = 'FRONT';
|
||||
} else {
|
||||
$mai_data{'trt'} = 'none';
|
||||
}
|
||||
$c->do_display($mai_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 delete some of these if they are not used.
|
||||
$cdb = esmith::ConfigDB::UTF8->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::UTF8->open() || die("Couldn't open Hosts db");
|
||||
$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
|
||||
|
||||
my $title = $c->l('mai_E-Mail');
|
||||
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}) {
|
||||
# $mai_data{$key} = $value;
|
||||
#}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
if (! $trt){
|
||||
$trt = $c->param('trt') || 'FRONT'; #Indicates where to go now
|
||||
}
|
||||
|
||||
# Now add in the params from the selected row from the table
|
||||
|
||||
my %selectedrow;
|
||||
|
||||
if ($trt eq 'FRONT'){
|
||||
#Validate Get selected row (if applicable) FRONT
|
||||
%selectedrow = $c->get_selected_FRONT($mai_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'ACC'){
|
||||
#Validate Get selected row (if applicable) ACC
|
||||
%selectedrow = $c->get_selected_ACC($mai_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'FIL'){
|
||||
#Validate Get selected row (if applicable) FIL
|
||||
%selectedrow = $c->get_selected_FIL($mai_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'REC'){
|
||||
#Validate Get selected row (if applicable) REC
|
||||
%selectedrow = $c->get_selected_REC($mai_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'DEL'){
|
||||
#Validate Get selected row (if applicable) DEL
|
||||
%selectedrow = $c->get_selected_DEL($mai_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){
|
||||
$mai_data{$key} = $value;
|
||||
}
|
||||
# Where to go now
|
||||
$mai_data{'trt'} = $trt;
|
||||
|
||||
# Set up other shared data according to the panel to go to
|
||||
|
||||
if ($trt eq 'FRONT'){
|
||||
# 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_FRONT();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$mai_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'ACC'){
|
||||
# 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_ACC();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$mai_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'FIL'){
|
||||
# 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_FIL();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$mai_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'REC'){
|
||||
# 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_REC();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$mai_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'DEL'){
|
||||
# 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_DEL();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$mai_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# and table control fields
|
||||
|
||||
|
||||
# Data for panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
mai_data => \%mai_data
|
||||
);
|
||||
$c->render(template => "emailsettings");
|
||||
}
|
||||
1;
|
56
Targets/Emailsettings/_mai_ACC.html.ep
Normal file
56
Targets/Emailsettings/_mai_ACC.html.ep
Normal file
@@ -0,0 +1,56 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
%#
|
||||
<div id="Emailsettings-ACC" class="partial Emailsettings-ACC">
|
||||
%# <script>
|
||||
%# window.onload = function() {
|
||||
%# SelectInput();
|
||||
%# };
|
||||
%# </script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $mai_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('mai_SAVE');
|
||||
% $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table
|
||||
|
||||
%= form_for "emailsettingsu" => (method => 'POST') => begin
|
||||
% param 'trt' => $mai_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $mai_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
%=l 'mai_DESC_POP_ACCESS_CONTROL'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_POP_ACCESS_CONTROL'
|
||||
</span><span class=input>
|
||||
% param 'POPAccess' => $c->get_current_pop3_access() unless param 'POPAccess';
|
||||
%= select_field 'POPAccess' => $c->get_pop_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
%=l 'mai_DESC_IMAP_ACCESS_CONTROL'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_IMAP_ACCESS_CONTROL'
|
||||
</span><span class=input>
|
||||
% param 'IMAPAccess' => $c->get_current_imap_access() unless param 'IMAPAccess';
|
||||
%= select_field 'IMAPAccess' => $c->get_imap_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
%=l 'mai_DESC_WEBMAIL'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_WEBMAIL'
|
||||
</span><span class=input>
|
||||
% param 'WebMail' => $c->get_current_webmail_status() unless param 'WebMail';
|
||||
%= select_field 'WebMail' => $c->get_webmail_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
% my $btn = l('SAVE');
|
||||
%= submit_button "$btn", class => 'action'
|
||||
|
||||
%# ....
|
||||
%# Probably finally by a submit.
|
||||
%= submit_button $btn, class => 'action'
|
||||
%end
|
||||
</div>
|
89
Targets/Emailsettings/_mai_DEL.html.ep
Normal file
89
Targets/Emailsettings/_mai_DEL.html.ep
Normal file
@@ -0,0 +1,89 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
%#
|
||||
<div id="Emailsettings-DEL" class="partial Emailsettings-DEL">
|
||||
%# <script>
|
||||
%# window.onload = function() {
|
||||
%# SelectInput();
|
||||
%# };
|
||||
%# </script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $mai_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('mai_SAVE');
|
||||
% $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table
|
||||
|
||||
%= form_for "emailsettingsu" => (method => 'POST') => begin
|
||||
% param 'trt' => $mai_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $mai_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
<h2>
|
||||
%=l 'mai_TITLE_UNKNOWN'
|
||||
</h2>
|
||||
|
||||
%=l 'mai_DESC_UNKNOWN'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_UNKNOWN'
|
||||
</span><span class=input>
|
||||
% param 'EmailUnknownUser' => $mai_datas->{emailunknownuser} unless param 'EmailUnknownUser';
|
||||
%= select_field 'EmailUnknownUser' => $c->get_emailunknownuser_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
<!--<hr class='menubar' />-->
|
||||
<h2>
|
||||
%=l 'mai_TITLE_DELEGATE'
|
||||
</h2>
|
||||
|
||||
%=l 'mai_DESC_DELEGATE'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_DELEGATE'
|
||||
</span><span class=input>
|
||||
% param 'DelegateMailServer' => $mai_datas->{delegatemailserver} unless param 'DelegateMailServer';
|
||||
%= text_field 'DelegateMailServer', class => 'input'
|
||||
</span></p>
|
||||
|
||||
<!--<hr class='sectionbar' />-->
|
||||
<h2>
|
||||
%=l 'mai_TITLE_SMARTHOST'
|
||||
</h2>
|
||||
|
||||
%=l 'mai_DESC_SMARTHOST'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SMARTHOST'
|
||||
</span><span class=input>
|
||||
% param 'SMTPSmartHost' => $mai_datas->{smtpsmarthost} unless param 'SMTPSmartHost';
|
||||
%= text_field 'SMTPSmartHost', class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SMARTHOST_SMTPAUTH_STATUS'
|
||||
</span><span class=input>
|
||||
% param 'SMTPAUTHPROXY_status' => $mai_datas->{smtpauthproxystatus} unless param 'SMTPAUTHPROXY_status';
|
||||
%= select_field 'SMTPAUTHPROXY_status' => [[(l 'DISABLED') => 'disabled'], [(l 'ENABLED') => 'enabled']], class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SMARTHOST_SMTPAUTH_USERID'
|
||||
</span><span class=input>
|
||||
% param 'SMTPAUTHPROXY_Userid' => $mai_datas->{smtpauthproxyuserid} unless param 'SMTPAUTHPROXY_Userid';
|
||||
%= text_field 'SMTPAUTHPROXY_Userid', class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SMARTHOST_SMTPAUTH_PASSWD'
|
||||
</span><span class=input>
|
||||
% param 'SMTPAUTHPROXY_Passwd' => $mai_datas->{smtpauthproxypassword} unless param 'SMTPAUTHPROXY_Passwd';
|
||||
%= password_field 'SMTPAUTHPROXY_Passwd', class => 'input'
|
||||
</span></p>
|
||||
|
||||
|
||||
%# ....
|
||||
%# Probably finally by a submit.
|
||||
%= submit_button $btn, class => 'action'
|
||||
%end
|
||||
</div>
|
97
Targets/Emailsettings/_mai_FIL.html.ep
Normal file
97
Targets/Emailsettings/_mai_FIL.html.ep
Normal file
@@ -0,0 +1,97 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
%#
|
||||
<div id="Emailsettings-FIL" class="partial Emailsettings-FIL">
|
||||
%# <script>
|
||||
%# window.onload = function() {
|
||||
%# SelectInput();
|
||||
%# };
|
||||
%# </script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $mai_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('mai_SAVE');
|
||||
% $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table
|
||||
|
||||
%= form_for "emailsettingsu" => (method => 'POST') => begin
|
||||
% param 'trt' => $mai_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $mai_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
%=l 'mai_DESC_VIRUS_SCAN'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_VIRUS_SCAN'
|
||||
</span><span class=input>
|
||||
% param 'VirusStatus' => $mai_datas->{virusstatus} unless param 'VirusStatus';
|
||||
%= select_field 'VirusStatus' => [[(l 'DISABLED') => 'disabled'], [ (l 'ENABLED') => 'enabled']], class => 'input'
|
||||
</span><br></p>
|
||||
|
||||
%=l 'mai_DESC_SPAM_SCAN'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SPAM_SCAN'
|
||||
</span><span class=input>
|
||||
% param 'Spamstatus' => $mai_datas->{spamstatus} unless param 'Spamstatus';
|
||||
%= select_field 'Spamstatus' => [[(l 'DISABLED') => 'disabled'], [ (l 'ENABLED') => 'enabled']], class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SPAM_SENSITIVITY'
|
||||
</span><span class=input>
|
||||
% param 'SpamSensitivity' => $mai_datas->{spamsensitivity} unless param 'SpamSensitivity';
|
||||
%= select_field 'SpamSensitivity' => $c->get_spam_sensitivity_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SPAM_TAGLEVEL'
|
||||
</span><span class=input>
|
||||
% param 'SpamTagLevel' => $mai_datas->{spamtaglevel} unless param 'SpamTagLevel';
|
||||
%= select_field 'SpamTagLevel' => $c->get_spam_level_options(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SPAM_REJECTLEVEL'
|
||||
</span><span class=input>
|
||||
% param 'SpamRejectLevel' => $mai_datas->{spamrejectlevel} unless param 'SpamRejectLevel';
|
||||
%= select_field 'SpamRejectLevel' => $c->get_spam_level_options(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SORTSPAM'
|
||||
</span><span class=input>
|
||||
% param 'SpamSortSpam' => $mai_datas->{spamsortspam} unless param 'SpamSortSpam';
|
||||
%= select_field 'SpamSortSpam' => [[(l 'DISABLED') => 'disabled'], [ (l 'ENABLED') => 'enabled']], class => 'input'
|
||||
</span></p>
|
||||
|
||||
%=l 'mai_DESC_SPAM_SUBJECT'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SPAM_SUBJECTTAG'
|
||||
</span><span class=input>
|
||||
% param 'SpamSubjectTag' => $mai_datas->{spamsubjecttag} unless param 'SpamSubjectTag';
|
||||
%= select_field 'SpamSubjectTag' => [[(l 'DISABLED') => 'disabled'], [ (l 'ENABLED') => 'enabled']], class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SPAM_SUBJECT'
|
||||
</span><span class=input>
|
||||
% param 'SpamSubject' => $mai_datas->{spamsubject} unless param 'SpamSubject';
|
||||
%= text_field 'SpamSubject' => class => 'input'
|
||||
</span></p>
|
||||
|
||||
%=l 'mai_DESC_BLOCK_EXECUTABLE_CONTENT'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_CONTENT_TO_BLOCK'
|
||||
</span><span class=input>
|
||||
% param 'BlockExecutableContent' => $c->get_patterns_current_opt() unless param 'BlockExecutableContent';
|
||||
%= select_field 'BlockExecutableContent' => $c->get_patterns_opt(), class => 'input', multiple => "1"
|
||||
</span></p>
|
||||
|
||||
%# ....
|
||||
%# Probably finally by a submit.
|
||||
%= submit_button $btn, class => 'action'
|
||||
%end
|
||||
</div>
|
155
Targets/Emailsettings/_mai_FRONT.html.ep
Normal file
155
Targets/Emailsettings/_mai_FRONT.html.ep
Normal file
@@ -0,0 +1,155 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
%#
|
||||
<div id="Emailsettings-FRONT" class="partial Emailsettings-FRONT">
|
||||
%# <script>
|
||||
%# window.onload = function() {
|
||||
%# SelectInput();
|
||||
%# };
|
||||
%# </script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $mai_data
|
||||
</pre>
|
||||
% }
|
||||
% $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table
|
||||
<h1><%= $title%></h1>
|
||||
<br>
|
||||
<br>
|
||||
% my $btn = l('Modify');
|
||||
|
||||
<fieldset title='fred'>
|
||||
<legend><%= $c->l('mai_DESC_STATE_ACCESS_BUTTON') %></legend>
|
||||
%= form_for 'emailsettings' => (method => 'POST') => begin
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_POP_ACCESS_CONTROL'
|
||||
</span><span class=data2>
|
||||
%= $c->get_current_pop3_access( TRUE )
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_IMAP_ACCESS_CONTROL'
|
||||
</span><span class=data2>
|
||||
%= $c->get_current_imap_access( TRUE )
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_WEBMAIL'
|
||||
</span><span class=data2>
|
||||
%= $c->get_current_webmail_status( TRUE )
|
||||
</span></p>
|
||||
|
||||
<br>
|
||||
<div class='center'>
|
||||
%= submit_button "$btn", class => 'action'
|
||||
</div>
|
||||
|
||||
%= hidden_field 'trt' => 'ACC'
|
||||
% end
|
||||
</fieldset>
|
||||
<br>
|
||||
|
||||
|
||||
<fieldset>
|
||||
<legend><%= $c->l('mai_DESC_STATE_FILTERING_BUTTON') %></legend>
|
||||
%= form_for 'emailsettings' => (method => 'POST') => begin
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_VIRUS_SCAN'
|
||||
</span><span class=data2>
|
||||
%= $c->get_virus_status(TRUE)
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SPAM_SCAN'
|
||||
</span><span class=data2>
|
||||
%= $c->get_spam_status(TRUE)
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_BLOCK_EXECUTABLE_CONTENT'
|
||||
</span><span class=data2>
|
||||
%= $c->get_patterns_status(TRUE)
|
||||
</span></p>
|
||||
|
||||
<br>
|
||||
<div class='center'>
|
||||
%= submit_button "$btn", class => 'action'
|
||||
</div>
|
||||
|
||||
%= hidden_field 'trt' => 'FIL'
|
||||
% end
|
||||
</fieldset>
|
||||
<br>
|
||||
|
||||
<fieldset>
|
||||
<legend><%= $c->l('mai_DESC_STATE_RECEPTION_BUTTON') %></legend>
|
||||
%= form_for 'emailsettings' => (method => 'POST') => begin
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_MODE'
|
||||
</span><span class=data2>
|
||||
%= $mai_datas->{fetchmailmethod}
|
||||
</span></p>
|
||||
|
||||
% my $smtp_mesg;
|
||||
|
||||
% $smtp_mesg=l('SMTP port %u allow client to authenticate:');
|
||||
<p><span class=label>
|
||||
%= sprintf($smtp_mesg,$c->get_db_prop('qpsmtpd','TCPPort',25));
|
||||
</span><span class=data2>
|
||||
%= $c->get_current_smtp_auth( TRUE )
|
||||
</span></p>
|
||||
|
||||
% $smtp_mesg=l('SMTPS SSL/TLS auth: port %u status:');
|
||||
<p><span class=label>
|
||||
%= sprintf($smtp_mesg,$c->get_db_prop('sqpsmtpd','TCPPort',465));
|
||||
</span><span class=data2>
|
||||
%= $c->get_current_smtp_ssl_auth( TRUE, 's', FALSE )
|
||||
</span></p>
|
||||
|
||||
% $smtp_mesg=l 'Submission port %u status:';
|
||||
<p><span class=label>
|
||||
%= sprintf($smtp_mesg,$c->get_db_prop('uqpsmtpd','TCPPort',587));
|
||||
</span><span class=data2>
|
||||
%= $c->get_current_smtp_ssl_auth( TRUE,'u', FALSE )
|
||||
</span></p>
|
||||
<br />
|
||||
|
||||
<div class='center'>
|
||||
%= submit_button "$btn", class => 'action'
|
||||
</div>
|
||||
|
||||
%= hidden_field 'trt' => 'REC'
|
||||
% end
|
||||
</fieldset>
|
||||
<br>
|
||||
|
||||
<fieldset>
|
||||
<legend><%= $c->l('mai_DESC_STATE_DELIVERY_BUTTON') %></legend>
|
||||
%= form_for 'emailsettings' => (method => 'POST') => begin
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_UNKNOWN'
|
||||
</span><span class=data2>
|
||||
%= $c->get_emailunknownuser_status( TRUE )
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_DELEGATE'
|
||||
</span><span class=data2>
|
||||
%= $c->get_value('DelegateMailServer')
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SMARTHOST'
|
||||
</span><span class=data2>
|
||||
%= $c->get_value('SMTPSmartHost')
|
||||
</span></p>
|
||||
|
||||
<br>
|
||||
<div class='center'>
|
||||
%= submit_button "$btn", class => 'action'
|
||||
</div>
|
||||
|
||||
%= hidden_field 'trt' => 'DEL'
|
||||
% end
|
||||
</fieldset>
|
||||
</div>
|
158
Targets/Emailsettings/_mai_REC.html.ep
Normal file
158
Targets/Emailsettings/_mai_REC.html.ep
Normal file
@@ -0,0 +1,158 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
%#
|
||||
<div id="Emailsettings-REC" class="partial Emailsettings-REC">
|
||||
%# <script>
|
||||
%# window.onload = function() {
|
||||
%# SelectInput();
|
||||
%# };
|
||||
%# </script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $mai_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('mai_SAVE');
|
||||
% $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table
|
||||
|
||||
%= form_for "emailsettingsu" => (method => 'POST') => begin
|
||||
% param 'trt' => $mai_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $mai_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
%=l 'mai_DESC_MODE'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_MODE'
|
||||
</span><span class=input>
|
||||
% param 'FetchmailMethod' => $mai_datas->{fetchmailmethod} unless param 'FetchmailMethod';
|
||||
<!--
|
||||
<pre>
|
||||
%= dumper $mai_datas->{fetchmailmethod}
|
||||
%= dumper $c->get_retrieval_opt()
|
||||
%= param 'FetchmailMethod'
|
||||
</pre>
|
||||
-->
|
||||
%= select_field 'FetchmailMethod' => $c->get_retrieval_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
%#=l 'mai_DESC_SMTP_AUTH_CONTROL'
|
||||
<br />
|
||||
%= l "SMTP port (25) main purpose is to receive emails from another server, STARTTLS is always offered, but auth if offered is only if STARTTLS is also used by client."
|
||||
<br />
|
||||
%= l "SMTPS port (465) will require implicit SSL/TLS then authenticate to send."
|
||||
<br />
|
||||
%= l "SMTP Submission port (587) will require STARTTLS, then authenticate to send."
|
||||
<br />
|
||||
|
||||
% my $smtp_mesg=l('SMTP port %u allow client to authenticate:');
|
||||
<p><span class=label>
|
||||
%= sprintf($smtp_mesg,$c->get_db_prop('qpsmtpd','TCPPort',25));
|
||||
</span><span class=input>
|
||||
% param 'SMTPAuth' => $c->get_current_smtp_auth( FALSE ) unless param 'SMTPAuth';
|
||||
<!--
|
||||
<pre>
|
||||
%= dumper $c->get_smtp_auth_opt()
|
||||
%= dumper $c->get_current_smtp_auth(FALSE)
|
||||
%= dumper $c->get_db_prop("qpsmtpd","Authentication")
|
||||
%= param 'SMTPAuth'
|
||||
</pre>
|
||||
-->
|
||||
%= select_field 'SMTPAuth' => $c->get_smtp_auth_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
% my $smtp_mesg=l('SMTPS SSL/TLS auth: port %u status:');
|
||||
<p><span class=label>
|
||||
%= sprintf($smtp_mesg,$c->get_db_prop('sqpsmtpd','TCPPort',465));
|
||||
</span><span class=input>
|
||||
% param 'sSMTPAuth' => $c->get_current_smtp_ssl_auth(FALSE,'s', TRUE) unless param 'sSMTPAuth';
|
||||
|
||||
%= select_field 'sSMTPAuth' => $c->get_smtp_ssl_auth_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
%my $smtp_mesg=l('Submission port %u status:');
|
||||
<p><span class=label>
|
||||
%= sprintf($smtp_mesg,$c->get_db_prop('uqpsmtpd','TCPPort',587));
|
||||
</span><span class=input>
|
||||
% param 'uSMTPAuth' => $c->get_current_smtp_ssl_auth(FALSE,'u', TRUE) unless param 'uSMTPAuth';
|
||||
<!--
|
||||
<pre>
|
||||
%= dumper $c->get_smtp_ssl_auth_opt()
|
||||
%= dumper $c->get_current_smtp_ssl_auth(FALSE,'s', TRUE)
|
||||
%= dumper $c->get_current_smtp_ssl_auth(FALSE,'u', TRUE)
|
||||
%= dumper $c->get_db_prop("uqpsmtpd","access")
|
||||
%= param 'uSMTPAuth'
|
||||
</pre>
|
||||
-->
|
||||
%= select_field 'uSMTPAuth' => $c->get_smtp_ssl_auth_opt(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
<!--<hr class="sectionbar" />-->
|
||||
<h2>
|
||||
%=l 'mai_TITLE_SECONDARY'
|
||||
</h2>
|
||||
|
||||
%=l 'mai_DESC_SECONDARY'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SECONDARY'
|
||||
</span><span class=input>
|
||||
% param 'SecondaryMailServer' => $mai_datas->{secondarymailserver} unless param 'SecondaryMailServer';
|
||||
%= text_field 'SecondaryMailServer', class => 'input'
|
||||
</span></p>
|
||||
|
||||
%=l 'mai_DESC_FETCH_PERIOD'
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_FETCH_PERIOD'
|
||||
</span><span class=input>
|
||||
% param 'FreqOffice' => $mai_datas->{freqoffice} unless param 'FreqOffice';
|
||||
%= select_field 'FreqOffice' => $c->fetchmail_freq(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_FETCH_PERIOD_NIGHTS'
|
||||
</span><span class=input>
|
||||
% param 'FreqOutside' => $mai_datas->{freqoutside} unless param 'FreqOutside';
|
||||
%= select_field 'FreqOutside' => $c->fetchmail_freq(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_FETCH_PERIOD_WEEKENDS'
|
||||
</span><span class=input>
|
||||
% param 'FreqWeekend' => $mai_datas->{freqweekend} unless param 'FreqWeekend';
|
||||
%= select_field 'FreqWeekend' => $c->fetchmail_freq(), class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_POP_ACCOUNT'
|
||||
</span><span class=input>
|
||||
% param 'SecondaryMailAccount' => $mai_datas->{secondarymailaccount} unless param 'SecondaryMailAccount';
|
||||
%= text_field 'SecondaryMailAccount', class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_POP_PASS'
|
||||
</span><span class=input>
|
||||
% param 'SecondaryMailPassword' => $mai_datas->{secondarymailpassword} unless param 'SecondaryMailPassword';
|
||||
%= password_field 'SecondaryMailPassword', class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SORT_METHOD'
|
||||
</span><span class=input>
|
||||
% param 'SpecifyHeader' => $mai_datas->{specifyheader} unless param 'SpecifyHeader';
|
||||
%= select_field 'SpecifyHeader' => [[(l 'mai_DEFAULT') => 'off'], [(l 'mai_SPECIFY_BELOW') => 'on']], class => 'input'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'mai_LABEL_SORT_HEADER'
|
||||
</span><span class=input>
|
||||
% param 'SecondaryMailEnvelope' => $mai_datas->{secondarymailenvelope} unless param 'SecondaryMailEnvelope';
|
||||
%= text_field 'SecondaryMailEnvelope', class => 'input'
|
||||
</span></p>
|
||||
|
||||
%# ....
|
||||
%# Probably finally by a submit.
|
||||
%= submit_button $btn, class => 'action'
|
||||
%end
|
||||
</div>
|
14
Targets/Emailsettings/emailsettings.css
Normal file
14
Targets/Emailsettings/emailsettings.css
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
*/
|
||||
.Emailsettings-panel {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.name {}
|
||||
.rout {}
|
68
Targets/Emailsettings/emailsettings.html.ep
Normal file
68
Targets/Emailsettings/emailsettings.html.ep
Normal file
@@ -0,0 +1,68 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
%#
|
||||
% layout 'default', title => "Sme server 2 - E-Mail", share_dir => './';
|
||||
%# css specific to this panel:
|
||||
% content_for 'module' => begin
|
||||
%= stylesheet '/css/emailsettings.css'
|
||||
%= javascript '/js/emailsettings.js'
|
||||
<div id="module" class="module Emailsettings-panel">
|
||||
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $c->current_route
|
||||
%= dumper $mai_data->{trt}
|
||||
</pre>
|
||||
% }
|
||||
|
||||
<h1><%=$title%></h1>
|
||||
|
||||
% if ( stash('modul')) {
|
||||
%= $c->render_to_string(inline => stash('modul') );
|
||||
% }
|
||||
|
||||
%if ($c->stash('first')) {
|
||||
<br><p>
|
||||
%=$c->render_to_string(inline =>$c->l($c->stash('first')))
|
||||
</p>
|
||||
|
||||
%} elsif ($c->stash('success')) {
|
||||
<div class='success '>
|
||||
%= $c->l($c->stash('success'));
|
||||
</div>
|
||||
<br />
|
||||
|
||||
%} elsif ($c->stash('error')) {
|
||||
<div class='sme-error'>
|
||||
%= $c->l($c->stash('error'));
|
||||
</div>
|
||||
<br />
|
||||
%}
|
||||
|
||||
%#Routing to partials according to trt parameter.
|
||||
%#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement'
|
||||
|
||||
% if ($mai_data->{trt} eq "FRONT") {
|
||||
%= include 'partials/_mai_FRONT'
|
||||
%}
|
||||
|
||||
% if ($mai_data->{trt} eq "ACC") {
|
||||
%= include 'partials/_mai_ACC'
|
||||
%}
|
||||
|
||||
% if ($mai_data->{trt} eq "FIL") {
|
||||
%= include 'partials/_mai_FIL'
|
||||
%}
|
||||
|
||||
% if ($mai_data->{trt} eq "REC") {
|
||||
%= include 'partials/_mai_REC'
|
||||
%}
|
||||
|
||||
% if ($mai_data->{trt} eq "DEL") {
|
||||
%= include 'partials/_mai_DEL'
|
||||
%}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
%end
|
5
Targets/Emailsettings/emailsettings.js
Normal file
5
Targets/Emailsettings/emailsettings.js
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-29 08:53:20
|
||||
//
|
||||
$(document).ready(function() {
|
||||
});
|
152
Targets/Emailsettings/emailsettings_en.lex
Normal file
152
Targets/Emailsettings/emailsettings_en.lex
Normal file
@@ -0,0 +1,152 @@
|
||||
'mai_FORM_TITLE' => 'E-mail settings',
|
||||
'E-mail' => 'E-mail',
|
||||
'mai_SUCCESS' => 'The new e-mail settings have been saved.',
|
||||
'mai_NEVER' => 'not at all',
|
||||
'mai_EVERY5MIN' => 'Every 5 minutes',
|
||||
'mai_EVERY15MIN' => 'Every 15 minutes',
|
||||
'mai_EVERY30MIN' => 'Every 30 minutes',
|
||||
'mai_EVERYHOUR' => 'Every hour',
|
||||
'mai_EVERY2HRS' => 'Every 2 hours',
|
||||
'mai_STANDARD' => 'Standard (SMTP)',
|
||||
'mai_ETRN' => 'ETRN (SMTP with client request)',
|
||||
'mai_DEFAULT' => 'Default',
|
||||
'mai_SPECIFY_BELOW' => 'Specify below',
|
||||
'mai_MULTIDROP' => 'multi-drop',
|
||||
'mai_LABEL_MODE' => 'E-mail retrieval mode',
|
||||
'mai_DESC_MODE' => 'The e-mail retrieval mode can be set to
|
||||
standard (for dedicated Internet connections), ETRN (recommended
|
||||
for dialup connections), or multi-drop (for dialup connections if
|
||||
ETRN is not supported by your Internet provider). Note that
|
||||
multi-drop mode is the only option available when the server is
|
||||
configured in private server and gateway mode.',
|
||||
'mai_LABEL_DELEGATE' => 'Address of internal mail server',
|
||||
'mai_TITLE_DELEGATE' => 'Delegate mail servers',
|
||||
'mai_DESC_DELEGATE' => 'Your server includes a complete, full-featured e-mail server. However,
|
||||
if for some reason you wish to delegate e-mail processing to
|
||||
another system, specify the IP address of the delegate system
|
||||
here. For normal operation, leave this field blank.',
|
||||
'mai_LABEL_SECONDARY' => 'Secondary mail server',
|
||||
'mai_TITLE_SECONDARY' => 'ETRN or multi-drop settings',
|
||||
'mai_DESC_SECONDARY' => 'For ETRN or multi-drop, specify the hostname or IP address of your
|
||||
secondary mail server. (If using the standard e-mail setup, this
|
||||
field can be left blank.)',
|
||||
'mai_DESC_FETCH_PERIOD' => 'For ETRN or multi-drop, you can control how frequently this server
|
||||
contacts your secondary e-mail server to fetch e-mail. More
|
||||
frequent connections mean that you receive your e-mail more
|
||||
quickly, but also cause Internet requests to be sent more often,
|
||||
possibly increasing your phone and Internet charges.',
|
||||
'mai_LABEL_FETCH_PERIOD' => 'During office hours (8:00 AM to 6:00 PM) on weekdays',
|
||||
'mai_LABEL_FETCH_PERIOD_NIGHTS' => 'Outside office hours (6:00 PM to 8:00 AM) on weekdays',
|
||||
'mai_LABEL_FETCH_PERIOD_WEEKENDS' => 'During the weekend',
|
||||
'mai_DESC_POP_ACCOUNT' => 'For multi-drop e-mail, specify the POP user account and password.
|
||||
(If using standard or ETRN e-mail, these fields can be blank.)
|
||||
Also, for multi-drop, you can either use the default mail sorting
|
||||
method, or you can specify a particular message header to use for
|
||||
mail sorting.',
|
||||
'mai_LABEL_POP_PASS' => 'POP user password (for multi-drop)',
|
||||
'mai_LABEL_POP_ACCOUNT' => 'POP user account (for multi-drop)',
|
||||
'mai_LABEL_SORT_METHOD' => 'Select sort method (for multi-drop)',
|
||||
'mai_LABEL_SORT_HEADER' => 'Select sort header (for multi-drop)',
|
||||
'mai_LABEL_FETCH_PROTO' => 'Protocol (for multi-drop)',
|
||||
'mai_LABEL_FETCH_SECURE' => 'Tunnel over SSL (for multi-drop)',
|
||||
'mai_AUTO' => 'Automatic',
|
||||
'mai_ENABLED_BOTH' => 'Allow both HTTP and HTTPS',
|
||||
'mai_ENABLED_SECURE_ONLY' => 'Allow HTTPS (secure)',
|
||||
'mai_ONLY_LOCAL_NETWORK_SSL' => 'Allow HTTPS (secure) from local networks',
|
||||
'mai_INSECURE_POP3' => 'Allow both POP3 and POP3S',
|
||||
'mai_ALLOW_PRIVATE' => 'Allow private',
|
||||
'mai_SECURE_POP3' => 'Allow private and public (secure POP3S)',
|
||||
'mai_INSECURE_IMAP' => 'Allow both IMAP and IMAPS',
|
||||
'mai_SECURE_IMAP' => 'Allow private and public (secure IMAPS)',
|
||||
'mai_INSECURE_SMTP' => 'Allow both SMTP and SSMTP',
|
||||
'mai_SECURE_SMTP' => 'Allow SSMTP (secure)',
|
||||
'mai_LABEL_POP_ACCESS_CONTROL' => 'POP3 server access',
|
||||
'mai_LABEL_IMAP_ACCESS_CONTROL' => 'IMAP server access',
|
||||
'mai_LABEL_SMTP_AUTH_CONTROL' => 'SMTP authentication',
|
||||
'mai_FORWARD_TO_ADMIN' => 'Send to administrator',
|
||||
'mai_FORWARD_TO' => 'Send to',
|
||||
'mai_RETURN_TO_SENDER' => 'Reject',
|
||||
'mai_LABEL_UNKNOWN' => 'E-mail to unknown users',
|
||||
'mai_TITLE_UNKNOWN' => 'Unknown Users',
|
||||
'mai_DESC_UNKNOWN' => 'Selecting Reject (recommended setting) will configure the server to only
|
||||
accept mail for valid email addresses (for example users, groups, pseudonyms).
|
||||
Mail for other addresses will be rejected.',
|
||||
'mai_LABEL_SMARTHOST' => 'Address of Internet provider\'s mail server',
|
||||
'mai_TITLE_SMARTHOST' => 'SMTP server',
|
||||
'mai_DESC_SMARTHOST' => 'The server can deliver outgoing messages directly to their
|
||||
destination (recommended in most cases) or can deliver them via
|
||||
your Internet provider\'s SMTP server (recommended if you have an
|
||||
unreliable Internet connection or are using a residential Internet
|
||||
service). If using your Internet provider\'s SMTP server, specify
|
||||
its hostname or IP address below. Otherwise leave this field blank.',
|
||||
'mai_INVALID_SMARTHOST' => 'The smarthost name you entered is not a valid internet domain name and is not blank',
|
||||
'mai_INVALID_DELEGATE' => 'The delegate host name you entered is not a valid internet domain name and is not blank',
|
||||
'mai_DESC_POP_ACCESS_CONTROL' => 'You can control POP3 server access. The setting \'Allow access
|
||||
only from local networks\' allows POP3 access only from your
|
||||
local network(s). The POP3S setting can be used to provide
|
||||
encrypted external access to your POP3 server. We recommend
|
||||
leaving this setting \'Allow access only from local networks\'
|
||||
unless you have a specific reason to do otherwise.',
|
||||
'mai_DESC_IMAP_ACCESS_CONTROL' => 'You can control IMAP server access. The setting \'Allow access
|
||||
only from local networks\' allows IMAP access only from your
|
||||
local network(s). The IMAPS setting can be used to provide
|
||||
encrypted external access to your IMAP server. We recommend
|
||||
leaving this setting \'Allow access only from local networks\'
|
||||
unless you have a specific reason to do otherwise.',
|
||||
'mai_DESC_SMTP_AUTH_CONTROL' => 'You can provide authenticated access to your SMTP server, or
|
||||
set it to Disabled.
|
||||
The SSMTP setting requires <b>all</b> users to use SSL/TLS
|
||||
authentication. The SMTP and SSMTP option additionally allows
|
||||
STARTTLS to be used to ensure secure authentication.',
|
||||
'mai_DESC_WEBMAIL' => 'You can enable or disable webmail on this system. Webmail allows
|
||||
users to access their mail through a regular web browser by
|
||||
pointing the browser to https://[_1]/webmail,and
|
||||
logging in to their account.',
|
||||
'mai_LABEL_WEBMAIL' => 'Webmail access',
|
||||
'mai_LABEL_BLOCK_EXECUTABLE_CONTENT' => 'Executable content blocking',
|
||||
'mai_LABEL_CONTENT_TO_BLOCK' => 'Content to block',
|
||||
'mai_DESC_BLOCK_EXECUTABLE_CONTENT' => 'You can block executable content in e-mail attachments
|
||||
by highlighting the executable attachment types you wish to
|
||||
block. E-mail containing these attachment types will
|
||||
be automatically returned to the sender.',
|
||||
'mai_UNACCEPTABLE_CHARS' => 'This field requires a valid e-mail address, which must include
|
||||
the @ symbol and a domain name.',
|
||||
'mai_DESC_STATE_ACCESS' => 'E-mail access',
|
||||
'mai_DESC_STATE_ACCESS_BUTTON' => 'Change e-mail access settings',
|
||||
'mai_DESC_STATE_RECEPTION' => 'E-mail reception',
|
||||
'mai_DESC_STATE_RECEPTION_BUTTON' => 'Change e-mail reception settings',
|
||||
'mai_DESC_STATE_DELIVERY' => 'E-mail delivery',
|
||||
'mai_DESC_STATE_DELIVERY_BUTTON' => 'Change e-mail delivery settings',
|
||||
'mai_DESC_STATE_FILTERING_BUTTON' => 'Change e-mail filtering settings',
|
||||
'mai_LABEL_VIRUS_SCAN' => 'Virus scanning',
|
||||
'mai_DESC_VIRUS_SCAN' => 'You can scan incoming and outgoing e-mail for viruses. If scanning is enabled and a virus is detected, the e-mail will be rejected and returned to the
|
||||
sender.',
|
||||
'mai_LABEL_SPAM_SCAN' => 'Spam filtering',
|
||||
'mai_DESC_SPAM_SCAN' => 'You can scan e-mail for spam. If Spam filtering is
|
||||
enabled, an X-Spam-Status: header is added to each
|
||||
message, which can be used for filtering spam.
|
||||
You can adjust the sensitivity of the Spam detection
|
||||
process from the default of medium. For fine-grained
|
||||
control, you can set the Spam sensitivity to Custom
|
||||
and then choose a custom tagging level, and
|
||||
optionally a level at which to reject the message.',
|
||||
'mai_LABEL_SPAM_SUBJECT' => 'SPAM subject prefix',
|
||||
'mai_DESC_SPAM_SUBJECT' => 'You can enable to add a tag to the subject of each
|
||||
message that is classified as SPAM.
|
||||
The value for this tag can be defined below.',
|
||||
'mai_LABEL_SPAM_SENSITIVITY' => 'Spam sensitivity',
|
||||
'mai_LABEL_SPAM_TAGLEVEL' => 'Custom spam tagging level',
|
||||
'mai_LABEL_SPAM_REJECTLEVEL' => 'Custom spam rejection level',
|
||||
'mai_LABEL_SPAM_SUBJECTTAG' => 'Modify subject of spam messages',
|
||||
'mai_LABEL_SORTSPAM' => 'Sort spam into junkmail folder',
|
||||
'mai_VERYHIGH' => 'Very high',
|
||||
'mai_HIGH' => 'High',
|
||||
'mai_MEDIUM' => 'Medium',
|
||||
'mai_LOW' => 'Low',
|
||||
'mai_VERYLOW' => 'Very low',
|
||||
'mai_CUSTOM' => 'Custom',
|
||||
'mai_LABEL_SMARTHOST_SMTPAUTH_STATUS' => 'SMTP Authentication for Internet provider',
|
||||
'mai_LABEL_SMARTHOST_SMTPAUTH_USERID' => 'Mail server user id',
|
||||
'mai_LABEL_SMARTHOST_SMTPAUTH_PASSWD' => 'Mail server password',
|
||||
'mai_VALIDATION_SMTPAUTH_NONBLANK' => 'This field cannot be left blank if SMTP Authentication is
|
||||
enabled.',
|
835
Targets/Letsencrypt/Letsencrypt-Custom.pm
Normal file → Executable file
835
Targets/Letsencrypt/Letsencrypt-Custom.pm
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-16 10:30:16
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-16 10:30:16
|
||||
#
|
||||
#
|
||||
# Routines to be edited by the developer to provide content and validation for parameters
|
||||
@@ -12,426 +12,555 @@ use esmith::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
use constant FALSE => 0;
|
||||
use constant TRUE => 1;
|
||||
|
||||
|
||||
#The most common ones
|
||||
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
# Validation routines - parameters for each panel
|
||||
sub validate_LIST {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
sub validate_LIST {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('InternalIP')
|
||||
{$ret .= 'Validation for InternalIP failed';}
|
||||
if (! TRUE) #validate $c->param('ExternalIP')
|
||||
{$ret .= 'Validation for ExternalIP failed';}
|
||||
if (! TRUE) #validate $c->param('InternetIP')
|
||||
{$ret .= 'Validation for InternetIP failed';}
|
||||
if (! TRUE) #validate $c->param('Issuer')
|
||||
{$ret .= 'Validation for Issuer failed';}
|
||||
if (! TRUE) #validate $c->param('Expiry')
|
||||
{$ret .= 'Validation for Expiry failed';}
|
||||
if (! TRUE) #validate $c->param('NotBefore')
|
||||
{$ret .= 'Validation for NotBefore failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE) #validate $c->param('InternalIP')
|
||||
{
|
||||
$ret .= 'Validation for InternalIP failed';
|
||||
}
|
||||
|
||||
sub validate_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "Error from params";
|
||||
if (! TRUE) #validate $c->param('status')
|
||||
{$ret .= 'Validation for status failed';}
|
||||
if (! TRUE) #validate $c->param('hookScript')
|
||||
{$ret .= 'Validation for hookScript failed';}
|
||||
if (! TRUE) #validate $c->param('hostOverride')
|
||||
{$ret .= 'Validation for hostOverride failed';}
|
||||
if (! TRUE) #validate $c->param('ACCEPT_TERMS')
|
||||
{$ret .= 'Validation for ACCEPT_TERMS failed';}
|
||||
if (! TRUE) #validate $c->param('API')
|
||||
{$ret .= 'Validation for API failed';}
|
||||
if (! TRUE) #validate $c->param('keysize')
|
||||
{$ret .= 'Validation for keysize failed';}
|
||||
if (! TRUE) #validate $c->param('configure')
|
||||
{$ret .= 'Validation for configure failed';}
|
||||
if (! TRUE) #validate $c->param('Email')
|
||||
{$ret .= 'Validation for Email failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE) #validate $c->param('ExternalIP')
|
||||
{
|
||||
$ret .= 'Validation for ExternalIP failed';
|
||||
}
|
||||
|
||||
sub validate_CHECKALLDOMAINS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('AllDomainsCheck')
|
||||
{$ret .= 'Validation for AllDomainsCheck failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE) #validate $c->param('InternetIP')
|
||||
{
|
||||
$ret .= 'Validation for InternetIP failed';
|
||||
}
|
||||
|
||||
sub validate_CHECKALLENABLEDDOMAINS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('EnabledDomainsCheck')
|
||||
{$ret .= 'Validation for EnabledDomainsCheck failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE) #validate $c->param('Issuer')
|
||||
{
|
||||
$ret .= 'Validation for Issuer failed';
|
||||
}
|
||||
|
||||
sub validate_CHECKONEDOMAIN {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('OneDomainToCheck')
|
||||
{$ret .= 'Validation for OneDomainToCheck failed';}
|
||||
if (! TRUE) #validate $c->param('OneDomainsCheck')
|
||||
{$ret .= 'Validation for OneDomainsCheck failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE) #validate $c->param('Expiry')
|
||||
{
|
||||
$ret .= 'Validation for Expiry failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('NotBefore')
|
||||
{
|
||||
$ret .= 'Validation for NotBefore failed';
|
||||
}
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub validate_LIST
|
||||
|
||||
sub validate_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (!TRUE) #validate $c->param('status')
|
||||
{
|
||||
$ret .= 'Validation for status failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('hookScript')
|
||||
{
|
||||
$ret .= 'Validation for hookScript failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('hostOverride')
|
||||
{
|
||||
$ret .= 'Validation for hostOverride failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('ACCEPT_TERMS')
|
||||
{
|
||||
$ret .= 'Validation for ACCEPT_TERMS failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('API')
|
||||
{
|
||||
$ret .= 'Validation for API failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('keysize')
|
||||
{
|
||||
$ret .= 'Validation for keysize failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('configure')
|
||||
{
|
||||
$ret .= 'Validation for configure failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('Email')
|
||||
{
|
||||
$ret .= 'Validation for Email failed';
|
||||
}
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub validate_PARAMS
|
||||
|
||||
sub validate_CHECKALLDOMAINS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (!TRUE) #validate $c->param('AllDomainsCheck')
|
||||
{
|
||||
$ret .= 'Validation for AllDomainsCheck failed';
|
||||
}
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub validate_CHECKALLDOMAINS
|
||||
|
||||
sub validate_CHECKALLENABLEDDOMAINS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (!TRUE) #validate $c->param('EnabledDomainsCheck')
|
||||
{
|
||||
$ret .= 'Validation for EnabledDomainsCheck failed';
|
||||
}
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub validate_CHECKALLENABLEDDOMAINS
|
||||
|
||||
sub validate_CHECKONEDOMAIN {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (!TRUE) #validate $c->param('OneDomainToCheck')
|
||||
{
|
||||
$ret .= 'Validation for OneDomainToCheck failed';
|
||||
}
|
||||
|
||||
if (!TRUE) #validate $c->param('OneDomainsCheck')
|
||||
{
|
||||
$ret .= 'Validation for OneDomainsCheck failed';
|
||||
}
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub validate_CHECKONEDOMAIN
|
||||
|
||||
# Get singleton data for each panel
|
||||
sub get_data_for_panel_LIST {
|
||||
|
||||
sub get_data_for_panel_LIST {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
# my ($reply, $err, $server_cert) = Net::SSLeay::sslcat('localhost', 443, '/');
|
||||
# my $issuer = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_issuer_name($server_cert));
|
||||
# my $before = Net::SSLeay::P_ASN1_TIME_get_isotime(Net::SSLeay::X509_get_notBefore($server_cert));
|
||||
# my $expiry = Net::SSLeay::P_ASN1_TIME_get_isotime(Net::SSLeay::X509_get_notAfter($server_cert));
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
|
||||
my %ret = (
|
||||
'Data1'=>'Data for LIST', #Example
|
||||
# fields from Inputs in LIST $fields['LIST']
|
||||
'InternalIP'=>$cdb->get_prop('InternalInterface','IPAddress'),
|
||||
'ExternalIP'=>$cdb->get_prop('ExternalInterface','IPAddress'),
|
||||
'InternetIP'=>$c->get_my_ip(),
|
||||
'Issuer'=>'$issuer',
|
||||
'Expiry'=>'$expiry',
|
||||
'NotBefore'=>'$before',
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
# my ($reply, $err, $server_cert) = Net::SSLeay::sslcat('localhost', 443, '/');
|
||||
# my $issuer = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_issuer_name($server_cert));
|
||||
# my $before = Net::SSLeay::P_ASN1_TIME_get_isotime(Net::SSLeay::X509_get_notBefore($server_cert));
|
||||
# my $expiry = Net::SSLeay::P_ASN1_TIME_get_isotime(Net::SSLeay::X509_get_notAfter($server_cert));
|
||||
my %ret = (
|
||||
'Data1' => 'Data for LIST', #Example
|
||||
# fields from Inputs in LIST $fields['LIST']
|
||||
'InternalIP' => $cdb->get_prop('InternalInterface', 'IPAddress'),
|
||||
'ExternalIP' => $cdb->get_prop('ExternalInterface', 'IPAddress'),
|
||||
'InternetIP' => $c->get_my_ip(),
|
||||
'Issuer' => '$issuer',
|
||||
'Expiry' => '$expiry',
|
||||
'NotBefore' => '$before',
|
||||
);
|
||||
return %ret;
|
||||
} ## end sub get_data_for_panel_LIST
|
||||
|
||||
sub get_data_for_panel_PARAMS {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1'=>'Data for PARAMS', #Example
|
||||
# fields from Inputs in PARAMS $fields['PARAMS']
|
||||
'status'=>$cdb->get_prop('letsencrypt', 'status', 'disabled'),
|
||||
'hookScript'=>$cdb->get_prop('letsencrypt', 'hookScript', 'disabled'),
|
||||
'hostOverride'=>$cdb->get_prop('letsencrypt', 'hostOverride', 'disabled'),
|
||||
'ACCEPT_TERMS'=>$cdb->get_prop('letsencrypt', 'ACCEPT_TERMS', ''),
|
||||
'API'=>$cdb->get_prop('letsencrypt', 'API', '2'),
|
||||
'keysize'=>$cdb->get_prop('letsencrypt', 'keysize', '4096'),
|
||||
'configure'=>$cdb->get_prop('letsencrypt', 'configure', 'none' ),
|
||||
'Email'=>$cdb->get_prop('letsencrypt', 'email')
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
sub get_data_for_panel_PARAMS {
|
||||
|
||||
sub get_data_for_panel_CHECKALLDOMAINS {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1'=>'Data for CHECKALLDOMAINS', #Example
|
||||
# fields from Inputs in CHECKALLDOMAINS $fields['CHECKALLDOMAINS']
|
||||
'AllDomainsCheck'=>'AllDomainsCheck contents',
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1' => 'Data for PARAMS', #Example
|
||||
# fields from Inputs in PARAMS $fields['PARAMS']
|
||||
'status' => $cdb->get_prop('letsencrypt', 'status', 'disabled'),
|
||||
'hookScript' => $cdb->get_prop('letsencrypt', 'hookScript', 'disabled'),
|
||||
'hostOverride' => $cdb->get_prop('letsencrypt', 'hostOverride', 'disabled'),
|
||||
'ACCEPT_TERMS' => $cdb->get_prop('letsencrypt', 'ACCEPT_TERMS', ''),
|
||||
'API' => $cdb->get_prop('letsencrypt', 'API', '2'),
|
||||
'keysize' => $cdb->get_prop('letsencrypt', 'keysize', '4096'),
|
||||
'configure' => $cdb->get_prop('letsencrypt', 'configure', 'none'),
|
||||
'email' => $cdb->get_prop('letsencrypt', 'email')
|
||||
);
|
||||
return %ret;
|
||||
} ## end sub get_data_for_panel_PARAMS
|
||||
|
||||
sub get_data_for_panel_CHECKALLENABLEDDOMAINS {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1'=>'Data for CHECKALLENABLEDDOMAINS', #Example
|
||||
# fields from Inputs in CHECKALLENABLEDDOMAINS $fields['CHECKALLENABLEDDOMAINS']
|
||||
'EnabledDomainsCheck'=>'EnabledDomainsCheck contents',
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
sub get_data_for_panel_CHECKALLDOMAINS {
|
||||
|
||||
sub get_data_for_panel_CHECKONEDOMAIN {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1'=>'Data for CHECKONEDOMAIN', #Example
|
||||
# fields from Inputs in CHECKONEDOMAIN $fields['CHECKONEDOMAIN']
|
||||
'OneDomainToCheck'=>$c->param("CHECKONEDOMAIN"),
|
||||
'OneDomainsCheck'=>'OneDomainsCheck contents',
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1' => 'Data for CHECKALLDOMAINS', #Example
|
||||
# fields from Inputs in CHECKALLDOMAINS $fields['CHECKALLDOMAINS']
|
||||
'AllDomainsCheck' => $c->update_all_domains(),
|
||||
);
|
||||
return %ret;
|
||||
} ## end sub get_data_for_panel_CHECKALLDOMAINS
|
||||
|
||||
sub get_data_for_panel_CHECKALLENABLEDDOMAINS {
|
||||
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1' => 'Data for CHECKALLENABLEDDOMAINS', #Example
|
||||
# fields from Inputs in CHECKALLENABLEDDOMAINS $fields['CHECKALLENABLEDDOMAINS']
|
||||
'EnabledDomainsCheck' => $c->update_enabled_domains(),
|
||||
);
|
||||
return %ret;
|
||||
} ## end sub get_data_for_panel_CHECKALLENABLEDDOMAINS
|
||||
|
||||
sub get_data_for_panel_CHECKONEDOMAIN {
|
||||
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1' => 'Data for CHECKONEDOMAIN', #Example
|
||||
# fields from Inputs in CHECKONEDOMAIN $fields['CHECKONEDOMAIN']
|
||||
'OneDomainToCheck' => $c->param("CHECKONEDOMAIN"),
|
||||
'OneDomainsCheck' => $c->update_one_domain($c->param("CHECKONEDOMAIN"))
|
||||
);
|
||||
return %ret;
|
||||
} ## end sub get_data_for_panel_CHECKONEDOMAIN
|
||||
|
||||
# Get control data for table(s)
|
||||
# Define a constant hash for field name mapping
|
||||
use constant DomainList_FIELD_MAPPING => (
|
||||
'Table1-Domain name / HOSTNAME' => 'Domain',
|
||||
'Table1-Brief description' => 'Description',
|
||||
'Table1-Content' => 'Content',
|
||||
'Table1-LABEL_NAMESERVERS' => 'Nameservers',
|
||||
'Table1-LABEL_POINT' => 'Source-for-Table1-LABEL_POINT',
|
||||
'Table1-LABEL_LECERT' => 'letsencryptSSLcert',
|
||||
'Table1-IS_IN_CERT' => 'isincert',
|
||||
'Table1-CHECK' => 'Check'
|
||||
|
||||
# Define a constant hash for field name mapping
|
||||
use constant DomainList_FIELD_MAPPING => (
|
||||
'Table1-Domain name / HOSTNAME' => 'Domain',
|
||||
'Table1-Brief description' => 'Description',
|
||||
'Table1-Content' => 'Content',
|
||||
'Table1-LABEL_NAMESERVERS' => 'Nameservers',
|
||||
'Table1-LABEL_POINT' => 'Source-for-Table1-LABEL_POINT',
|
||||
'Table1-LABEL_LECERT' => 'letsencryptSSLcert',
|
||||
'Table1-IS_IN_CERT' => 'isincert',
|
||||
'Table1-CHECK' => 'Check'
|
||||
#'target_field2' => 'source_field2',
|
||||
# Add more mappings as needed
|
||||
);
|
||||
|
||||
|
||||
#'target_field2' => 'source_field2',
|
||||
# Add more mappings as needed
|
||||
);
|
||||
use constant TEST_DOMAIN_LIST => (
|
||||
{ "domain" => "Domain1","fred" => "fred1" , "description"=>"Description1"},
|
||||
{ "domain" => "Domain2", "fred" => "fred2", "description"=>"Description2" },
|
||||
{ "domain" => "Domain3", "fred" => "fred3", "description"=>"Description3" },
|
||||
{ "domain" => "Domain1", "fred" => "fred1", "description" => "Description1" },
|
||||
{ "domain" => "Domain2", "fred" => "fred2", "description" => "Description2" },
|
||||
{ "domain" => "Domain3", "fred" => "fred3", "description" => "Description3" },
|
||||
|
||||
# Add more test entries as needed
|
||||
);
|
||||
|
||||
sub actual_DomainList {
|
||||
my $c = shift;
|
||||
# Actual code for extracting DomainList
|
||||
my @list = ();
|
||||
# my @rv = Net::SSLeay::X509_get_subjectAltNames($server_cert);
|
||||
# foreach my $element (@rv) {
|
||||
# next if $element =~ /^\d+$/; ;
|
||||
# #print $element . "\n";
|
||||
# push @list, $element;
|
||||
# }
|
||||
my @data = ();
|
||||
my $check = $c->l('Check Domain');
|
||||
for ($ddb->domains)
|
||||
{
|
||||
my $ns = $_->prop('Nameservers') || 'internet';
|
||||
my $le = $_->prop('letsencryptSSLcert') || 'disabled';#letsencrypt configure all
|
||||
my $dname= $_->key;
|
||||
my $isincert = "N";
|
||||
my $link = $c->create_link("letsencryptd","CHECKONEDOMAIN","");
|
||||
my $checklink = "<a href='".$link."&CHECKONEDOMAIN=".$_->key."'>".$check."</a>";
|
||||
#my $checklink = "<a href=''>check</a>";
|
||||
$isincert = "Y" if ( $dname ~~ @list);
|
||||
# domain
|
||||
push @data,
|
||||
{ Domain => $_->key,
|
||||
$_->props,
|
||||
letsencryptSSLcert => $le,
|
||||
isincert => $isincert,
|
||||
Check => $checklink,
|
||||
Nameservers => $ns,
|
||||
};
|
||||
#and hosts
|
||||
for my $h ($hdb->get_hosts_by_domain($dname))
|
||||
{
|
||||
next if $ddb->get($h->key);
|
||||
next unless ($h->prop('HostType') eq "Self" || $h->prop('HostType') eq "Local");
|
||||
$le = $h->prop('letsencryptSSLcert') || 'disabled';#letsencrypt configure all
|
||||
$isincert = "N";
|
||||
$isincert = "Y" if ( $h->key ~~ @list);
|
||||
push @data,
|
||||
{ Domain => "--> ". $h->key,
|
||||
$h->props,
|
||||
Description=>$h->prop('ExternalIP')|| $h->prop('InternalIP')||"",
|
||||
Content => $h->prop('HostType'),
|
||||
isincert => $isincert,
|
||||
Check => "", #$checklink
|
||||
Nameservers => $c->l($ns),
|
||||
}
|
||||
}
|
||||
}
|
||||
return @data;
|
||||
}
|
||||
my $c = shift;
|
||||
|
||||
# Actual code for extracting DomainList
|
||||
my @list = ();
|
||||
|
||||
# my @rv = Net::SSLeay::X509_get_subjectAltNames($server_cert);
|
||||
# foreach my $element (@rv) {
|
||||
# next if $element =~ /^\d+$/; ;
|
||||
# #print $element . "\n";
|
||||
# push @list, $element;
|
||||
# }
|
||||
my @data = ();
|
||||
my $check = $c->l('Check Domain');
|
||||
|
||||
for ($ddb->domains) {
|
||||
my $ns = $_->prop('Nameservers') || 'internet';
|
||||
my $le = $_->prop('letsencryptSSLcert') || 'disabled'; #letsencrypt configure all
|
||||
my $dname = $_->key;
|
||||
my $isincert = "N";
|
||||
my $link = $c->create_link("letsencryptd", "CHECKONEDOMAIN", "");
|
||||
my $checklink = "<a href='" . $link . "&CHECKONEDOMAIN=" . $_->key . "'>" . $check . "</a>";
|
||||
|
||||
#my $checklink = "<a href=''>check</a>";
|
||||
$isincert = "Y" if ($dname ~~ @list);
|
||||
|
||||
# domain
|
||||
push @data,
|
||||
{
|
||||
Domain => $_->key,
|
||||
$_->props,
|
||||
letsencryptSSLcert => $le,
|
||||
isincert => $isincert,
|
||||
Check => $checklink,
|
||||
Nameservers => $ns,
|
||||
};
|
||||
|
||||
#and hosts
|
||||
for my $h ($hdb->get_hosts_by_domain($dname)) {
|
||||
next if $ddb->get($h->key);
|
||||
next unless ($h->prop('HostType') eq "Self" || $h->prop('HostType') eq "Local");
|
||||
$le = $h->prop('letsencryptSSLcert') || 'disabled'; #letsencrypt configure all
|
||||
$isincert = "N";
|
||||
$isincert = "Y" if ($h->key ~~ @list);
|
||||
push @data, {
|
||||
Domain => "--> " . $h->key,
|
||||
$h->props,
|
||||
Description => $h->prop('ExternalIP') || $h->prop('InternalIP') || "",
|
||||
Content => $h->prop('HostType'),
|
||||
isincert => $isincert,
|
||||
Check => "", #$checklink
|
||||
Nameservers => $c->l($ns),
|
||||
};
|
||||
} ## end for my $h ($hdb->get_hosts_by_domain...)
|
||||
} ## end for ($ddb->domains)
|
||||
return @data;
|
||||
} ## end sub actual_DomainList
|
||||
|
||||
sub get_DomainList {
|
||||
|
||||
# Return an array of hashes of the contents for each row and column for DomainList
|
||||
my $c = shift;
|
||||
my @source_records = $c->actual_DomainList(); #TEST_DOMAIN_LIST #Replace by code or call to produce contents of table;
|
||||
my $c = shift;
|
||||
my @source_records
|
||||
= $c->actual_DomainList(); #TEST_DOMAIN_LIST #Replace by code or call to produce contents of table;
|
||||
my @transformed_records;
|
||||
my %Field_Mapping = DomainList_FIELD_MAPPING;
|
||||
|
||||
# Iterate over each record in the source array
|
||||
for my $source_record (@source_records) {
|
||||
my %transformed_record;
|
||||
|
||||
# Iterate over each key-value pair in the $Field_Mapping constant
|
||||
while (my ($target, $source) = each %Field_Mapping) {
|
||||
|
||||
# Check if the source field exists in the source record
|
||||
if (exists $source_record->{$source}) {
|
||||
|
||||
# Assign the source field value to the target field in the transformed record
|
||||
$transformed_record{$target} = $source_record->{$source};
|
||||
}
|
||||
}
|
||||
} ## end while (my ($target, $source...))
|
||||
|
||||
# Add transformed record to the array if it's not empty
|
||||
push @transformed_records, \%transformed_record if %transformed_record;
|
||||
}
|
||||
} ## end for my $source_record (...)
|
||||
return \@transformed_records;
|
||||
}
|
||||
|
||||
|
||||
} ## end sub get_DomainList
|
||||
|
||||
# Return hash with values from row in which link clicked on table
|
||||
sub get_selected_LIST {
|
||||
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;
|
||||
} ## end sub get_selected_LIST
|
||||
|
||||
sub get_selected_LIST {
|
||||
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_PARAMS {
|
||||
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;
|
||||
} ## end sub get_selected_PARAMS
|
||||
|
||||
sub get_selected_PARAMS {
|
||||
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_CHECKALLDOMAINS {
|
||||
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;
|
||||
} ## end sub get_selected_CHECKALLDOMAINS
|
||||
|
||||
sub get_selected_CHECKALLDOMAINS {
|
||||
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_CHECKALLENABLEDDOMAINS {
|
||||
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_CHECKONEDOMAIN {
|
||||
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_CHECKALLENABLEDDOMAINS {
|
||||
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;
|
||||
} ## end sub get_selected_CHECKALLENABLEDDOMAINS
|
||||
|
||||
sub get_selected_CHECKONEDOMAIN {
|
||||
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;
|
||||
} ## end sub get_selected_CHECKONEDOMAIN
|
||||
|
||||
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
|
||||
sub perform_LIST {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
my $db = $cdb; #maybe one of the others
|
||||
my $dbkey = 'ChangeThis';
|
||||
|
||||
sub perform_LIST {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #copy or perform with value: InternalIP e.g. $c->setprop(dbentry,dbkey,$c->param('InternalIP')
|
||||
{$ret .= 'Perform failed for InternalIP failed';}
|
||||
if (! TRUE) #copy or perform with value: ExternalIP e.g. $c->setprop(dbentry,dbkey,$c->param('ExternalIP')
|
||||
{$ret .= 'Perform failed for ExternalIP failed';}
|
||||
if (! TRUE) #copy or perform with value: InternetIP e.g. $c->setprop(dbentry,dbkey,$c->param('InternetIP')
|
||||
{$ret .= 'Perform failed for InternetIP failed';}
|
||||
if (! TRUE) #copy or perform with value: Issuer e.g. $c->setprop(dbentry,dbkey,$c->param('Issuer')
|
||||
{$ret .= 'Perform failed for Issuer failed';}
|
||||
if (! TRUE) #copy or perform with value: Expiry e.g. $c->setprop(dbentry,dbkey,$c->param('Expiry')
|
||||
{$ret .= 'Perform failed for Expiry failed';}
|
||||
if (! TRUE) #copy or perform with value: NotBefore e.g. $c->setprop(dbentry,dbkey,$c->param('NotBefore')
|
||||
{$ret .= 'Perform failed for NotBefore failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE
|
||||
) #copy or perform with value: InternalIP e.g. $db->set_prop($dbkey,'InternalIP',$c->param('InternalIP'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for InternalIP';
|
||||
} ## end if (!TRUE)
|
||||
|
||||
sub perform_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #copy or perform with value: status e.g. $c->setprop(dbentry,dbkey,$c->param('status')
|
||||
{$ret .= 'Perform failed for status failed';}
|
||||
if (! TRUE) #copy or perform with value: hookScript e.g. $c->setprop(dbentry,dbkey,$c->param('hookScript')
|
||||
{$ret .= 'Perform failed for hookScript failed';}
|
||||
if (! TRUE) #copy or perform with value: hostOverride e.g. $c->setprop(dbentry,dbkey,$c->param('hostOverride')
|
||||
{$ret .= 'Perform failed for hostOverride failed';}
|
||||
if (! TRUE) #copy or perform with value: ACCEPT_TERMS e.g. $c->setprop(dbentry,dbkey,$c->param('ACCEPT_TERMS')
|
||||
{$ret .= 'Perform failed for ACCEPT_TERMS failed';}
|
||||
if (! TRUE) #copy or perform with value: API e.g. $c->setprop(dbentry,dbkey,$c->param('API')
|
||||
{$ret .= 'Perform failed for API failed';}
|
||||
if (! TRUE) #copy or perform with value: keysize e.g. $c->setprop(dbentry,dbkey,$c->param('keysize')
|
||||
{$ret .= 'Perform failed for keysize failed';}
|
||||
if (! TRUE) #copy or perform with value: configure e.g. $c->setprop(dbentry,dbkey,$c->param('configure')
|
||||
{$ret .= 'Perform failed for configure failed';}
|
||||
if (! TRUE) #copy or perform with value: Email e.g. $c->setprop(dbentry,dbkey,$c->param('Email')
|
||||
{$ret .= 'Perform failed for Email failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE
|
||||
) #copy or perform with value: ExternalIP e.g. $db->set_prop($dbkey,'ExternalIP',$c->param('ExternalIP'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for ExternalIP';
|
||||
} ## end if (!TRUE)
|
||||
|
||||
sub perform_CHECKALLDOMAINS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #copy or perform with value: AllDomainsCheck e.g. $c->setprop(dbentry,dbkey,$c->param('AllDomainsCheck')
|
||||
{$ret .= 'Perform failed for AllDomainsCheck failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE
|
||||
) #copy or perform with value: InternetIP e.g. $db->set_prop($dbkey,'InternetIP',$c->param('InternetIP'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for InternetIP';
|
||||
} ## end if (!TRUE)
|
||||
|
||||
sub perform_CHECKALLENABLEDDOMAINS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #copy or perform with value: EnabledDomainsCheck e.g. $c->setprop(dbentry,dbkey,$c->param('EnabledDomainsCheck')
|
||||
{$ret .= 'Perform failed for EnabledDomainsCheck failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE
|
||||
) #copy or perform with value: Issuer e.g. $db->set_prop($dbkey,'Issuer',$c->param('Issuer'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for Issuer';
|
||||
} ## end if (!TRUE)
|
||||
|
||||
sub perform_CHECKONEDOMAIN {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #copy or perform with value: OneDomainToCheck e.g. $c->setprop(dbentry,dbkey,$c->param('OneDomainToCheck')
|
||||
{$ret .= 'Perform failed for OneDomainToCheck failed';}
|
||||
if (! TRUE) #copy or perform with value: OneDomainsCheck e.g. $c->setprop(dbentry,dbkey,$c->param('OneDomainsCheck')
|
||||
{$ret .= 'Perform failed for OneDomainsCheck failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
if (!TRUE
|
||||
) #copy or perform with value: Expiry e.g. $db->set_prop($dbkey,'Expiry',$c->param('Expiry'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for Expiry';
|
||||
} ## end if (!TRUE)
|
||||
|
||||
if (!TRUE
|
||||
) #copy or perform with value: NotBefore e.g. $db->set_prop($dbkey,'NotBefore',$c->param('NotBefore'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for NotBefore';
|
||||
} ## end if (!TRUE)
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub perform_LIST
|
||||
|
||||
sub create_link{
|
||||
# WIP
|
||||
my ($c,$route, $panel, $index) = @_;
|
||||
my $link = "$route?trt=$panel&Selected=$index";
|
||||
return $link;
|
||||
}
|
||||
sub perform_PARAMS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
my $db = $cdb; #maybe one of the others
|
||||
my $dbkey = 'letsencrypt';
|
||||
|
||||
sub get_my_ip
|
||||
{
|
||||
# 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, 'status', $c->param('status'), type => 'service')) {
|
||||
$ret .= 'Perform/save failed for status';
|
||||
}
|
||||
|
||||
if (!$db->set_prop($dbkey, 'hookScript', $c->param('hookScript'), type => 'service')) {
|
||||
$ret .= 'Perform/save failed for hookScript';
|
||||
}
|
||||
|
||||
if (!$db->set_prop($dbkey, 'hostOverride', $c->param('hostOverride'), type => 'service')) {
|
||||
$ret .= 'Perform/save failed for hostOverride';
|
||||
}
|
||||
|
||||
if (!$db->set_prop($dbkey, 'ACCEPT_TERMS', $c->param('ACCEPT_TERMS'), type => 'service')) {
|
||||
$ret .= 'Perform/save failed for ACCEPT_TERMS';
|
||||
}
|
||||
if (!$db->set_prop($dbkey, 'API', $c->param('API'), type => 'service')) { $ret .= 'Perform/save failed for API'; }
|
||||
|
||||
if (!$db->set_prop($dbkey, 'keysize', $c->param('keysize'), type => 'service')) {
|
||||
$ret .= 'Perform/save failed for keysize';
|
||||
}
|
||||
|
||||
if (!$db->set_prop($dbkey, 'configure', $c->param('configure'), type => 'service')) {
|
||||
$ret .= 'Perform/save failed for configure';
|
||||
}
|
||||
|
||||
if (!$db->set_prop($dbkey, 'email', $c->param('email'), type => 'service')) {
|
||||
$ret .= 'Perform/save failed for email';
|
||||
}
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub perform_PARAMS
|
||||
|
||||
sub perform_CHECKALLDOMAINS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
my $db = $cdb; #maybe one of the others
|
||||
my $dbkey = 'ChangeThis';
|
||||
|
||||
if (!TRUE
|
||||
) #copy or perform with value: AllDomainsCheck e.g. $db->set_prop($dbkey,'AllDomainsCheck',$c->param('AllDomainsCheck'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for AllDomainsCheck';
|
||||
} ## end if (!TRUE)
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub perform_CHECKALLDOMAINS
|
||||
|
||||
sub perform_CHECKALLENABLEDDOMAINS {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
my $db = $cdb; #maybe one of the others
|
||||
my $dbkey = 'ChangeThis';
|
||||
|
||||
if (!TRUE
|
||||
) #copy or perform with value: EnabledDomainsCheck e.g. $db->set_prop($dbkey,'EnabledDomainsCheck',$c->param('EnabledDomainsCheck'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for EnabledDomainsCheck';
|
||||
} ## end if (!TRUE)
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub perform_CHECKALLENABLEDDOMAINS
|
||||
|
||||
sub perform_CHECKONEDOMAIN {
|
||||
my $c = shift;
|
||||
my $prefix_data = shift; #Data hash as parameter
|
||||
my $ret = "";
|
||||
my $db = $cdb; #maybe one of the others
|
||||
my $dbkey = 'ChangeThis';
|
||||
|
||||
if (!TRUE
|
||||
) #copy or perform with value: OneDomainToCheck e.g. $db->set_prop($dbkey,'OneDomainToCheck',$c->param('OneDomainToCheck'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for OneDomainToCheck';
|
||||
} ## end if (!TRUE)
|
||||
|
||||
if (!TRUE
|
||||
) #copy or perform with value: OneDomainsCheck e.g. $db->set_prop($dbkey,'OneDomainsCheck',$c->param('OneDomainsCheck'),type=>'service'))
|
||||
{
|
||||
$ret .= 'Perform/save failed for OneDomainsCheck';
|
||||
} ## end if (!TRUE)
|
||||
if ($ret eq "") { $ret = 'ok'; }
|
||||
return $ret;
|
||||
} ## end sub perform_CHECKONEDOMAIN
|
||||
|
||||
sub create_link {
|
||||
|
||||
# WIP
|
||||
my ($c, $route, $panel, $index) = @_;
|
||||
my $link = "$route?trt=$panel&Selected=$index";
|
||||
return $link;
|
||||
} ## end sub create_link
|
||||
|
||||
sub get_my_ip {
|
||||
my ($self, $item, $prop, $default) = @_;
|
||||
my $output = `/usr/sbin/e-smith/getmyip`;
|
||||
return $output || "IP";
|
||||
}
|
||||
return $output || "IP";
|
||||
} ## end sub get_my_ip
|
||||
|
||||
sub update_one_domain {
|
||||
my ($self, $domain) = @_;
|
||||
return "$domain not domain" unless ($ddb->get($domain) || $hdb->get($domain));
|
||||
($domain) = ($domain =~ /([\w\p{L}.]+)/);
|
||||
my $output = `/etc/e-smith/events/actions/letsencrypt-setdomains " " $domain `;
|
||||
return $output || "-empty-";
|
||||
} ## end sub update_one_domain
|
||||
|
||||
sub update_all_domains {
|
||||
my $self = shift;
|
||||
my $output = `/etc/e-smith/events/actions/letsencrypt-setdomains "" "" all `;
|
||||
return $output || "-empty-";
|
||||
} ## end sub update_all_domains
|
||||
|
||||
sub update_enabled_domains {
|
||||
my $self = shift;
|
||||
my $output = `/etc/e-smith/events/actions/letsencrypt-setdomains "" "" enabled `;
|
||||
return $output || "-empty-";
|
||||
} ## end sub update_enabled_domains
|
||||
1;
|
728
Targets/Letsencrypt/Letsencrypt.pm
Normal file → Executable file
728
Targets/Letsencrypt/Letsencrypt.pm
Normal file → Executable file
@@ -1,6 +1,6 @@
|
||||
package SrvMngr::Controller::Letsencrypt;
|
||||
#
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-01 15:22:43
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Network
|
||||
@@ -15,25 +15,19 @@ package SrvMngr::Controller::Letsencrypt;
|
||||
#
|
||||
# Documentation: https://wiki.contribs.org/Letsencrypt
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# 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;
|
||||
@@ -41,390 +35,414 @@ use esmith::AccountsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::DomainsDB;
|
||||
|
||||
|
||||
|
||||
require '/usr/share/smanager/lib/SrvMngr/Controller/Letsencrypt-Custom.pm'; #The code that is to be added by the developer
|
||||
require
|
||||
'/usr/share/smanager/lib/SrvMngr/Controller/Letsencrypt-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
|
||||
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
my %lets_data = ();
|
||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||
my $modul = '';
|
||||
|
||||
$lets_data{'trt'} = 'LIST';
|
||||
|
||||
#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($lets_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
|
||||
|
||||
#
|
||||
# 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);
|
||||
my $modul = '';
|
||||
|
||||
#The most common ones - you might want to comment out any not used.
|
||||
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
#The most common ones
|
||||
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
my %lets_data = ();
|
||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||
my $modul = '';
|
||||
$lets_data{'trt'} = 'LIST';
|
||||
|
||||
# Accessing all POST parameters
|
||||
#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($lets_data{'trt'});
|
||||
} ## end sub main
|
||||
|
||||
# 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.
|
||||
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
my %lets_data = ();
|
||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||
|
||||
# Accessing all POST parameters
|
||||
my %params = $c->req->params->to_hash;
|
||||
|
||||
# Get number of POST parameters
|
||||
my $num_params = keys %params;
|
||||
|
||||
|
||||
#Params are available in the hash "params" - copy to the prefix_data hash
|
||||
#while (my ($key, $value) = each %{$c->req->params->to_hash}) {
|
||||
# $lets_data{$key} = $value;
|
||||
#}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'LIST'; #hidden control on every form.
|
||||
# the value of trt will tell you which panel has returned
|
||||
my $trt = $c->param('trt') || 'LIST'; #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 'LIST'){
|
||||
#Validate form parameters for panel LIST
|
||||
$ret = $c->validate_LIST(\%lets_data);
|
||||
$thispanel = 'LIST';
|
||||
}
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#Validate form parameters for panel PARAMS
|
||||
$ret = $c->validate_PARAMS(\%lets_data);
|
||||
$thispanel = 'PARAMS';
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKALLDOMAINS'){
|
||||
#Validate form parameters for panel CHECKALLDOMAINS
|
||||
$ret = $c->validate_CHECKALLDOMAINS(\%lets_data);
|
||||
$thispanel = 'CHECKALLDOMAINS';
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKALLENABLEDDOMAINS'){
|
||||
#Validate form parameters for panel CHECKALLENABLEDDOMAINS
|
||||
$ret = $c->validate_CHECKALLENABLEDDOMAINS(\%lets_data);
|
||||
$thispanel = 'CHECKALLENABLEDDOMAINS';
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKONEDOMAIN'){
|
||||
#Validate form parameters for panel CHECKONEDOMAIN
|
||||
$ret = $c->validate_CHECKONEDOMAIN(\%lets_data);
|
||||
$thispanel = 'CHECKONEDOMAIN';
|
||||
}
|
||||
|
||||
|
||||
if ($ret ne "ok"){
|
||||
$c->do_display($thispanel);
|
||||
} else {
|
||||
#Do whatever is needed, including writing values to the DB
|
||||
|
||||
if ($trt eq 'LIST'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_LIST(\%lets_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash( success => $c->l('lets_LIST_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_PARAMS(\%lets_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash( success => $c->l('lets_PARAMS_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKALLDOMAINS'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_CHECKALLDOMAINS(\%lets_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash( success => $c->l('lets_CHECKALLDOMAINS_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKALLENABLEDDOMAINS'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_CHECKALLENABLEDDOMAINS(\%lets_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash( success => $c->l('lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKONEDOMAIN'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_CHECKONEDOMAIN(\%lets_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash( success => $c->l('lets_CHECKONEDOMAIN_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') {
|
||||
$lets_data{'trt'} = 'LIST';
|
||||
} else {
|
||||
$lets_data{'trt'} = 'none';
|
||||
}
|
||||
$c->do_display($lets_data{'trt'});
|
||||
|
||||
}
|
||||
}
|
||||
if ($trt eq 'LIST') {
|
||||
|
||||
#Validate form parameters for panel LIST
|
||||
$ret = $c->validate_LIST(\%lets_data);
|
||||
$thispanel = 'LIST';
|
||||
} ## end if ($trt eq 'LIST')
|
||||
|
||||
if ($trt eq 'PARAMS') {
|
||||
|
||||
#Validate form parameters for panel PARAMS
|
||||
$ret = $c->validate_PARAMS(\%lets_data);
|
||||
$thispanel = 'PARAMS';
|
||||
} ## end if ($trt eq 'PARAMS')
|
||||
|
||||
if ($trt eq 'CHECKALLDOMAINS') {
|
||||
|
||||
#Validate form parameters for panel CHECKALLDOMAINS
|
||||
$ret = $c->validate_CHECKALLDOMAINS(\%lets_data);
|
||||
$thispanel = 'CHECKALLDOMAINS';
|
||||
} ## end if ($trt eq 'CHECKALLDOMAINS')
|
||||
|
||||
if ($trt eq 'CHECKALLENABLEDDOMAINS') {
|
||||
|
||||
#Validate form parameters for panel CHECKALLENABLEDDOMAINS
|
||||
$ret = $c->validate_CHECKALLENABLEDDOMAINS(\%lets_data);
|
||||
$thispanel = 'CHECKALLENABLEDDOMAINS';
|
||||
} ## end if ($trt eq 'CHECKALLENABLEDDOMAINS')
|
||||
|
||||
if ($trt eq 'CHECKONEDOMAIN') {
|
||||
|
||||
#Validate form parameters for panel CHECKONEDOMAIN
|
||||
$ret = $c->validate_CHECKONEDOMAIN(\%lets_data);
|
||||
$thispanel = 'CHECKONEDOMAIN';
|
||||
} ## end if ($trt eq 'CHECKONEDOMAIN')
|
||||
|
||||
if ($ret ne "ok") {
|
||||
$c->do_display($thispanel);
|
||||
} else {
|
||||
|
||||
#Do whatever is needed, including writing values to the DB
|
||||
if ($trt eq 'LIST') {
|
||||
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_LIST(\%lets_data);
|
||||
|
||||
if ($ret ne "ok") {
|
||||
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash(success => $c->l('lets_LIST_panel_action_was_successful'))
|
||||
; #A bit bland - edit it in the lex file
|
||||
}
|
||||
} ## end if ($trt eq 'LIST')
|
||||
|
||||
if ($trt eq 'PARAMS') {
|
||||
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_PARAMS(\%lets_data);
|
||||
|
||||
if ($ret ne "ok") {
|
||||
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash(success => $c->l('lets_PARAMS_panel_action_was_successful'))
|
||||
; #A bit bland - edit it in the lex file
|
||||
}
|
||||
} ## end if ($trt eq 'PARAMS')
|
||||
|
||||
if ($trt eq 'CHECKALLDOMAINS') {
|
||||
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_CHECKALLDOMAINS(\%lets_data);
|
||||
|
||||
if ($ret ne "ok") {
|
||||
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash(success => $c->l('lets_CHECKALLDOMAINS_panel_action_was_successful'))
|
||||
; #A bit bland - edit it in the lex file
|
||||
}
|
||||
} ## end if ($trt eq 'CHECKALLDOMAINS')
|
||||
|
||||
if ($trt eq 'CHECKALLENABLEDDOMAINS') {
|
||||
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_CHECKALLENABLEDDOMAINS(\%lets_data);
|
||||
|
||||
if ($ret ne "ok") {
|
||||
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash(success => $c->l('lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful'))
|
||||
; #A bit bland - edit it in the lex file
|
||||
}
|
||||
} ## end if ($trt eq 'CHECKALLENABLEDDOMAINS')
|
||||
|
||||
if ($trt eq 'CHECKONEDOMAIN') {
|
||||
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_CHECKONEDOMAIN(\%lets_data);
|
||||
|
||||
if ($ret ne "ok") {
|
||||
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} else {
|
||||
$c->stash(success => $c->l('lets_CHECKONEDOMAIN_panel_action_was_successful'))
|
||||
; #A bit bland - edit it in the lex file
|
||||
}
|
||||
} ## end if ($trt eq 'CHECKONEDOMAIN')
|
||||
|
||||
# and call any signal-events needed
|
||||
#TBD
|
||||
# Setup shared data and call panel
|
||||
if ('none' eq 'none') {
|
||||
$lets_data{'trt'} = 'LIST';
|
||||
} else {
|
||||
$lets_data{'trt'} = 'none';
|
||||
}
|
||||
$c->do_display($lets_data{'trt'});
|
||||
} ## end else [ if ($ret ne "ok") ]
|
||||
} ## end sub do_update
|
||||
|
||||
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) = @_;
|
||||
#
|
||||
# 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.
|
||||
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
|
||||
#The most common ones - you might want to comment out any not used.
|
||||
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||
my %lets_data = ();
|
||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||
my $modul = "";
|
||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||
my $modul = "";
|
||||
|
||||
# Accessing all parameters
|
||||
my %params = $c->req->params->to_hash;
|
||||
# Accessing all parameters
|
||||
my $params = $c->req->params->to_hash;
|
||||
|
||||
# Get number of parameters
|
||||
my $num_params = keys %params;
|
||||
|
||||
my $num_params = scalar 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}) {
|
||||
# $lets_data{$key} = $value;
|
||||
#}
|
||||
# the value of trt will tell you which panel has returned
|
||||
if (!$trt) {
|
||||
$trt = $c->param('trt') || 'LIST'; #Indicates where to go now
|
||||
}
|
||||
|
||||
# the value of trt will tell you which panel has returned
|
||||
if (! $trt){
|
||||
$trt = $c->param('trt') || 'LIST'; #Indicates where to go now
|
||||
}
|
||||
|
||||
# Now add in the params from the selected row from the table
|
||||
|
||||
my %selectedrow;
|
||||
|
||||
if ($trt eq 'LIST'){
|
||||
#Validate Get selected row (if applicable) LIST
|
||||
%selectedrow = $c->get_selected_LIST($lets_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
#Validate Get selected row (if applicable) PARAMS
|
||||
%selectedrow = $c->get_selected_PARAMS($lets_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKALLDOMAINS'){
|
||||
#Validate Get selected row (if applicable) CHECKALLDOMAINS
|
||||
%selectedrow = $c->get_selected_CHECKALLDOMAINS($lets_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKALLENABLEDDOMAINS'){
|
||||
#Validate Get selected row (if applicable) CHECKALLENABLEDDOMAINS
|
||||
%selectedrow = $c->get_selected_CHECKALLENABLEDDOMAINS($lets_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKONEDOMAIN'){
|
||||
#Validate Get selected row (if applicable) CHECKONEDOMAIN
|
||||
%selectedrow = $c->get_selected_CHECKONEDOMAIN($lets_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){
|
||||
|
||||
if ($trt eq 'LIST') {
|
||||
|
||||
#Validate Get selected row (if applicable) LIST
|
||||
%selectedrow = $c->get_selected_LIST($lets_data{'Selected'}, $is_new_record);
|
||||
} ## end if ($trt eq 'LIST')
|
||||
|
||||
if ($trt eq 'PARAMS') {
|
||||
|
||||
#Validate Get selected row (if applicable) PARAMS
|
||||
%selectedrow = $c->get_selected_PARAMS($lets_data{'Selected'}, $is_new_record);
|
||||
} ## end if ($trt eq 'PARAMS')
|
||||
|
||||
if ($trt eq 'CHECKALLDOMAINS') {
|
||||
|
||||
#Validate Get selected row (if applicable) CHECKALLDOMAINS
|
||||
%selectedrow = $c->get_selected_CHECKALLDOMAINS($lets_data{'Selected'}, $is_new_record);
|
||||
} ## end if ($trt eq 'CHECKALLDOMAINS')
|
||||
|
||||
if ($trt eq 'CHECKALLENABLEDDOMAINS') {
|
||||
|
||||
#Validate Get selected row (if applicable) CHECKALLENABLEDDOMAINS
|
||||
%selectedrow = $c->get_selected_CHECKALLENABLEDDOMAINS($lets_data{'Selected'}, $is_new_record);
|
||||
} ## end if ($trt eq 'CHECKALLENABLEDDOMAINS')
|
||||
|
||||
if ($trt eq 'CHECKONEDOMAIN') {
|
||||
|
||||
#Validate Get selected row (if applicable) CHECKONEDOMAIN
|
||||
%selectedrow = $c->get_selected_CHECKONEDOMAIN($lets_data{'Selected'}, $is_new_record);
|
||||
} ## end if ($trt eq 'CHECKONEDOMAIN')
|
||||
|
||||
#Copy in the selected row params to the prefix_data hash to pass to the panel
|
||||
while (my ($key, $value) = each %selectedrow) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
# Where to go now
|
||||
$lets_data{'trt'} = $trt;
|
||||
|
||||
# Set up other shared data according to the panel to go to
|
||||
|
||||
if ($trt eq 'LIST'){
|
||||
# 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_LIST();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'PARAMS'){
|
||||
# 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_PARAMS();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKALLDOMAINS'){
|
||||
# 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_CHECKALLDOMAINS();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKALLENABLEDDOMAINS'){
|
||||
# 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_CHECKALLENABLEDDOMAINS();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'CHECKONEDOMAIN'){
|
||||
# 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_CHECKONEDOMAIN();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# and table control fields
|
||||
$c->stash(DomainList=>$c->get_DomainList());
|
||||
|
||||
|
||||
# Data for panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
}
|
||||
|
||||
# Where to go now
|
||||
$lets_data{'trt'} = $trt;
|
||||
|
||||
# Set up other shared data according to the panel to go to
|
||||
if ($trt eq 'LIST') {
|
||||
|
||||
# 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_LIST();
|
||||
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
} ## end if ($trt eq 'LIST')
|
||||
|
||||
if ($trt eq 'PARAMS') {
|
||||
|
||||
# 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_PARAMS();
|
||||
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
} ## end if ($trt eq 'PARAMS')
|
||||
|
||||
if ($trt eq 'CHECKALLDOMAINS') {
|
||||
|
||||
# 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_CHECKALLDOMAINS();
|
||||
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
} ## end if ($trt eq 'CHECKALLDOMAINS')
|
||||
|
||||
if ($trt eq 'CHECKALLENABLEDDOMAINS') {
|
||||
|
||||
# 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_CHECKALLENABLEDDOMAINS();
|
||||
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
} ## end if ($trt eq 'CHECKALLENABLEDDOMAINS')
|
||||
|
||||
if ($trt eq 'CHECKONEDOMAIN') {
|
||||
|
||||
# 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_CHECKONEDOMAIN();
|
||||
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$lets_data{$key} = $value;
|
||||
}
|
||||
} ## end if ($trt eq 'CHECKONEDOMAIN')
|
||||
|
||||
# and table control fields
|
||||
$c->stash(DomainList => $c->get_DomainList());
|
||||
|
||||
# Data for panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
lets_data => \%lets_data
|
||||
);
|
||||
$c->render(template => "letsencrypt");
|
||||
} ## end sub do_display
|
||||
1;
|
2
Targets/Letsencrypt/_lets_CHECKALLDOMAINS.html.ep
Normal file → Executable file
2
Targets/Letsencrypt/_lets_CHECKALLDOMAINS.html.ep
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-09 17:25:37
|
||||
%#
|
||||
<div id="Letsencrypt-CHECKALLDOMAINS" class="partial Letsencrypt-CHECKALLDOMAINS">
|
||||
<script>
|
||||
|
2
Targets/Letsencrypt/_lets_CHECKALLENABLEDDOMAINS.html.ep
Normal file → Executable file
2
Targets/Letsencrypt/_lets_CHECKALLENABLEDDOMAINS.html.ep
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-09 17:25:37
|
||||
%#
|
||||
<div id="Letsencrypt-CHECKALLENABLEDDOMAINS" class="partial Letsencrypt-CHECKALLENABLEDDOMAINS">
|
||||
<script>
|
||||
|
4
Targets/Letsencrypt/_lets_CHECKONEDOMAIN.html.ep
Normal file → Executable file
4
Targets/Letsencrypt/_lets_CHECKONEDOMAIN.html.ep
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-09 17:25:37
|
||||
%#
|
||||
<div id="Letsencrypt-CHECKONEDOMAIN" class="partial Letsencrypt-CHECKONEDOMAIN">
|
||||
<script>
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<h1 class='head'><%=l('lets_Check_just_one_domain')%></h1>
|
||||
|
||||
<h2 class='subh'><%=l('lets_Loop_through_checking_the_letsencrypt')%></h2>
|
||||
<h2 class='subh'><%=l('lets_Loop_through_and_check_the')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('lets_Domains_name')
|
||||
|
8
Targets/Letsencrypt/_lets_LIST.html.ep
Normal file → Executable file
8
Targets/Letsencrypt/_lets_LIST.html.ep
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-09 17:25:37
|
||||
%#
|
||||
<div id="Letsencrypt-LIST" class="partial Letsencrypt-LIST">
|
||||
<script>
|
||||
@@ -67,12 +67,12 @@
|
||||
|
||||
<h2 class='subh3'><%=l('lets_Current_certificate_details')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
<span class=label>
|
||||
%=l('lets_Issuer')
|
||||
</span><span class=data>
|
||||
% param 'Issuer' => $lets_data->{Issuer} unless param 'Issuer';
|
||||
%= text_field 'Issuer', size => '50', class => 'textinput Issuer' , pattern=>'.*' , placeholder=>'Issuer', Readonly=>'true'
|
||||
<br></span></p>
|
||||
%= text_area 'Issuer', cols=>40, rows=>10, Readonly=>'true'
|
||||
</span><br>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('lets_Expiry')
|
||||
|
11
Targets/Letsencrypt/_lets_PARAMS.html.ep
Normal file → Executable file
11
Targets/Letsencrypt/_lets_PARAMS.html.ep
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-09 17:25:37
|
||||
%#
|
||||
<div id="Letsencrypt-PARAMS" class="partial Letsencrypt-PARAMS">
|
||||
<script>
|
||||
@@ -83,8 +83,8 @@
|
||||
<p><span class=label>
|
||||
%=l('lets_EMAIL')
|
||||
</span><span class=data>
|
||||
% param 'Email' => $lets_data->{Email} unless param 'Email';
|
||||
%=email_field 'Email', class => 'emai8'
|
||||
% param 'email' => $lets_data->{email} unless param 'email';
|
||||
%=email_field 'email', class => 'emai8'
|
||||
</span></p>
|
||||
|
||||
|
||||
@@ -92,11 +92,6 @@
|
||||
%= submit_button l('lets_Save'), class => 'action subm9'
|
||||
</span>
|
||||
|
||||
<span class='data'>
|
||||
%= submit_button l('lets_Back'), class => 'action back', onclick =>'history.back()'
|
||||
</span>
|
||||
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
6
Targets/Letsencrypt/letsencrypt.css
Normal file → Executable file
6
Targets/Letsencrypt/letsencrypt.css
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-17 14:48:52
|
||||
Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-01 15:22:43
|
||||
*/
|
||||
.Letsencrypt-panel {}
|
||||
.name {}
|
||||
@@ -34,7 +34,6 @@ tbody .tabl1 {}
|
||||
.sele7 {}
|
||||
.emai8 {}
|
||||
.subm9 {}
|
||||
.back10 {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.head {}
|
||||
@@ -54,7 +53,6 @@ tbody .tabl1 {}
|
||||
.read1 {}
|
||||
.text2 {}
|
||||
.back3 {}
|
||||
|
||||
.inline-buttons {
|
||||
display: flex; /* Use flexbox to arrange items horizontally */
|
||||
gap: 10px; /* Optional: Add space between buttons */
|
||||
@@ -89,4 +87,4 @@ tbody .tabl1 {}
|
||||
|
||||
span .label {
|
||||
padding-top:13em;
|
||||
}
|
||||
}
|
||||
|
4
Targets/Letsencrypt/letsencrypt.html.ep
Normal file → Executable file
4
Targets/Letsencrypt/letsencrypt.html.ep
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-09 17:25:37
|
||||
%#
|
||||
% layout 'default', title => "Sme server 2 - Letsencrypt certificate", share_dir => './';
|
||||
%# css specific to this panel:
|
||||
@@ -26,7 +26,7 @@
|
||||
</p>
|
||||
|
||||
%} elsif ($c->stash('success')) {
|
||||
<div class='sme-border'>
|
||||
<div class='success '>
|
||||
<h2><%=$c->l('lets_Status_Report') %></h2><p>
|
||||
%= $c->l($c->stash('success'));
|
||||
</p>
|
||||
|
84
Targets/Letsencrypt/letsencrypt_en.lex
Normal file → Executable file
84
Targets/Letsencrypt/letsencrypt_en.lex
Normal file → Executable file
@@ -1,52 +1,54 @@
|
||||
#
|
||||
# Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-17 14:48:52
|
||||
# Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-12-09 17:25:37
|
||||
#
|
||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for a specific domain',
|
||||
'lets_Brief_description' => 'Brief description',
|
||||
'lets_Expiry' => 'Expiry',
|
||||
'lets_EMAIL' => 'Email',
|
||||
'lets_One_domain_check_result' => 'One domain check result',
|
||||
'lets_Current_certificate_details' => 'Current certificate details',
|
||||
'lets_LABEL_POINT' => 'Label Point',
|
||||
'lets_IS_IN_CERT' => 'Is In cart',
|
||||
'lets_LABEL_LECERT' => 'Label secret',
|
||||
'lets_Enabled_domains_check_result' => 'Enabled domains check result',
|
||||
'lets_Letsencrypt_certificate' => 'Letsencrypt certificate',
|
||||
'lets_Check_all_domains' => 'Check all domains',
|
||||
'lets_Domain_name_/_HOSTNAME' => 'Domain name / HOSTNAME',
|
||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain which is enabled',
|
||||
'lets_CHECK_ALL_ENABLED_DOMAINS' => 'Check All Enabled Domains',
|
||||
'lets_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
||||
'lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful' => 'CHECKALLENABLEDDOMAINS panel action was successful',
|
||||
'lets_HOOKSCRIPT_STATUS' => 'Hookscript Status',
|
||||
'lets_List_of_Domains_and_Hosts' => 'List of Domains and Hosts',
|
||||
'lets_Save' => 'Save',
|
||||
'lets_Internal_IP' => 'Internal IP',
|
||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain',
|
||||
'lets_Internet_IP' => 'Internet IP',
|
||||
'lets_Status_Report' => 'Status Report',
|
||||
'lets_Current_certificate_details' => 'Current certificate details',
|
||||
'lets_SERVICE_STATUS' => 'Service Status',
|
||||
'lets_ACCEPT_TERMS_STATUS' => 'Accept Terms Status',
|
||||
'lets_HOOKSCRIPT_STATUS' => 'Hookscript Status',
|
||||
'lets_EMAIL' => 'Email',
|
||||
'lets_Brief_description' => 'Brief description',
|
||||
'lets_KEYSIZE_STATUS' => 'Keysize Status',
|
||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain',
|
||||
'lets_LABEL_NAMESERVERS' => 'Label timeservers',
|
||||
'lets_CHECKALLDOMAINS_panel_action_was_successful' => 'CHECKALLDOMAINS panel action was successful',
|
||||
'lets_Letsencrypt_certificate' => 'Letsencrypt certificate',
|
||||
'lets_APPLY' => 'Apply',
|
||||
'lets_All_domains_check_result' => 'All domains check result',
|
||||
'lets_API_STATUS' => 'ape Status',
|
||||
'lets_External_Interface_IP' => 'External Interface IP',
|
||||
'lets_CHECK' => 'Check',
|
||||
'lets_Check_just_one_domain' => 'Check just one domain',
|
||||
'lets_External_Interface_IP' => 'External Interface IP',
|
||||
'lets_Not_Before' => 'Not Before',
|
||||
'lets_Content' => 'Content',
|
||||
'lets_All_domains_check_result' => 'All domains check result',
|
||||
'lets_LIST_panel_action_was_successful' => 'LIST panel action was successful',
|
||||
'lets_CONFIGUREMODE_STATUS' => 'Configuremode Status',
|
||||
'lets_CONFIG_LETSENCRYPT' => 'confirm Letsencrypt',
|
||||
'lets_CHECKONEDOMAIN_panel_action_was_successful' => 'CHECKONEDOMAIN panel action was successful',
|
||||
'lets_LABEL_NAMESERVERS' => 'Label timeservers',
|
||||
'lets_CHECK_ALL_DOMAINS' => 'Check All Domains',
|
||||
'lets_HOSTOVERRIDE_STATUS' => 'Hostoverride Status',
|
||||
'lets_API_STATUS' => 'ape Status',
|
||||
'lets_APPLY' => 'Apply',
|
||||
'lets_Check_all_enabled_domains' => 'Check all enabled domains',
|
||||
'lets_KEYSIZE_STATUS' => 'Keysize Status',
|
||||
'lets_Issuer' => 'Issuer',
|
||||
'lets_Domains_name' => 'Domains name',
|
||||
'lets_One_domain_check_result' => 'One domain check result',
|
||||
'lets_LABEL_LECERT' => 'Label secret',
|
||||
'lets_Internet_IP' => 'Internet IP',
|
||||
'lets_CONFIG' => 'Config',
|
||||
'lets_CHECKALLDOMAINS_panel_action_was_successful' => 'CHECKALLDOMAINS panel action was successful',
|
||||
'lets_Check_all_enabled_domains' => 'Check all enabled domains',
|
||||
'lets_Issuer' => 'Issuer',
|
||||
'lets_CHECKONEDOMAIN_panel_action_was_successful' => 'CHECKONEDOMAIN panel action was successful',
|
||||
'lets_CONFIG_LETSENCRYPT' => 'confirm Letsencrypt',
|
||||
'lets_Content' => 'Content',
|
||||
'lets_Check_all_domains' => 'Check all domains',
|
||||
'lets_HOSTOVERRIDE_STATUS' => 'Hostoverride Status',
|
||||
'lets_Internal_IP' => 'Internal IP',
|
||||
'lets_Back' => 'Back',
|
||||
'lets_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
||||
'lets_Expiry' => 'Expiry',
|
||||
'lets_Error_Status_Report' => 'Error Status Report',
|
||||
'lets_For_this_Server' => 'For this Server',
|
||||
'lets_List_of_Domains_and_Hosts' => 'List of Domains and Hosts',
|
||||
'lets_Loop_through_and_check_the' => 'Loop through and check the letsencrypt status for a specific domain',
|
||||
'lets_CHECK_ALL_DOMAINS' => 'Check All Domains',
|
||||
'lets_IS_IN_CERT' => 'Is In cart',
|
||||
'lets_Manage_letsencrypt-config_settings:' => 'Manage letsencrypt-config settings',
|
||||
'lets_LABEL_POINT' => 'Label Point',
|
||||
'lets_Domain_name_/_HOSTNAME' => 'Domain name / HOSTNAME',
|
||||
'lets_LIST_panel_action_was_successful' => 'LIST panel action was successful',
|
||||
'lets_Domains_name' => 'Domains name',
|
||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain which is enabled',
|
||||
'lets_CHECK_ALL_ENABLED_DOMAINS' => 'Check All Enabled Domains',
|
||||
'lets_CONFIGUREMODE_STATUS' => 'Configuremode Status',
|
||||
'lets_Save' => 'Save',
|
||||
'lets_ACCEPT_TERMS_STATUS' => 'Accept Terms Status',
|
||||
'lets_Not_Before' => 'Not Before',
|
||||
|
289
Targets/Mailsorting/Mailsorting-Custom.pm
Normal file
289
Targets/Mailsorting/Mailsorting-Custom.pm
Normal file
@@ -0,0 +1,289 @@
|
||||
#
|
||||
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
#
|
||||
#
|
||||
# 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 $ms_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('account')
|
||||
{$ret .= 'Validation for account failed';}
|
||||
if (! TRUE) #validate $c->param('username')
|
||||
{$ret .= 'Validation for username failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub validate_RULES {
|
||||
my $c = shift;
|
||||
my $ms_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('basis')
|
||||
{$ret .= 'Validation for basis failed';}
|
||||
if (! TRUE) #validate $c->param('criterion')
|
||||
{$ret .= 'Validation for criterion failed';}
|
||||
if (! TRUE) #validate $c->param('basis2')
|
||||
{$ret .= 'Validation for basis2 failed';}
|
||||
if (! TRUE) #validate $c->param('criterion2')
|
||||
{$ret .= 'Validation for criterion2 failed';}
|
||||
if (! TRUE) #validate $c->param('action')
|
||||
{$ret .= 'Validation for action failed';}
|
||||
if (! TRUE) #validate $c->param('deliver')
|
||||
{$ret .= 'Validation for deliver failed';}
|
||||
if (! TRUE) #validate $c->param('folder')
|
||||
{$ret .= 'Validation for folder failed';}
|
||||
if (! TRUE) #validate $c->param('copy')
|
||||
{$ret .= 'Validation for copy failed';}
|
||||
if (! TRUE) #validate $c->param('action2')
|
||||
{$ret .= 'Validation for action2 failed';}
|
||||
if (! TRUE) #validate $c->param('deliver2')
|
||||
{$ret .= 'Validation for deliver2 failed';}
|
||||
if (! TRUE) #validate $c->param('key')
|
||||
{$ret .= 'Validation for key failed';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub validate_REMOVE {
|
||||
my $c = shift;
|
||||
my $ms_data = shift; #Data hash as parameter
|
||||
# Validation for each field
|
||||
my $ret = "";
|
||||
|
||||
if (! TRUE) #validate $c->param('RemoveRule')
|
||||
{$ret .= 'Validation for RemoveRule 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']
|
||||
'account'=>'account contents',
|
||||
'username'=>'username contents',
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
sub get_data_for_panel_RULES {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1'=>'Data for RULES', #Example
|
||||
# fields from Inputs in RULES $fields['RULES']
|
||||
'basis'=>'basis contents',
|
||||
'criterion'=>'criterion contents',
|
||||
'basis2'=>'basis2 contents',
|
||||
'criterion2'=>'criterion2 contents',
|
||||
'action'=>'action contents',
|
||||
'deliver'=>'deliver contents',
|
||||
'folder'=>'folder contents',
|
||||
'copy'=>'copy contents',
|
||||
'action2'=>'action2 contents',
|
||||
'deliver2'=>'deliver2 contents',
|
||||
'key'=>'key contents',
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
sub get_data_for_panel_REMOVE {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my %ret = (
|
||||
'Data1'=>'Data for REMOVE', #Example
|
||||
# fields from Inputs in REMOVE $fields['REMOVE']
|
||||
'RemoveRule'=>'RemoveRule contents',
|
||||
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Get control data for table(s)
|
||||
|
||||
# Define a constant hash for field name mapping
|
||||
use constant getAllRules_FIELD_MAPPING => (
|
||||
'MatchAgainst' => 'Source-for-MatchAgainst',
|
||||
'TheRule' => 'Source-for-TheRule',
|
||||
'c2ndMatch' => 'Source-for-c2ndMatch',
|
||||
'c2ndRule' => 'Source-for-c2ndRule',
|
||||
'Action' => 'Source-for-Action',
|
||||
'Destination' => 'Source-for-Destination',
|
||||
'Copy' => 'Source-for-Copy',
|
||||
'Destination' => 'Source-for-Destination',
|
||||
'Serial Number' => 'Source-for-Serial Number',
|
||||
'Modify' => 'Source-for-Modify',
|
||||
'Remove' => 'Source-for-Remove'
|
||||
#'target_field2' => 'source_field2',
|
||||
# Add more mappings as needed
|
||||
);
|
||||
|
||||
sub actual_getAllRules {
|
||||
my @ret = ();
|
||||
# Actual code for extracting getAllRules
|
||||
return @ret;
|
||||
}
|
||||
|
||||
sub get_getAllRules {
|
||||
# Return an array of hashes of the contents for each row and column for getAllRules
|
||||
my $c = shift;
|
||||
my @source_records = $c->actual_getAllRules();
|
||||
my @transformed_records;
|
||||
my %Field_Mapping = getAllRules_FIELD_MAPPING();
|
||||
# Iterate over each record in the source array
|
||||
for my $source_record (@source_records) {
|
||||
my %transformed_record;
|
||||
# Iterate over each key-value pair in the $Field_Mapping constant
|
||||
while (my ($target, $source) = each %Field_Mapping) {
|
||||
# Check if the source field exists in the source record
|
||||
if (exists $source_record->{$source}) {
|
||||
# Assign the source field value to the target field in the transformed record
|
||||
$transformed_record{$target} = $source_record->{$source};
|
||||
}
|
||||
}
|
||||
# Add transformed record to the array if it's not empty
|
||||
push @transformed_records, \%transformed_record if %transformed_record;
|
||||
}
|
||||
return \@transformed_records;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# 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_RULES {
|
||||
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_REMOVE {
|
||||
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 $ms_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: account e.g. $db->set_prop($dbkey,'account',$c->param('account'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for account';}
|
||||
if (! TRUE) #copy or perform with value: username e.g. $db->set_prop($dbkey,'username',$c->param('username'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for username';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub perform_RULES {
|
||||
my $c = shift;
|
||||
my $ms_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: basis e.g. $db->set_prop($dbkey,'basis',$c->param('basis'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for basis';}
|
||||
if (! TRUE) #copy or perform with value: criterion e.g. $db->set_prop($dbkey,'criterion',$c->param('criterion'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for criterion';}
|
||||
if (! TRUE) #copy or perform with value: basis2 e.g. $db->set_prop($dbkey,'basis2',$c->param('basis2'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for basis2';}
|
||||
if (! TRUE) #copy or perform with value: criterion2 e.g. $db->set_prop($dbkey,'criterion2',$c->param('criterion2'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for criterion2';}
|
||||
if (! TRUE) #copy or perform with value: action e.g. $db->set_prop($dbkey,'action',$c->param('action'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for action';}
|
||||
if (! TRUE) #copy or perform with value: deliver e.g. $db->set_prop($dbkey,'deliver',$c->param('deliver'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for deliver';}
|
||||
if (! TRUE) #copy or perform with value: folder e.g. $db->set_prop($dbkey,'folder',$c->param('folder'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for folder';}
|
||||
if (! TRUE) #copy or perform with value: copy e.g. $db->set_prop($dbkey,'copy',$c->param('copy'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for copy';}
|
||||
if (! TRUE) #copy or perform with value: action2 e.g. $db->set_prop($dbkey,'action2',$c->param('action2'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for action2';}
|
||||
if (! TRUE) #copy or perform with value: deliver2 e.g. $db->set_prop($dbkey,'deliver2',$c->param('deliver2'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for deliver2';}
|
||||
if (! TRUE) #copy or perform with value: key e.g. $db->set_prop($dbkey,'key',$c->param('key'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for key';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub perform_REMOVE {
|
||||
my $c = shift;
|
||||
my $ms_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: RemoveRule e.g. $db->set_prop($dbkey,'RemoveRule',$c->param('RemoveRule'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for RemoveRule';}
|
||||
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;
|
||||
}
|
||||
1;
|
357
Targets/Mailsorting/Mailsorting.pm
Normal file
357
Targets/Mailsorting/Mailsorting.pm
Normal file
@@ -0,0 +1,357 @@
|
||||
package SrvMngr::Controller::Mailsorting;
|
||||
#
|
||||
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
# Remember that each route must be unique (else they just overwrite each other).
|
||||
# you cannot have get and post on the same name and url.
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# heading : System
|
||||
# description : Process Mail
|
||||
# navigation : 6000 1200
|
||||
#
|
||||
# name : mailsorting, method : get, url : /mailsorting, ctlact : Mailsorting#main
|
||||
# name : mailsortingu, method : post, url : /mailsortingu, ctlact : Mailsorting#do_update
|
||||
# name : mailsortingd, method : get, url : /mailsortingd, ctlact : Mailsorting#do_display
|
||||
#
|
||||
# routes : end
|
||||
#
|
||||
# Documentation: https://wiki.contribs.org/Mailsorting
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# 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;
|
||||
|
||||
my %ms_data;
|
||||
|
||||
require '/usr/share/smanager/lib/SrvMngr/Controller/Mailsorting-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");
|
||||
|
||||
%ms_data = ();
|
||||
my $title = $c->l('ms_Process_Mail');
|
||||
my $modul = '';
|
||||
|
||||
$ms_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($ms_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 $title = $c->l('ms_Process_Mail');
|
||||
|
||||
# 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}) {
|
||||
# $ms_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(\%ms_data);
|
||||
$thispanel = 'TABLE';
|
||||
}
|
||||
|
||||
if ($trt eq 'RULES'){
|
||||
#Validate form parameters for panel RULES
|
||||
$ret = $c->validate_RULES(\%ms_data);
|
||||
$thispanel = 'RULES';
|
||||
}
|
||||
|
||||
if ($trt eq 'REMOVE'){
|
||||
#Validate form parameters for panel REMOVE
|
||||
$ret = $c->validate_REMOVE(\%ms_data);
|
||||
$thispanel = 'REMOVE';
|
||||
}
|
||||
|
||||
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(\%ms_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
ms_data => \%ms_data
|
||||
);
|
||||
$c->render(template => "mailsorting");
|
||||
} else {
|
||||
$c->stash( success => $c->l('ms_TABLE_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'RULES'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_RULES(\%ms_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
ms_data => \%ms_data
|
||||
);
|
||||
$c->render(template => "mailsorting");
|
||||
} else {
|
||||
$c->stash( success => $c->l('ms_RULES_panel_action_was_successful')); #A bit bland - edit it in the lex file
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'REMOVE'){
|
||||
#do whatever is required ...
|
||||
$ret = $c->perform_REMOVE(\%ms_data);
|
||||
if ($ret ne "ok") {
|
||||
# return to the panel with error message
|
||||
$c->stash(error => $c->l($ret));
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
ms_data => \%ms_data
|
||||
);
|
||||
$c->render(template => "mailsorting");
|
||||
} else {
|
||||
$c->stash( success => $c->l('ms_REMOVE_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') {
|
||||
$ms_data{'trt'} = 'TABLE';
|
||||
} else {
|
||||
$ms_data{'trt'} = 'none';
|
||||
}
|
||||
$c->do_display($ms_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 $title = $c->l('ms_Process_Mail');
|
||||
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}) {
|
||||
# $ms_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($ms_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'RULES'){
|
||||
#Validate Get selected row (if applicable) RULES
|
||||
%selectedrow = $c->get_selected_RULES($ms_data{'Selected'},$is_new_record);
|
||||
}
|
||||
|
||||
if ($trt eq 'REMOVE'){
|
||||
#Validate Get selected row (if applicable) REMOVE
|
||||
%selectedrow = $c->get_selected_REMOVE($ms_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){
|
||||
$ms_data{$key} = $value;
|
||||
}
|
||||
# Where to go now
|
||||
$ms_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) {
|
||||
$ms_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'RULES'){
|
||||
# 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_RULES();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$ms_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($trt eq 'REMOVE'){
|
||||
# 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_REMOVE();
|
||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
||||
while (my ($key, $value) = each %returned_hash) {
|
||||
$ms_data{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# and table control fields
|
||||
$c->stash(getAllRules=>$c->get_getAllRules());
|
||||
|
||||
|
||||
# Data for panel
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
ms_data => \%ms_data
|
||||
);
|
||||
$c->render(template => "mailsorting");
|
||||
}
|
||||
1;
|
38
Targets/Mailsorting/_ms_REMOVE.html.ep
Normal file
38
Targets/Mailsorting/_ms_REMOVE.html.ep
Normal file
@@ -0,0 +1,38 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
%#
|
||||
<div id="Mailsorting-REMOVE" class="partial Mailsorting-REMOVE">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $ms_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('ms_APPLY');
|
||||
%= form_for "mailsortingu" => (method => 'POST') => begin
|
||||
% param 'trt' => $ms_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $ms_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h1 class='head'><%=l('ms_Mail_sorting_rules')%></h1>
|
||||
|
||||
<h2 class='subh'><%=l('ms_You_are_about_to_remove')%></h2>
|
||||
|
||||
<span class=label>
|
||||
%=l('ms_Rule_contents')
|
||||
</span><span class=data>
|
||||
% param 'RemoveRule' => $ms_data->{RemoveRule} unless param 'RemoveRule';
|
||||
%= text_area 'RemoveRule', cols=>40, rows=>10, Readonly=>'true','
|
||||
</span><br>
|
||||
|
||||
<span class='data'>
|
||||
%= submit_button l('ms_Remove'), class => 'action subm95'
|
||||
</span>
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
122
Targets/Mailsorting/_ms_RULES.html.ep
Normal file
122
Targets/Mailsorting/_ms_RULES.html.ep
Normal file
@@ -0,0 +1,122 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
%#
|
||||
<div id="Mailsorting-RULES" class="partial Mailsorting-RULES">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $ms_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('ms_APPLY');
|
||||
%= form_for "mailsortingu" => (method => 'POST') => begin
|
||||
% param 'trt' => $ms_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $ms_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h1 class='head'><%=l('ms_Mail_sorting_rules')%></h1>
|
||||
|
||||
<h2 class='subh'><%=l('ms_Manage_mailsortingModifyRule_settings:')%></h2>
|
||||
|
||||
<p class='paragraph para1'>
|
||||
%=l('ms_Modify_your_rule.')
|
||||
</p>
|
||||
|
||||
<p class='paragraph para2'>
|
||||
%=l('ms_You_can_change_the_order')
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_basis')
|
||||
</span><span class=data>
|
||||
% my @basis_options = [['Subject' => 'Subject'], ['To' => 'TO_'], ['From' => 'From'], ['Email Headers' => 'headers'], ['Size greater than' => 'sizegt'], ['Size less than' => 'sizelt']];
|
||||
% param 'basis' => $ms_data->{basis} unless param 'basis';
|
||||
%= select_field 'basis' => @basis_options, class => 'input', id => 'basis_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_criterion')
|
||||
</span><span class=data>
|
||||
% param 'criterion' => $ms_data->{criterion} unless param 'criterion';
|
||||
%= text_field 'criterion', size => '50', class => 'textinput criterion' , pattern=>'.*' , placeholder=>'criterion', title =>'Pattern regex mismatch', id => 'criterion_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_basis2')
|
||||
</span><span class=data>
|
||||
% my @basis2_options = [['' => ''], ['Subject' => 'Subject'], ['To' => 'TO_'], ['From' => 'From'], ['Email Headers' => 'headers']];
|
||||
% param 'basis2' => $ms_data->{basis2} unless param 'basis2';
|
||||
%= select_field 'basis2' => @basis2_options, class => 'input', id => 'basis2_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_criterion2')
|
||||
</span><span class=data>
|
||||
% param 'criterion2' => $ms_data->{criterion2} unless param 'criterion2';
|
||||
%= text_field 'criterion2', size => '50', class => 'textinput criterion2' , pattern=>'.*' , placeholder=>'criterion2', title =>'Pattern regex mismatch', id => 'criterion2_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_action')
|
||||
</span><span class=data>
|
||||
% my @action_options = [['Delete email' => 'delete'], ['Forward email' => 'forward'], ['Sort to mail folder' => 'sort']];
|
||||
% param 'action' => $ms_data->{action} unless param 'action';
|
||||
%= select_field 'action' => @action_options, class => 'input', id => 'action_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_deliver')
|
||||
</span><span class=data>
|
||||
% param 'deliver' => $ms_data->{deliver} unless param 'deliver';
|
||||
%= text_field 'deliver', size => '50', class => 'textinput deliver' , pattern=>'.*' , placeholder=>'deliver', title =>'Pattern regex mismatch', id => 'deliver_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_folder')
|
||||
</span><span class=data>
|
||||
% my @folder_options = ;
|
||||
% param 'folder' => $ms_data->{folder} unless param 'folder';
|
||||
%= select_field 'folder' => @folder_options, class => 'input', id => 'folder_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_copy')
|
||||
</span><span class=data>
|
||||
% my @copy_options = [['No' => 'no'], ['Yes' => 'yes']];
|
||||
% param 'copy' => $ms_data->{copy} unless param 'copy';
|
||||
%= select_field 'copy' => @copy_options, class => 'input', id => 'copy_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_action2')
|
||||
</span><span class=data>
|
||||
% my @action2_options = [['' => ''], ['Delete email' => 'delete'], ['Forward email' => 'forward'], ['Send to my inbox' => 'inbox']];
|
||||
% param 'action2' => $ms_data->{action2} unless param 'action2';
|
||||
%= select_field 'action2' => @action2_options, class => 'input', id => 'action2_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_deliver2')
|
||||
</span><span class=data>
|
||||
% param 'deliver2' => $ms_data->{deliver2} unless param 'deliver2';
|
||||
%= text_field 'deliver2', size => '50', class => 'textinput deliver2' , pattern=>'.*' , placeholder=>'deliver2', title =>'Pattern regex mismatch', id => 'deliver2_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_key')
|
||||
</span><span class=data>
|
||||
% param 'key' => $ms_data->{key} unless param 'key';
|
||||
%= text_field 'key', size => '50', class => 'textinput key' , pattern=>'.*' , placeholder=>'key', title =>'Pattern regex mismatch', id => 'key_text'
|
||||
<br></span></p>
|
||||
|
||||
<span class='data'>
|
||||
%= submit_button l('ms_Save'), class => 'action subm12'
|
||||
</span>
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
88
Targets/Mailsorting/_ms_TABLE.html.ep
Normal file
88
Targets/Mailsorting/_ms_TABLE.html.ep
Normal file
@@ -0,0 +1,88 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
%#
|
||||
<div id="Mailsorting-TABLE" class="partial Mailsorting-TABLE">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $ms_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('ms_APPLY');
|
||||
%= form_for "mailsortingu" => (method => 'POST') => begin
|
||||
% param 'trt' => $ms_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $ms_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h1 class='head'><%=l('ms_Mail_sorting_rules')%></h1>
|
||||
|
||||
<p class='paragraph para1'>
|
||||
%=l('ms_Rules_are_executed_as_email')
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_Account')
|
||||
</span><span class=data>
|
||||
% param 'account' => $ms_data->{account} unless param 'account';
|
||||
%= text_field 'account', size => '50', class => 'textinput account' , pattern=>'.*' , placeholder=>'account', title =>'Pattern regex mismatch', id => 'account_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_User_Name')
|
||||
</span><span class=data>
|
||||
% param 'username' => $ms_data->{username} unless param 'username';
|
||||
%= text_field 'username', size => '50', class => 'textinput username' , pattern=>'.*' , placeholder=>'username', title =>'Pattern regex mismatch', id => 'username_text'
|
||||
<br></span></p>
|
||||
|
||||
<a href='mailsortingdd?trt=RULES' class='link link1'>
|
||||
%= l('ms_Add_new_rule')
|
||||
</a>
|
||||
%#= link_to l('ms_Add_new_rule'), 'mailsortingdd?trt=RULES' , class=>'link link1'
|
||||
|
||||
|
||||
<h2 class='subh'><%=l('ms_Current_rules')%></h2>
|
||||
|
||||
<br /><table class="sme-border TableSort sme-table tabl1 ">
|
||||
<thead class='tabl1'>
|
||||
<tr table-head-row>
|
||||
<th class='sme-border table-head-col table-head-col-Match Against '><%=l('ms_Match_Against')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-The Rule '><%=l('ms_The_Rule')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-2nd Match '><%=l('ms_2nd_Match')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-2nd Rule '><%=l('ms_2nd_Rule')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Action '><%=l('ms_Action')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Destination '><%=l('ms_Destination')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Copy '><%=l('ms_Copy')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Destination '><%=l('ms_Destination')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Serial Number '><%=l('ms_Serial_Number')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Modify '><%=l('ms_Modify')%></th>
|
||||
<th class='sme-border table-head-col table-head-col-Remove '><%=l('ms_Remove')%></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class='tabl1'>
|
||||
% my $control_data = $c->stash('getAllRules');
|
||||
% foreach my $row (@$control_data) {
|
||||
<tr class='table-row'>
|
||||
<td class='sme-border table-col table-col-MatchAgainst'><%=$c->render_to_string(inline=>$row->{'MatchAgainst'})%></td>
|
||||
<td class='sme-border table-col table-col-TheRule'><%=$c->render_to_string(inline=>$row->{'TheRule'})%></td>
|
||||
<td class='sme-border table-col table-col-c2ndMatch'><%=$c->render_to_string(inline=>$row->{'c2ndMatch'})%></td>
|
||||
<td class='sme-border table-col table-col-c2ndRule'><%=$c->render_to_string(inline=>$row->{'c2ndRule'})%></td>
|
||||
<td class='sme-border table-col table-col-Action'><%=$c->render_to_string(inline=>$row->{'Action'})%></td>
|
||||
<td class='sme-border table-col table-col-Destination'><%=$c->render_to_string(inline=>$row->{'Destination'})%></td>
|
||||
<td class='sme-border table-col table-col-Copy'><%=$c->render_to_string(inline=>$row->{'Copy'})%></td>
|
||||
<td class='sme-border table-col table-col-Destination'><%=$c->render_to_string(inline=>$row->{'Destination'})%></td>
|
||||
<td class='sme-border table-col table-col-Serial Number'><%=$c->render_to_string(inline=>$row->{'Serial Number'})%></td>
|
||||
<td class='sme-border table-col table-col-Modify'><%=$c->render_to_string(inline=>$row->{'Modify'})%></td>
|
||||
<td class='sme-border table-col table-col-Remove'><%=$c->render_to_string(inline=>$row->{'Remove'})%></td>
|
||||
</tr>
|
||||
%}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
39
Targets/Mailsorting/mailsorting.css
Normal file
39
Targets/Mailsorting/mailsorting.css
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
*/
|
||||
.Mailsorting-panel {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.head {}
|
||||
.para1 {}
|
||||
.text97 {}
|
||||
.text96 {}
|
||||
.link1 {}
|
||||
.subh {}
|
||||
.tabl1 {}
|
||||
thead .tabl1 {}
|
||||
tbody .tabl1 {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.head {}
|
||||
.subh {}
|
||||
.para1 {}
|
||||
.para2 {}
|
||||
.sele1 {}
|
||||
.text2 {}
|
||||
.sele3 {}
|
||||
.text4 {}
|
||||
.sele5 {}
|
||||
.text6 {}
|
||||
.sele7 {}
|
||||
.sele8 {}
|
||||
.sele9 {}
|
||||
.text10 {}
|
||||
.text11 {}
|
||||
.subm12 {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.head {}
|
||||
.subh {}
|
||||
.text94 {}
|
||||
.subm95 {}
|
64
Targets/Mailsorting/mailsorting.html.ep
Normal file
64
Targets/Mailsorting/mailsorting.html.ep
Normal file
@@ -0,0 +1,64 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
%#
|
||||
% layout 'default', title => "Sme server 2 - Process Mail", share_dir => './';
|
||||
%# css specific to this panel:
|
||||
% content_for 'module' => begin
|
||||
%= stylesheet '/css/mailsorting.css'
|
||||
%= javascript '/js/mailsorting.js'
|
||||
<div id="module" class="module Mailsorting-panel">
|
||||
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $c->current_route
|
||||
%= dumper $ms_data->{trt}
|
||||
</pre>
|
||||
% }
|
||||
|
||||
<h1><%=$title%></h1>
|
||||
|
||||
% if ( stash('modul')) {
|
||||
%= $c->render_to_string(inline => stash('modul') );
|
||||
% }
|
||||
|
||||
%if ($c->stash('first')) {
|
||||
<br><p>
|
||||
%=$c->render_to_string(inline =>$c->l($c->stash('first')))
|
||||
</p>
|
||||
|
||||
%} elsif ($c->stash('success')) {
|
||||
<div class='success '>
|
||||
<p>
|
||||
%= $c->l($c->stash('success'));
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
%} elsif ($c->stash('error')) {
|
||||
<div class='sme-error'>
|
||||
<p>
|
||||
%= $c->l($c->stash('error'));
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
%}
|
||||
|
||||
%#Routing to partials according to trt parameter.
|
||||
%#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement'
|
||||
|
||||
% if ($ms_data->{trt} eq "TABLE") {
|
||||
%= include 'partials/_ms_TABLE'
|
||||
%}
|
||||
|
||||
% if ($ms_data->{trt} eq "RULES") {
|
||||
%= include 'partials/_ms_RULES'
|
||||
%}
|
||||
|
||||
% if ($ms_data->{trt} eq "REMOVE") {
|
||||
%= include 'partials/_ms_REMOVE'
|
||||
%}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
%end
|
5
Targets/Mailsorting/mailsorting.js
Normal file
5
Targets/Mailsorting/mailsorting.js
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
//
|
||||
$(document).ready(function() {
|
||||
});
|
41
Targets/Mailsorting/mailsorting_en.lex
Normal file
41
Targets/Mailsorting/mailsorting_en.lex
Normal file
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
#
|
||||
'ms_Modify_your_rule.' => 'Modify your rule',
|
||||
'ms_REMOVE_panel_action_was_successful' => 'REMOVE panel action was successful',
|
||||
'ms_criterion' => 'Criterion',
|
||||
'ms_APPLY' => 'Apply',
|
||||
'ms_RULES_panel_action_was_successful' => 'RULES panel action was successful',
|
||||
'ms_Rule_contents' => 'Rule contents',
|
||||
'ms_Add_new_rule' => 'Add new rule',
|
||||
'ms_action2' => 'action',
|
||||
'ms_You_are_about_to_remove' => 'You are about to remove a rule',
|
||||
'ms_You_can_change_the_order' => 'You can change the order in which rules are evaluated by altering the numeric value in order of rule execution Priority is determined by asci value And must be unique beg rule user101 goes first Then user then user',
|
||||
'ms_Remove' => 'Remove',
|
||||
'ms_The_Rule' => 'The Rule',
|
||||
'ms_key' => 'Key',
|
||||
'ms_Rules_are_executed_as_email' => 'Rules are executed as email arrives in your mailbox on the server And are independent of your email client Your current rules If you have any are listed below',
|
||||
'ms_2nd_Rule' => 'and Rule',
|
||||
'ms_Action' => 'Action',
|
||||
'ms_Save' => 'Save',
|
||||
'ms_TABLE_panel_action_was_successful' => 'TABLE panel action was successful',
|
||||
'ms_Match_Against' => 'Match Against',
|
||||
'ms_2nd_Match' => 'and Match',
|
||||
'ms_Copy' => 'Copy',
|
||||
'ms_criterion2' => 'criterion',
|
||||
'ms_deliver2' => 'deliver',
|
||||
'ms_basis2' => 'basis',
|
||||
'ms_Mail_sorting_rules' => 'Mail sorting rules',
|
||||
'ms_User_Name' => 'User Name',
|
||||
'ms_folder' => 'Folder',
|
||||
'ms_action' => 'Action',
|
||||
'ms_copy' => 'Copy',
|
||||
'ms_basis' => 'Basis',
|
||||
'ms_Account' => 'Account',
|
||||
'ms_Serial_Number' => 'Serial Number',
|
||||
'ms_Manage_mailsortingModifyRule_settings:' => 'Manage mailsortingModifyRule settings',
|
||||
'ms_Destination' => 'Destination',
|
||||
'ms_Modify' => 'Modify',
|
||||
'ms_Process_Mail' => 'Process Mail',
|
||||
'ms_deliver' => 'Deliver',
|
||||
'ms_Current_rules' => 'Current rules',
|
321
Targets/Mailstats/Mailstats-Custom.pm
Normal file
321
Targets/Mailstats/Mailstats-Custom.pm
Normal file
@@ -0,0 +1,321 @@
|
||||
#
|
||||
# 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 POSIX 'strftime';
|
||||
|
||||
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
|
||||
);}
|
||||
|
||||
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;
|
315
Targets/Mailstats/Mailstats.pm
Normal file
315
Targets/Mailstats/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;
|
207
Targets/Mailstats/_mst_CONFIG.html.ep
Normal file
207
Targets/Mailstats/_mst_CONFIG.html.ep
Normal file
@@ -0,0 +1,207 @@
|
||||
%#
|
||||
%# 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">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $mst_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('mst_APPLY');
|
||||
%= form_for "mailstatsu" => (method => 'POST') => begin
|
||||
% param 'trt' => $mst_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $mst_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Specify_if_you_would_like')
|
||||
</span><span class=data>
|
||||
% my @TextorHTML_options = [['HTML' => 'HTML'], ['Text' => 'Text'], ['Both' => 'Both'], ['Neither' => 'Neither']];
|
||||
% param 'TextorHTML' => $mst_data->{TextorHTML} unless param 'TextorHTML';
|
||||
%= select_field 'TextorHTML' => @TextorHTML_options, class => 'input', id => 'TextorHTML_select'
|
||||
<br></span> </p>
|
||||
|
||||
<div class=emailwanted>
|
||||
|
||||
|
||||
<h2 class='subh'><%=l('mst_Email_details')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Email_for_stats')
|
||||
</span><span class=data>
|
||||
% param 'Email' => $mst_data->{Email} unless param 'Email';
|
||||
%=email_field 'Email', class => 'emai3'
|
||||
</span></p>
|
||||
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Host_name_for_email_server')
|
||||
</span><span class=data>
|
||||
% param 'EmailHost' => $mst_data->{EmailHost} unless param 'EmailHost';
|
||||
%= text_field 'EmailHost', size => '50', class => 'textinput EmailHost' , pattern=>'.*' , placeholder=>'EmailHost', title =>'Pattern regex mismatch'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('mst_Port_number_for_email_server')
|
||||
</span><span class=data>
|
||||
% param 'EmailPort' => $mst_data->{EmailPort} unless param 'EmailPort';
|
||||
%=number_field 'EmailPort', class => 'numb6'
|
||||
</span></p>
|
||||
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_User_name_for_email_sending')
|
||||
</span><span class=data>
|
||||
% param 'EmailUser' => $mst_data->{EmailUser} unless param 'EmailUser';
|
||||
%= text_field 'EmailUser', size => '50', class => 'textinput EmailUser' , pattern=>'.*' , placeholder=>'EmailUser', title =>'Pattern regex mismatch'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('mst_User_Password_for_email_sending')
|
||||
</span><span class=data>
|
||||
% param 'EmailPassword' => $mst_data->{EmailPassword} unless param 'EmailPassword';
|
||||
%=password_field 'EmailPassword', class => 'pass8 sme-password', autocomplete => 'off'
|
||||
</span></p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Would_you_like_to_save')
|
||||
</span><span class=data>
|
||||
% my @DBSave_options = [['yes' => 'yes'], ['no' => 'no']];
|
||||
% param 'DBSave' => $mst_data->{DBSave} unless param 'DBSave';
|
||||
%= select_field 'DBSave' => @DBSave_options, class => 'input', id => 'DBSave_select'
|
||||
<br></span> </p>
|
||||
|
||||
<div class=dbwanted>
|
||||
|
||||
|
||||
<h2 class='subh2'><%=l('mst_Details_for_connection_to_database')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Host_name_for_DB_server')
|
||||
</span><span class=data>
|
||||
% param 'DBHost' => $mst_data->{DBHost} unless param 'DBHost';
|
||||
%= text_field 'DBHost', size => '50', class => 'textinput DBHost' , pattern=>'.*' , placeholder=>'DBHost', title =>'Pattern regex mismatch'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('mst_Port_number_for_DB_server')
|
||||
</span><span class=data>
|
||||
% param 'DBPort' => $mst_data->{DBPort} unless param 'DBPort';
|
||||
%=number_field 'DBPort', class => 'numb11'
|
||||
</span></p>
|
||||
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_User_name_for_DB_sending')
|
||||
</span><span class=data>
|
||||
% param 'DBUser' => $mst_data->{DBUser} unless param 'DBUser';
|
||||
%= text_field 'DBUser', size => '50', class => 'textinput DBUser' , pattern=>'.*' , placeholder=>'DBUser', title =>'Pattern regex mismatch'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('mst_User_Password_for_DB_sending')
|
||||
</span><span class=data>
|
||||
% param 'DBPassword' => $mst_data->{DBPassword} unless param 'DBPassword';
|
||||
%=password_field 'DBPassword', class => 'pass13 sme-password', autocomplete => 'off'
|
||||
</span></p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<h2 class='subh3'><%=l('mst_Email_filtering_/_exclusion')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Select_the_countries_you_would')
|
||||
</span><span class=data>
|
||||
% my @CountrySelect_options = $c->get_CountryCodes();
|
||||
% param 'CountrySelect' => $mst_data->{CountrySelect} unless param 'CountrySelect';
|
||||
%= select_field 'CountrySelect' => @CountrySelect_options, class => 'input', id => 'CountrySelect_select', multiple => 'multiple'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Accumulated_country_codes_(editable)')
|
||||
</span><span class=data>
|
||||
% param 'AccumCountryCodes' => $mst_data->{AccumCountryCodes} unless param 'AccumCountryCodes';
|
||||
%= text_field 'AccumCountryCodes', size => '50', class => 'textinput AccumCountryCodes' , pattern=>'.*' , placeholder=>'AccumCountryCodes', title =>'Pattern regex mismatch', id => 'AccumCountryCodes_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Enable_RHSBL_checking')
|
||||
</span><span class=data>
|
||||
% my @EnableRHSBL_options = [['yes' => 'enabled'], ['no' => 'disabled']];
|
||||
% param 'EnableRHSBL' => $mst_data->{EnableRHSBL} unless param 'EnableRHSBL';
|
||||
%= select_field 'EnableRHSBL' => @EnableRHSBL_options, class => 'input', id => 'EnableRHSBL_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Enable_DNSBL_checking')
|
||||
</span><span class=data>
|
||||
% my @EnableDNSBL_options = [['yes' => 'enabled'], ['no' => 'disabled']];
|
||||
% param 'EnableDNSBL' => $mst_data->{EnableDNSBL} unless param 'EnableDNSBL';
|
||||
%= select_field 'EnableDNSBL' => @EnableDNSBL_options, class => 'input', id => 'EnableDNSBL_select'
|
||||
<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>
|
||||
%=l('mst_RBL_Servers_to_use')
|
||||
</span><span class=data>
|
||||
% param 'RBLList' => $mst_data->{RBLList} unless param 'RBLList';
|
||||
%= text_field 'RBLList', size => '50', class => 'textinput RBLList' , pattern=>'.*' , placeholder=>'RBLList', title =>'Pattern regex mismatch'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_SBL_Servers_to_use')
|
||||
</span><span class=data>
|
||||
% param 'SBLList' => $mst_data->{SBLList} unless param 'SBLList';
|
||||
%= text_field 'SBLList', size => '50', class => 'textinput SBLList' , pattern=>'.*' , placeholder=>'SBLList', title =>'Pattern regex mismatch'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_UBL_Servers_to_use')
|
||||
</span><span class=data>
|
||||
% param 'UBLList' => $mst_data->{UBLList} unless param 'UBLList';
|
||||
%= text_field 'UBLList', size => '50', class => 'textinput UBLList' , pattern=>'.*' , placeholder=>'UBLList', title =>'Pattern regex mismatch'
|
||||
<br></span></p>
|
||||
|
||||
<h2 class='subh4'><%=l('mst_Spamassassin_scores_-_tag_and')%></h2>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('mst_Score_to_fully_reject_emmail')
|
||||
</span><span class=data>
|
||||
% param 'RejectLevel' => $mst_data->{RejectLevel} unless param 'RejectLevel';
|
||||
%=number_field 'RejectLevel', class => 'numb21'
|
||||
</span></p>
|
||||
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('mst_Score_for_tagging_as_spam,')
|
||||
</span><span class=data>
|
||||
% param 'TagLevel' => $mst_data->{TagLevel} unless param 'TagLevel';
|
||||
%=number_field 'TagLevel', class => 'numb22'
|
||||
</span></p>
|
||||
|
||||
|
||||
<span class='data'>
|
||||
%= submit_button l('mst_Save'), class => 'action subm23'
|
||||
</span>
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
52
Targets/Mailstats/_mst_TABLE.html.ep
Normal file
52
Targets/Mailstats/_mst_TABLE.html.ep
Normal file
@@ -0,0 +1,52 @@
|
||||
%#
|
||||
%# 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">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $mst_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('mst_APPLY');
|
||||
%= form_for "mailstatsu" => (method => 'POST') => begin
|
||||
% param 'trt' => $mst_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $mst_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<div class=inline-buttons>
|
||||
|
||||
|
||||
<a href='mailstatsd?trt=CONFIG' class='link link1'>
|
||||
%= l('mst_Configure_Mailstats')
|
||||
</a>
|
||||
%#= link_to l('mst_Configure_Mailstats'), 'mailstatsd?trt=CONFIG' , class=>'link link1'
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<h2 class='subh1'><%=l('mst_Table_of_email_status')%></h2>
|
||||
|
||||
<p class='paragraph para1'>
|
||||
%=l('mst_Descriptive_paragraph')
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('mst_Date_for_Stats_display')
|
||||
</span><span class=data>
|
||||
% my @StatsDate_options = $c->get_mailstat_dates();
|
||||
% param 'StatsDate' => $mst_data->{StatsDate} unless param 'StatsDate';
|
||||
%= select_field 'StatsDate' => @StatsDate_options, class => 'input', id => 'StatsDate_select'
|
||||
<br></span> </p>
|
||||
|
||||
<object id = 'mailstats_object' data="<%='mailstats/$c->stash("url")' %>" title="<%= $c->stash('title') %>" type="text/html" ><%= $c->stash('title') %> not found</object>
|
||||
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
45
Targets/Mailstats/mailstats.css
Normal file
45
Targets/Mailstats/mailstats.css
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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 {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.grou1 {}
|
||||
.link1 {}
|
||||
.endg1 {}
|
||||
.subh1 {}
|
||||
.para1 {}
|
||||
.sele1 {}
|
||||
.obje2 {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.sele4 {}
|
||||
.grou1 {}
|
||||
.subh {}
|
||||
.emai3 {}
|
||||
.text5 {}
|
||||
.numb6 {}
|
||||
.text7 {}
|
||||
.pass8 {}
|
||||
.endg1 {}
|
||||
.sele9 {}
|
||||
.grou2 {}
|
||||
.subh2 {}
|
||||
.text10 {}
|
||||
.numb11 {}
|
||||
.text12 {}
|
||||
.pass13 {}
|
||||
.endg2 {}
|
||||
.subh3 {}
|
||||
.mult14 {}
|
||||
.text15 {}
|
||||
.sele16 {}
|
||||
.sele17 {}
|
||||
.sele24 {}
|
||||
.text18 {}
|
||||
.text19 {}
|
||||
.text20 {}
|
||||
.subh4 {}
|
||||
.numb21 {}
|
||||
.numb22 {}
|
||||
.subm23 {}
|
60
Targets/Mailstats/mailstats.html.ep
Normal file
60
Targets/Mailstats/mailstats.html.ep
Normal file
@@ -0,0 +1,60 @@
|
||||
%#
|
||||
%# 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 => './';
|
||||
%# css specific to this panel:
|
||||
% content_for 'module' => begin
|
||||
%= stylesheet '/css/mailstats.css'
|
||||
%= javascript '/js/mailstats.js'
|
||||
<div id="module" class="module Mailstats-panel">
|
||||
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $c->current_route
|
||||
%= dumper $mst_data->{trt}
|
||||
</pre>
|
||||
% }
|
||||
|
||||
<h1><%=$title%></h1>
|
||||
|
||||
% if ( stash('modul')) {
|
||||
%= $c->render_to_string(inline => stash('modul') );
|
||||
% }
|
||||
|
||||
%if ($c->stash('first')) {
|
||||
<br><p>
|
||||
%=$c->render_to_string(inline =>$c->l($c->stash('first')))
|
||||
</p>
|
||||
|
||||
%} elsif ($c->stash('success')) {
|
||||
<div class='success '>
|
||||
<p>
|
||||
%= $c->l($c->stash('success'));
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
%} elsif ($c->stash('error')) {
|
||||
<div class='sme-error'>
|
||||
<p>
|
||||
%= $c->l($c->stash('error'));
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
%}
|
||||
|
||||
%#Routing to partials according to trt parameter.
|
||||
%#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement'
|
||||
|
||||
% if ($mst_data->{trt} eq "TABLE") {
|
||||
%= include 'partials/_mst_TABLE'
|
||||
%}
|
||||
|
||||
% if ($mst_data->{trt} eq "CONFIG") {
|
||||
%= include 'partials/_mst_CONFIG'
|
||||
%}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
%end
|
66
Targets/Mailstats/mailstats.js
Normal file
66
Targets/Mailstats/mailstats.js
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
//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() {
|
||||
});
|
||||
|
||||
// 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);
|
||||
});
|
37
Targets/Mailstats/mailstats_en.lex
Normal file
37
Targets/Mailstats/mailstats_en.lex
Normal file
@@ -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',
|
0
Targets/Nfsshare/Nfsshare-Custom.pm
Normal file → Executable file
0
Targets/Nfsshare/Nfsshare-Custom.pm
Normal file → Executable file
0
Targets/Nfsshare/Nfsshare-Custom.pm.new
Normal file → Executable file
0
Targets/Nfsshare/Nfsshare-Custom.pm.new
Normal file → Executable file
0
Targets/Nfsshare/Nfsshare.pm
Normal file → Executable file
0
Targets/Nfsshare/Nfsshare.pm
Normal file → Executable file
0
Targets/Nfsshare/_nfs_PARAMS.html.ep
Normal file → Executable file
0
Targets/Nfsshare/_nfs_PARAMS.html.ep
Normal file → Executable file
0
Targets/Nfsshare/_nfs_TABLE.html.ep
Normal file → Executable file
0
Targets/Nfsshare/_nfs_TABLE.html.ep
Normal file → Executable file
0
Targets/Nfsshare/nfs_PARAMS.html.ep
Normal file → Executable file
0
Targets/Nfsshare/nfs_PARAMS.html.ep
Normal file → Executable file
0
Targets/Nfsshare/nfs_TABLE.html.ep
Normal file → Executable file
0
Targets/Nfsshare/nfs_TABLE.html.ep
Normal file → Executable file
0
Targets/Nfsshare/nfsshare-lexfiles.zip
Normal file → Executable file
0
Targets/Nfsshare/nfsshare-lexfiles.zip
Normal file → Executable file
0
Targets/Nfsshare/nfsshare.html.ep
Normal file → Executable file
0
Targets/Nfsshare/nfsshare.html.ep
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_bg.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_bg.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_de.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_de.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_dk.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_dk.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_el.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_el.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_en.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_en.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_en.po
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_en.po
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_es.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_es.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_es.po
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_es.po
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_et.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_et.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_fr.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_fr.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_hu.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_hu.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_id.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_id.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_il.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_il.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_it.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_it.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_jp.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_jp.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_nl.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_nl.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_no.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_no.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_pl.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_pl.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_pt-br.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_pt-br.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_pt.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_pt.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_ro.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_ro.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_ru.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_ru.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_sl.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_sl.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_sv.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_sv.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_th.lex
Normal file → Executable file
0
Targets/Nfsshare/nfsshare_th.lex
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user