* Finished the mail server configuration menu. Mail servers can be added, edited, and deleted now.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent d4a5882bb4
commit 98211e1228
  1. 150
      cgi-bin/striker
  2. 117
      html/skins/alteeve/email.html
  3. 22
      html/skins/alteeve/email.js
  4. BIN
      html/skins/alteeve/images/delete.png
  5. 4
      html/skins/alteeve/images/sources.txt
  6. 37
      html/skins/alteeve/main.css
  7. 4
      share/words.xml

@ -406,15 +406,17 @@ sub process_email_server_page
my ($anvil) = @_;
# Prep the cgi variables.
my $mail_server_uuid = defined $anvil->data->{cgi}{mail_server_uuid}{value} ? $anvil->data->{cgi}{mail_server_uuid}{value} : "";
my $say_outgoing_mail_server = defined $anvil->data->{cgi}{outgoing_mail_server}{value} ? $anvil->data->{cgi}{outgoing_mail_server}{value} : "";
my $say_login_name = defined $anvil->data->{cgi}{login_name}{value} ? $anvil->data->{cgi}{login_name}{value} : "";
my $say_login_password = defined $anvil->data->{cgi}{login_password}{value} ? $anvil->data->{cgi}{login_password}{value} : "";
my $say_connection_security = defined $anvil->data->{cgi}{connection_security}{value} ? $anvil->data->{cgi}{connection_security}{value} : "ifn_link1";
my $say_authentication_method = defined $anvil->data->{cgi}{authentication_method}{value} ? $anvil->data->{cgi}{authentication_method}{value} : "ifn_link1";
my $say_port = defined $anvil->data->{cgi}{port}{value} ? $anvil->data->{cgi}{port}{value} : "";
my $say_authentication_method = defined $anvil->data->{cgi}{authentication_method}{value} ? $anvil->data->{cgi}{authentication_method}{value} : "normal_password";
my $say_port = defined $anvil->data->{cgi}{port}{value} ? $anvil->data->{cgi}{port}{value} : "143";
my $say_helo_domain = defined $anvil->data->{cgi}{helo_domain}{value} ? $anvil->data->{cgi}{helo_domain}{value} : "";
my $say_back = defined $anvil->data->{cgi}{back}{value} ? $anvil->data->{cgi}{back}{value} : "";
my $say_save = defined $anvil->data->{cgi}{save}{value} ? $anvil->data->{cgi}{save}{value} : "";
my $say_delete = defined $anvil->data->{cgi}{'delete'}{value} ? $anvil->data->{cgi}{'delete'}{value} : "";
my $say_confirm = defined $anvil->data->{cgi}{confirm}{value} ? $anvil->data->{cgi}{confirm}{value} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
say_outgoing_mail_server => $say_outgoing_mail_server,
@ -424,20 +426,109 @@ sub process_email_server_page
say_authentication_method => $say_authentication_method,
say_back => $say_back,
say_save => $say_save,
say_delete => $say_delete,
say_confirm => $say_confirm,
}});
if ($say_back)
{
$say_save = "";
$say_delete = "";
$say_confirm = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
say_save => $say_save,
say_confirm => $say_confirm,
say_save => $say_save,
say_delete => $say_delete,
say_confirm => $say_confirm,
}});
}
# if the user put a port on the mail server, break it off now.
# Are we loading an existing record?
if (($mail_server_uuid) && not ($say_save))
{
# Load. If we're deleting, we'll check 'mail_server_helo_domain' to see if it already was.
my $query = "
SELECT
mail_server_address,
mail_server_authentication,
mail_server_helo_domain,
mail_server_password,
mail_server_port,
mail_server_security,
mail_server_username
FROM
mail_servers
WHERE
mail_server_uuid = ".$anvil->Database->quote($mail_server_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
$say_outgoing_mail_server = $row->[0];
$say_authentication_method = $row->[1];
$say_helo_domain = $row->[2];
$say_login_password = $row->[3];
$say_port = $row->[4];
$say_connection_security = $row->[5];
$say_login_name = $row->[6];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
say_outgoing_mail_server => $say_outgoing_mail_server,
say_authentication_method => $say_authentication_method,
say_helo_domain => $say_helo_domain,
say_login_password => $say_login_password,
say_port => $say_port,
say_connection_security => $say_connection_security,
say_login_name => $say_login_name,
}});
if ($say_delete)
{
# Has the user confirmed?
if ($say_confirm)
{
# Delete.
$anvil->Database->insert_or_update_mail_servers({
debug => 2,
'delete' => 1,
mail_server_uuid => $mail_server_uuid,
});
# Saved successfully.
my $ok_message = $anvil->Words->string({key => "ok_0002", variables => { mail_server => $say_outgoing_mail_server }});
$anvil->data->{form}{ok_message} = $anvil->Template->get({file => "main.html", name => "ok_message", variables => { ok_message => $ok_message }});
# Clear the form
$say_outgoing_mail_server = "";
$say_login_name = "";
$say_login_password = "";
$say_connection_security = "";
$say_authentication_method = "";
}
else
{
# Ask them to confirm.
$anvil->data->{form}{back_link} = $anvil->data->{sys}{cgi_string};
$anvil->data->{form}{back_link} =~ s/save=.*?&//;
$anvil->data->{form}{back_link} =~ s/save=.*?$//;
$anvil->data->{form}{refresh_link} = "";
$anvil->data->{form}{body} = $anvil->Template->get({file => "email.html", name => "mail-server-delete-confirm", variables => {
outgoing_mail_server => $say_outgoing_mail_server,
mail_server_uuid => $mail_server_uuid,
}});
return(0);
}
}
}
}
# if the user put a port on the mail server, break it off now and override any passed in port.
# Normally, the port is set via a hidden variable when the security check box is changed.
my $test_outgoing_mail_server = $say_outgoing_mail_server;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { test_outgoing_mail_server => $test_outgoing_mail_server }});
if ($test_outgoing_mail_server =~ /^(.*):(\d+)$/)
@ -449,7 +540,7 @@ sub process_email_server_page
say_port => $say_port,
}});
}
else
elsif (not $say_port)
{
# Port wasn't passed. Use '143' unless $say_connection_security is 'ssl_tls'
$say_port = 143;
@ -525,8 +616,9 @@ sub process_email_server_page
if ($say_confirm)
{
# Save!
my ($mail_server_uuid) = $anvil->Database->insert_or_update_mail_servers({
($mail_server_uuid) = $anvil->Database->insert_or_update_mail_servers({
debug => 2,
mail_server_uuid => $mail_server_uuid,
mail_server_address => $test_outgoing_mail_server,
mail_server_authentication => $say_authentication_method,
mail_server_helo_domain => $say_helo_domain,
@ -560,8 +652,6 @@ sub process_email_server_page
{
# Ask the user to confirm
$anvil->data->{form}{back_link} = $anvil->data->{sys}{cgi_string};
$anvil->data->{form}{back_link} =~ s/login_password=.*?&//;
$anvil->data->{form}{back_link} =~ s/login_password=.*?$//;
$anvil->data->{form}{back_link} =~ s/save=.*?&//;
$anvil->data->{form}{back_link} =~ s/save=.*?$//;
$anvil->data->{form}{refresh_link} = "";
@ -574,10 +664,43 @@ sub process_email_server_page
connection_security => $say_connection_security,
authentication_method => $say_authentication_method,
helo_domain => $say_helo_domain,
mail_server_uuid => $mail_server_uuid,
}});
return(0);
}
}
# Get a list of existing mail servers.
my $query = "SELECT mail_server_uuid, mail_server_address FROM mail_servers WHERE mail_server_helo_domain != 'DELETED' ORDER BY mail_server_address ASC;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results,
count => $count,
}});
my $mail_servers_form = "";
if ($count)
{
# Build the list of existing mail servers
$mail_servers_form .= $anvil->Template->get({file => "email.html", name => "mail-server-entry-open"});;
foreach my $row (@{$results})
{
my $mail_server_uuid = $row->[0];
my $mail_server_address = $row->[1];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
mail_server_uuid => $mail_server_uuid,
mail_server_address => $mail_server_address,
}});
$mail_servers_form .= $anvil->Template->get({file => "email.html", name => "mail-server-entry", variables => {
name => $mail_server_address,
uuid => $mail_server_uuid,
}});;
}
$mail_servers_form .= $anvil->Template->get({file => "email.html", name => "mail-server-entry-close"});;
}
# Outgoing mail server
my $outgoing_mail_server_class = $anvil->data->{cgi}{outgoing_mail_server}{alert} ? "input_alert" : "input_clear";
@ -626,7 +749,7 @@ sub process_email_server_page
"ssl_tls#!#".$anvil->Words->string({key => "striker_0175"}),
"starttls#!#".$anvil->Words->string({key => "striker_0176"})
],
blank => 1,
blank => 0,
selected => $say_connection_security,
class => $anvil->data->{cgi}{connection_security}{alert} ? "input_alert" : "input_clear",
});
@ -642,20 +765,23 @@ sub process_email_server_page
"tls_certificate#!#".$anvil->Words->string({key => "striker_0181"}),
"oauth2#!#".$anvil->Words->string({key => "striker_0182"})
],
blank => 1,
blank => 0,
selected => $say_authentication_method,
class => $anvil->data->{cgi}{authentication_method}{alert} ? "input_alert" : "input_clear",
});
# Still here, show the menu.
$anvil->data->{form}{back_link} = "?";
$anvil->data->{form}{refresh_link} = "?email=true";
$anvil->data->{form}{refresh_link} = "?email=true&task=email_server";
$anvil->data->{form}{body} = $anvil->Template->get({file => "email.html", name => "mail-server-menu", variables => {
mail_servers => $mail_servers_form,
outgoing_mail_server => $outgoing_mail_server_form,
login_name => $login_name_form,
login_password => $login_password_form,
connection_security => $connection_security_select,
authentication_method => $authentication_method_select,
mail_server_uuid => $mail_server_uuid,
port => $say_port,
}});
return(0);

@ -1,6 +1,6 @@
<!-- start main-menu -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/email.js"></script>
<script type="text/javascript" src="#!data!skin::url!#/email.js"></script>
<tr>
<td colspan="2">
&nbsp;
@ -35,10 +35,49 @@
</table>
<!-- end main-menu -->
<!-- start mail-server-entry-open -->
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2" style="text-align: left; padding-bottom: 0.3em;">
#!string!striker_0187!#
</td>
</tr>
<tr>
<td colspan="2" style="text-align: left;">
<table class="list">
<!-- end mail-server-entry-open -->
<!-- start mail-server-entry -->
<tr>
<td class="column_row_value_fixed">
<a href="?email=true&task=email_server&mail_server_uuid=#!variable!uuid!#" class="fixed_link">#!variable!name!#</a>
</td>
<td>
&nbsp; <a href="?email=true&task=email_server&mail_server_uuid=#!variable!uuid!#&delete=true"><img src="#!data!skin::url!#/images/delete.png" alt="#!string!striker_0068!#" style="height: .8em;"></a> &nbsp;
</td>
</tr>
<!-- end mail-server-entry -->
<!-- start mail-server-entry-close -->
</table>
</td>
</tr>
<!-- end mail-server-entry-close -->
<!-- start mail-server-menu -->
<table align="center" class="mail_server">
<table align="center">
<script type="text/javascript" src="#!data!skin::url!#/email.js"></script>
<form name="mail_server" action="" method="post">
<div id="hostmail_server">
<div id="mail_server">
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2" class="title">
#!string!message_0154!#
@ -54,11 +93,17 @@
#!string!message_0155!#
</td>
</tr>
#!variable!mail_servers!#
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2" class="column_row_value_right">
<a href="?email=true&task=email_server">#!string!striker_0188!#</a>
</td>
</tr>
<tr>
<td colspan="2">
#!variable!outgoing_mail_server!#
@ -97,16 +142,18 @@
</td>
</tr>
</div>
<input type="hidden" name="email" id="email" value="true" />
<input type="hidden" name="task" id="task" value="email_server" />
<input type="hidden" name="email" id="email" value="true" />
<input type="hidden" name="task" id="task" value="email_server" />
<input type="hidden" name="port" id="port" value="#!variable!port!#" />
<input type="hidden" name="mail_server_uuid" id="mail_server_uuid" value="#!variable!mail_server_uuid!#" />
</form>
</table>
<!-- end mail-server-menu -->
<!-- start mail-server-confirm -->
<table align="center" class="mail_server">
<table align="center">
<form name="mail_server" action="" method="post">
<div id="hostmail_server">
<div id="mail_server">
<tr>
<td colspan="2" class="title">
#!string!message_0154!#
@ -137,6 +184,7 @@
<td class="column_row_value_fixed">
&nbsp; #!variable!say_outgoing_mail_server!#
<input type="hidden" name="outgoing_mail_server" id="outgoing_mail_server" value="#!variable!outgoing_mail_server!#"/>
<input type="hidden" name="mail_server_uuid" id="mail_server_uuid" value="#!variable!mail_server_uuid!#" />
<input type="hidden" name="port" id="port" value="#!variable!port!#"/>
</td>
</tr>
@ -205,3 +253,58 @@
</form>
</table>
<!-- end mail-server-confirm -->
<!-- start mail-server-delete-confirm -->
<table align="center">
<form name="mail_server" action="" method="post">
<div id="mail_server">
<tr>
<td colspan="2" class="title">
#!string!message_0154!#
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
<table align="center">
<tr>
<td class="column_header">
#!string!striker_0189!#
</td>
<td class="column_row_value_fixed">
&nbsp; #!variable!outgoing_mail_server!#
<input type="hidden" name="mail_server_uuid" id="mail_server_uuid" value="#!variable!mail_server_uuid!#"/>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="no_border">
<input type="submit" name="back" id="back" class="button" value="#!string!striker_0098!#">
</td>
<td class="no_border_right">
<input type="submit" name="confirm" id="confirm" class="button" value="#!string!striker_0082!#">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
</div>
<input type="hidden" name="email" id="email" value="true" />
<input type="hidden" name="task" id="task" value="email_server" />
<input type="hidden" name="delete" id="delete" value="true"/>
</form>
</table>
<!-- end mail-server-delete-confirm -->

@ -2,5 +2,25 @@ $.ajaxSetup({
cache: false
});
$(function() {
//console.log('Load');
if ($('#connection_security').length) {
//console.log('connection_security select exists');
$("#connection_security").change(function(){
var connection_security_value = $("#connection_security").val();
var port_value = $("#port").val();
//console.log('connection_security changed: ['+connection_security_value+'], port was: ['+port_value+']');
if (connection_security_value == 'ssl_tls') {
if (port_value != '993') {
$("#port").val('993');
//console.log('port changed to: ['+$("#port").val()+']');
}
}
else {
if (port_value != '143') {
$("#port").val('143');
//console.log('port changed to: ['+$("#port").val()+']');
}
}
});
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@ -67,3 +67,7 @@ Mail server Mail Server by SBTS from the Noun Project (https://thenounproject.co
Reader by Richa from the Noun Project
- email_recipient.png
Delete by Kavya from the Noun Project (https://thenounproject.com/term/delete/860236/)
- delete.png

@ -44,6 +44,9 @@ body {
border-radius: 3px;
}
.inline_button {
}
#center_body {
height: 100%;
}
@ -279,7 +282,9 @@ table {
}
table.centered {
margin: auto;
/*margin: auto;*/
margin-left: auto;
margin-right: auto;
}
table.data_table {
@ -293,11 +298,6 @@ table.data_table_nowrap {
white-space: nowrap;
}
table.centered {
margin-left: auto;
margin-right: auto;
}
td {
padding: 0;
border-collapse: collapse;
@ -350,6 +350,21 @@ td.column_row_value_right {
padding: 0.2em;
}
td.column_row_value_centered {
text-align: center;
color: #f7f7f7;
padding: 0.2em;
}
.fixed_link {
text-align: left;
color: #f7f7f7;
font-family: 'Dejavu Sans Mono', Courier;
padding: 0.2em;
font-size: 0.9em;
vertical-align: top;
}
td.column_row_value_fixed {
text-align: left;
color: #f7f7f7;
@ -432,6 +447,16 @@ tr.data_row {
text-align: center;
}
table.list {
/* margin-left: auto; */
/* margin-right: auto; */
padding-top: 0.2em;
padding-bottom: 0.2em;
padding-left: 0.4em;
padding-right: 0.4em;
border: 1px dotted #7f7f7f;
}
/* This is used for the 'configured' table as well */
table.unconfigured_table {
border: 1px solid blue;

@ -1045,6 +1045,9 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0184">Authentication method</key>
<key name="striker_0185">host_or_ip[:port]</key>
<key name="striker_0186">Indicates when the last time the OUI file was parsed. This is done to translate MAC addresses (and IPs associated with those MAC addresses) to the company that owns them.</key>
<key name="striker_0187">Existing mail servers:</key>
<key name="striker_0188">Clear the form</key>
<key name="striker_0189">Are you sure that you want to delete:</key>
<!-- These are generally units and appended to numbers -->
<key name="suffix_0001">#!variable!number!#/sec</key>
@ -1190,6 +1193,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<!-- Success messages shown to the user -->
<key name="ok_0001">Saved the mail server information successfully!</key>
<key name="ok_0002">The mail server: [#!variable!mail_server!#] has been deleted.</key>
<!-- Warnings -->
<key name="warning_0001">The IP address will change. You will need to reconnect after applying these changes.</key>

Loading…
Cancel
Save