From 9e16cdf50464553d1fba4c6933a300680a28ed48 Mon Sep 17 00:00:00 2001 From: Digimer Date: Tue, 31 Dec 2019 23:43:52 -0700 Subject: [PATCH] * Created Validate->is_email() to validate email addresses, using Mail::RFC822::Address. * Finished (but not yet tested) the menu to manage alert recipients. * Created Words->language_list() that creates a hash reference of available languages. Signed-off-by: Digimer --- Anvil/Tools/Validate.pm | 70 ++++++++- Anvil/Tools/Words.pm | 63 ++++++++- cgi-bin/striker | 257 ++++++++++++++++++++++++++++++++-- html/skins/alteeve/email.html | 211 ++++++++++++++++++++++++++++ rpm/SPECS/anvil.spec | 2 + share/words.xml | 21 +++ tools/test.pl | 6 + 7 files changed, 608 insertions(+), 22 deletions(-) diff --git a/Anvil/Tools/Validate.pm b/Anvil/Tools/Validate.pm index a1013a63..8b7858f0 100644 --- a/Anvil/Tools/Validate.pm +++ b/Anvil/Tools/Validate.pm @@ -7,6 +7,7 @@ use strict; use warnings; use Data::Dumper; use Scalar::Util qw(weaken isweak); +use Mail::RFC822::Address qw(valid validlist); our $VERSION = "3.0.0"; my $THIS_FILE = "Validate.pm"; @@ -15,6 +16,8 @@ my $THIS_FILE = "Validate.pm"; # form_field # is_alphanumeric # is_domain_name +# is_email +# is_hex # is_ipv4 # is_mac # is_positive_integer @@ -106,6 +109,8 @@ This is the type to be checked. Valid options are; =head4 domain_name +=head4 email + =head4 ipv4 =head4 mac @@ -118,6 +123,10 @@ If this type is used, you can use the C<< zero >> parameter which can be set to =head4 uuid +=head3 zero (optional, default '0') + +See 'type -> positive_integer' above for usage. + =cut sub form_field { @@ -135,6 +144,7 @@ sub form_field name => $name, type => $type, empty_ok => $empty_ok, + zero => $zero, }}); if ((not $name) or (not $type)) @@ -163,43 +173,49 @@ sub form_field } elsif (($type eq "alphanumeric") && (not $anvil->Validate->is_alphanumeric({string => $anvil->data->{cgi}{$name}{value}}))) { - $valid = 0; + $valid = 0; $anvil->data->{cgi}{$name}{alert} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); } elsif (($type eq "domain_name") && (not $anvil->Validate->is_domain_name({name => $anvil->data->{cgi}{$name}{value}}))) { - $valid = 0; + $valid = 0; + $anvil->data->{cgi}{$name}{alert} = 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); + } + elsif (($type eq "email") && (not $anvil->Validate->is_email({email => $anvil->data->{cgi}{$name}{value}}))) + { + $valid = 0; $anvil->data->{cgi}{$name}{alert} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); } elsif (($type eq "ipv4") && (not $anvil->Validate->is_ipv4({ip => $anvil->data->{cgi}{$name}{value}}))) { - $valid = 0; + $valid = 0; $anvil->data->{cgi}{$name}{alert} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); } elsif (($type eq "mac") && (not $anvil->Validate->is_mac({mac => $anvil->data->{cgi}{$name}{value}}))) { - $valid = 0; + $valid = 0; $anvil->data->{cgi}{$name}{alert} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); } elsif (($type eq "positive_integer") && (not $anvil->Validate->is_positive_integer({number => $anvil->data->{cgi}{$name}{value}, zero => $zero}))) { - $valid = 0; + $valid = 0; $anvil->data->{cgi}{$name}{alert} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); } elsif (($type eq "subnet_mask") && (not $anvil->Validate->is_subnet_mask({subnet_mask => $anvil->data->{cgi}{$name}{value}}))) { - $valid = 0; + $valid = 0; $anvil->data->{cgi}{$name}{alert} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); } elsif (($type eq "uuid") && (not $anvil->Validate->is_uuid({uuid => $anvil->data->{cgi}{$name}{value}}))) { - $valid = 0; + $valid = 0; $anvil->data->{cgi}{$name}{alert} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); } @@ -349,6 +365,46 @@ sub is_hex return($valid); } + +=head2 is_email + +Checks if the passed-in string is a valid address. Returns 'C<< 1 >>' if OK, 'C<< 0 >>' if not. + + $email = "test@example.com"; + if ($anvil->Validate->is_email({email => $email})) + { + print "The email address: [$email] is valid!\n"; + } + +Parameters; + +=head3 email (required) + +This is the email address to verify. + +=cut +sub is_email +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + + my $email = defined $parameter->{email} ? $parameter->{email} : ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { email => $email }}); + + # Validating email ourself is madness... See (TODO: link to email validation email). So we use + # 'Mail::RFC822::Address'. + my $valid = 0; + if (valid($email)) + { + $valid = 1; + } + + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { valid => $valid }}); + return($valid); +} + =head2 is_ipv4 Checks if the passed-in string is an IPv4 address. Returns 'C<< 1 >>' if OK, 'C<< 0 >>' if not. diff --git a/Anvil/Tools/Words.pm b/Anvil/Tools/Words.pm index acad4a63..a1ba5195 100644 --- a/Anvil/Tools/Words.pm +++ b/Anvil/Tools/Words.pm @@ -21,6 +21,7 @@ my $THIS_FILE = "Words.pm"; # clean_spaces # key # language +# language_list # parse_banged_string # read # string @@ -231,6 +232,20 @@ Set the output langauge to Japanese; $anvil->Words->language({set => "jp"}); +Parameters; + +=head3 iso (optional, default is active language) + +If C<< long >> is set, this can be used to query the long language name of the ISO code set here. If C<< long >> isn't set, this is ignored. + +=head3 long (optional, default '0') + +If set to an ISO code, the active default language is changed to the given language. If the long language name is not found, an empty string is returned. + +=head3 set (optional) + +If set to C<< 1 >>, the long version of the active language is returned. + =cut sub language { @@ -239,7 +254,9 @@ sub language my $anvil = $self->parent; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; - my $set = defined $parameter->{set} ? $parameter->{set} : ""; + my $iso = defined $parameter->{iso} ? $parameter->{iso} : ""; + my $long = defined $parameter->{long} ? $parameter->{long} : ""; + my $set = defined $parameter->{set} ? $parameter->{set} : ""; if ($set) { @@ -251,7 +268,49 @@ sub language $self->{WORDS}{LANGUAGE} = $anvil->data->{defaults}{language}{output}; } - return($self->{WORDS}{LANGUAGE}); + my $return = $self->{WORDS}{LANGUAGE}; + if ($long) + { + my $name = ""; + $iso = $self->{WORDS}{LANGUAGE} if not $iso; + foreach my $this_file (sort {$a cmp $b} keys %{$anvil->data->{words}}) + { + if ((exists $anvil->data->{words}{$this_file}{language}{$iso}{long_name}) && ($anvil->data->{words}{$this_file}{language}{$iso}{long_name})) + { + $name = $anvil->data->{words}{$this_file}{language}{$iso}{long_name}; + last; + } + } + return($name); + } + + return($return); +} + +=head2 language_list + +This creates a hashed list if languages available on the system. The list is stored as C<< sys::languages:: = >>. + +=cut +sub language_list +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + + foreach my $this_file (sort {$a cmp $b} keys %{$anvil->data->{words}}) + { + foreach my $iso (sort {$a cmp $b} keys %{$anvil->data->{words}{$this_file}{language}}) + { + if ((exists $anvil->data->{words}{$this_file}{language}{$iso}{long_name}) && ($anvil->data->{words}{$this_file}{language}{$iso}{long_name})) + { + $anvil->data->{sys}{languages}{$iso} = $anvil->data->{words}{$this_file}{language}{$iso}{long_name}; + } + } + } + + return(9); } =head2 parse_banged_string diff --git a/cgi-bin/striker b/cgi-bin/striker index e5949dde..a9de2b0d 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -408,9 +408,9 @@ sub process_email_recipient_page my $recipient_uuid = defined $anvil->data->{cgi}{recipient_uuid}{value} ? $anvil->data->{cgi}{recipient_uuid}{value} : ""; my $recipient_name = defined $anvil->data->{cgi}{recipient_name}{value} ? $anvil->data->{cgi}{recipient_name}{value} : ""; my $recipient_email = defined $anvil->data->{cgi}{recipient_email}{value} ? $anvil->data->{cgi}{recipient_email}{value} : ""; - my $recipient_language = defined $anvil->data->{cgi}{recipient_language}{value} ? $anvil->data->{cgi}{recipient_language}{value} : ""; - my $recipient_units = defined $anvil->data->{cgi}{recipient_units}{value} ? $anvil->data->{cgi}{recipient_units}{value} : ""; - my $recipient_new_level = defined $anvil->data->{cgi}{recipient_new_level}{value} ? $anvil->data->{cgi}{recipient_new_level}{value} : ""; + my $recipient_language = defined $anvil->data->{cgi}{recipient_language}{value} ? $anvil->data->{cgi}{recipient_language}{value} : "en_CA"; + my $recipient_units = defined $anvil->data->{cgi}{recipient_units}{value} ? $anvil->data->{cgi}{recipient_units}{value} : "metric"; + my $recipient_new_level = defined $anvil->data->{cgi}{recipient_new_level}{value} ? $anvil->data->{cgi}{recipient_new_level}{value} : "2"; my $delete = defined $anvil->data->{cgi}{'delete'}{value} ? $anvil->data->{cgi}{'delete'}{value} : ""; my $back = defined $anvil->data->{cgi}{back}{value} ? $anvil->data->{cgi}{back}{value} : ""; my $save = defined $anvil->data->{cgi}{save}{value} ? $anvil->data->{cgi}{save}{value} : ""; @@ -498,9 +498,9 @@ WHERE # Clear the form $recipient_name = ""; $recipient_email = ""; - $recipient_language = ""; - $recipient_units = ""; - $recipient_new_level = ""; + $recipient_language = "en_CA"; + $recipient_units = "metric"; + $recipient_new_level = "2"; } else { @@ -510,9 +510,9 @@ WHERE $anvil->data->{form}{back_link} =~ s/save=.*?$//; $anvil->data->{form}{refresh_link} = ""; $anvil->data->{form}{body} = $anvil->Template->get({file => "email.html", name => "recipient-delete-confirm", variables => { - recipient_name => $recipient_name, - recipient_email => $recipient_email - mail_server_uuid => $mail_server_uuid, + recipient_name => $recipient_name, + recipient_email => $recipient_email, + recipient_uuid => $recipient_uuid, }}); return(0); } @@ -520,20 +520,248 @@ WHERE } } - # Are we saving? + # If we're saving, make sure we have a valid email address and a name. + if ($save) + { + # Did the user give both an email address and name? + if ((not $recipient_name) or (not $recipient_name)) + { + # Which was missing? + if (not $recipient_name) + { + $anvil->data->{cgi}{recipient_name}{alert} = 1; + } + if (not $recipient_email) + { + $anvil->data->{cgi}{recipient_email}{alert} = 1; + } + $save = ""; + $confirm = ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + save => $save, + confirm => $confirm, + }}); + } + + # Verify that the mail server and ports are sane. + if (not $anvil->Validate->is_email({email => $recipient_email})) + { + # Bad domain + my $error_message = $anvil->Words->string({key => "warning_0026"}); + $anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $error_message }}); + $anvil->data->{cgi}{recipient_email}{alert} = 1; + $save = ""; + $confirm = ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + error_message => $error_message, + "form::error_massage" => $anvil->data->{form}{error_massage}, + "cgi::recipient_email::alert" => $anvil->data->{cgi}{recipient_email}{alert}, + save => $save, + confirm => $confirm, + }}); + } + } + + # Are we still saving? if ($save) { # Have we confirmed? if ($confirm) { - # Save the changes. + ($recipient_uuid) = $anvil->Database->insert_or_update_recipients({ + debug => 2, + recipient_uuid => $recipient_uuid, + recipient_name => $recipient_name, + recipient_email => $recipient_email, + recipient_language => $recipient_language, + recipient_units => $recipient_units, + recipient_new_level => $recipient_new_level, + }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { recipient_uuid => $recipient_uuid }}); + if ($recipient_uuid) + { + # Saved successfully. + my $ok_message = $anvil->Words->string({key => "ok_0004"}); + $anvil->data->{form}{ok_message} = $anvil->Template->get({file => "main.html", name => "ok_message", variables => { ok_message => $ok_message }}); + + # Clear the form + $recipient_uuid = ""; + $recipient_name = ""; + $recipient_email = ""; + $recipient_language = "en_CA"; + $recipient_units = "metric"; + $recipient_new_level = "2"; + } + else + { + # Something went wrong... + my $error_message = $anvil->Words->string({key => "warning_0027"}); + $anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $error_message }}); + } } else { - # Ask them to confirm + my $say_recipient_units = "#!string!unit_0027!#"; + if ($recipient_language eq "imperial") + { + $say_recipient_units = "#!string!unit_0028!#"; + } + # Ignore + my $say_recipient_new_level = "#!string!unit_0023!#"; + if ($recipient_new_level eq "1") + { + # Critical + $say_recipient_new_level = "#!string!unit_0024!#"; + } + elsif ($recipient_new_level eq "2") + { + # Warning + $say_recipient_new_level = "#!string!unit_0025!#"; + } + elsif ($recipient_new_level eq "3") + { + # Notice + $say_recipient_new_level = "#!string!unit_0026!#"; + } + my $say_recipient_language = $anvil->Words->language({iso => $recipient_language, long => 1}); + $say_recipient_language = "???" if not $say_recipient_language; + + # Ask the user 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 => "recipient-confirm", variables => { + recipient_uuid => $recipient_uuid, + recipient_name => $recipient_name, + recipient_email => $recipient_email, + recipient_language => $recipient_language, + say_recipient_language => $say_recipient_language, + recipient_units => $recipient_units, + say_recipient_units => $say_recipient_units, + recipient_new_level => $recipient_new_level, + say_recipient_new_level => $say_recipient_new_level, + }}); + return(0); } } + # Get a list of existing alert recipients. + my $query = "SELECT recipient_uuid, recipient_name, recipient_email FROM recipients WHERE recipient_name != 'DELETED' ORDER BY recipient_name 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 $recipients_form = ""; + if ($count) + { + # Build the list of existing mail servers + $recipients_form .= $anvil->Template->get({file => "email.html", name => "recipient-entry-open"});; + foreach my $row (@{$results}) + { + + my $recipient_uuid = $row->[0]; + my $recipient_name = $row->[1]; + my $recipient_email = $row->[2]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + recipient_uuid => $recipient_uuid, + recipient_name => $recipient_name, + recipient_email => $recipient_email, + }}); + + $recipients_form .= $anvil->Template->get({file => "email.html", name => "recipient-entry", variables => { + name => $recipient_name." (".$recipient_email.")", + uuid => $recipient_uuid, + }});; + } + $recipients_form .= $anvil->Template->get({file => "email.html", name => "recipient-entry-close"});; + } + + # Name + my $recipient_name_class = $anvil->data->{cgi}{recipient_name}{alert} ? "input_alert" : "input_clear"; + my $recipient_name_form = $anvil->Template->get({file => "main.html", name => "input_text_form", variables => { + name => "recipient_name", + id => "recipient_name", + field => "#!string!striker_0194!#", + description => "#!string!striker_0195!#", + value => $recipient_name, + default_value => "", + class => $recipient_name_class, + extra => "", + }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { recipient_name_form => $recipient_name_form }}); + + # Email + my $recipient_email_class = $anvil->data->{cgi}{recipient_email}{alert} ? "input_alert" : "input_clear"; + my $recipient_email_form = $anvil->Template->get({file => "main.html", name => "input_text_form", variables => { + name => "recipient_email", + id => "recipient_email", + field => "#!string!striker_0196!#", + description => "#!string!striker_0197!#", + value => $recipient_email, + default_value => "", + class => $recipient_email_class, + extra => "", + }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { recipient_email_form => $recipient_email_form }}); + + # Language (select) + $anvil->Words->language_list(); + my $options = []; + foreach my $iso (sort {$a cmp $b} keys %{$anvil->data->{sys}{languages}}) + { + push @{$options}, $iso."#!#".$anvil->data->{sys}{languages}{$iso}; + } + my $recipient_language_select = $anvil->Template->select_form({ + name => "recipient_language", + options => $options, + blank => 0, + selected => $recipient_language, + class => $anvil->data->{cgi}{recipient_language}{alert} ? "input_alert" : "input_clear", + }); + + # Units (select) + my $recipient_units_select = $anvil->Template->select_form({ + name => "recipient_units", + options => [ + "metric#!#".$anvil->Words->string({key => "unit_0027"}), + "imperial#!#".$anvil->Words->string({key => "unit_0028"}), + ], + blank => 0, + selected => $recipient_units, + class => $anvil->data->{cgi}{recipient_units}{alert} ? "input_alert" : "input_clear", + }); + + # Log Level (select) + my $recipient_new_level_select = $anvil->Template->select_form({ + name => "recipient_new_level", + options => [ + "0#!#".$anvil->Words->string({key => "unit_0023"}), + "1#!#".$anvil->Words->string({key => "unit_0024"}), + "2#!#".$anvil->Words->string({key => "unit_0025"}), + "3#!#".$anvil->Words->string({key => "unit_0026"}), + ], + blank => 0, + selected => $recipient_new_level, + class => $anvil->data->{cgi}{recipient_new_level}{alert} ? "input_alert" : "input_clear", + }); + + # Show the menu. + $anvil->data->{form}{back_link} = "?"; + $anvil->data->{form}{refresh_link} = "?email=true&task=email_recipient"; + $anvil->data->{form}{body} = $anvil->Template->get({file => "email.html", name => "recipient-menu", variables => { + recipients => $recipients_form, + recipient_name => $recipient_name_form, + recipient_email => $recipient_email_form, + language => $recipient_language_select, + units => $recipient_units_select, + new_level => $recipient_new_level_select, + recipient_uuid => $recipient_uuid, + }}); + return(0); } @@ -641,6 +869,7 @@ WHERE $anvil->data->{form}{ok_message} = $anvil->Template->get({file => "main.html", name => "ok_message", variables => { ok_message => $ok_message }}); # Clear the form + $mail_server_uuid = ""; $outgoing_mail_server = ""; $login_name = ""; $login_password = ""; @@ -696,6 +925,7 @@ WHERE $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { helo_domain => $helo_domain }}); } + # Sanity check our save if ($save) { # Did the user give an outgoing mail server? @@ -772,6 +1002,7 @@ WHERE $anvil->data->{form}{ok_message} = $anvil->Template->get({file => "main.html", name => "ok_message", variables => { ok_message => $ok_message }}); # Clear the form + $mail_server_uuid = ""; $outgoing_mail_server = ""; $login_name = ""; $login_password = ""; @@ -907,7 +1138,7 @@ WHERE class => $anvil->data->{cgi}{authentication_method}{alert} ? "input_alert" : "input_clear", }); - # Still here, show the menu. + # Show the menu. $anvil->data->{form}{back_link} = "?"; $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 => { diff --git a/html/skins/alteeve/email.html b/html/skins/alteeve/email.html index f76fcb3b..3702778a 100644 --- a/html/skins/alteeve/email.html +++ b/html/skins/alteeve/email.html @@ -309,6 +309,100 @@ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ #!string!message_0156!# +
+   +
+ #!string!message_0157!# +
+   +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ #!string!striker_0190!# + +   #!variable!recipient_name!# (#!variable!recipient_email!#) + + + +
+ #!string!striker_0191!# + +   #!variable!say_alert_level!# + +
+ #!string!striker_0192!# + +   #!variable!say_recipient_language!# + +
+ #!string!striker_0193!# + +   #!variable!say_recipient_units!# + +
+   +
+ + + +
+
+   +
+ + @@ -363,3 +457,120 @@
+ + + + +   + + + + + #!string!striker_0187!# + + + + + + + + + + + + + + + +
+ #!variable!name!# + +   #!string!striker_0068!#   +
+ + + + + + + + +
+
+ + + + + + + + + + + + #!variable!recipients!# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+   +
+ #!string!message_0156!# +
+   +
+ #!string!message_0157!# +
+   +
+ #!string!striker_0188!# +
+ + #!variable!recipient_name!# +
+ + #!variable!recipient_email!# +
+ #!string!striker_0198!#
+ #!variable!language!# +
+ #!string!striker_0199!#
+ #!variable!units!# +
+ #!string!striker_0200!#
+ #!variable!new_level!# +
+   +
+ +
+ diff --git a/rpm/SPECS/anvil.spec b/rpm/SPECS/anvil.spec index 24f89e5f..05dbdfc3 100644 --- a/rpm/SPECS/anvil.spec +++ b/rpm/SPECS/anvil.spec @@ -50,6 +50,7 @@ Requires: perl-HTML-Strip Requires: perl-IO-Tty Requires: perl-JSON Requires: perl-Log-Journald +Requires: perl-Mail-RFC822-Address Requires: perl-Net-SSH2 Requires: perl-Net-Netmask Requires: perl-Net-OpenSSH @@ -354,6 +355,7 @@ fi %changelog * tbd Madison Kelly 3.0-31 +- Added perl-Mail-RFC822-Address to core requirements. - * Fri Dec 13 2019 Madison Kelly 3.0-30 diff --git a/share/words.xml b/share/words.xml index 65d01198..956a1aa4 100644 --- a/share/words.xml +++ b/share/words.xml @@ -261,6 +261,7 @@ About to try to download aproximately: [#!variable!packages!#] packages needed t Mail Server Configuration When alert emails are sent, they are stored locally and then forwarded to a mail server. This is where you can configure the mail server that alerts are forwarded to for delivery to recipients. Alert recipient Configuration + When a system alert is recorded, any alert recipient interested in that alert will be notified by email. This is determined by the alert's level, and the recipients alert level interest. If the alert's level is equal to or higher than a given alert, an email will be crafted for them, in their chosen language and units. Starting: [#!variable!program!#]. @@ -1049,6 +1050,17 @@ If you are comfortable that the target has changed for a known reason, you can s Existing mail servers: Clear the form Are you sure that you want to delete: + Alert Recipient + Alert level for future Anvil! systems + Language + Units + Recipient's Name + This is the name that will be displayed when sending an email to this user. + Recipient's Email + The email that alerts are sent to. + The language the user will receive alerts in. + Does the user want imperial or metric units? + The alert level used for new (and existing) Anvil! systems. #!variable!number!#/sec @@ -1196,6 +1208,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec Saved the mail server information successfully! The mail server: [#!variable!mail_server!#] has been deleted. The alert recipient: [#!variable!recipient_email!#] has been deleted. + Saved the alert recipient information successfully! The IP address will change. You will need to reconnect after applying these changes. @@ -1223,6 +1236,8 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec The outgoing mail server appear to not be a valid domain name or IP address. The outgoing mail server port is not valid. Must be 'mail_server:x' where x is 1 ~ 65535. There was a problem saving the mail server data. Please check the logs for more information. + The recipient's email address appears to not be valid. + There was a problem saving the alert recipient data. Please check the logs for more information. There are not enough network interfaces on this machine. You have: [#!variable!interface_count!#] interface(s), and you need at least: [#!variable!required_interfaces_for_single!#] interfaces to connect to the requested networks (one for Back-Channel and one for each Internet-Facing network). @@ -1372,6 +1387,12 @@ Failed to generate an RSA public key for the user: [#!variable!user!#]. The outp STP Disabled STP Enabled in Kernel STP Enabled in User land + Ignore + Critical + Warning + Notice + Metric + Imperial diff --git a/tools/test.pl b/tools/test.pl index 0a07028b..c243831e 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -31,3 +31,9 @@ print "DB Connections: [".$anvil->data->{sys}{database}{connections}."]\n"; #$anvil->Network->load_interfces({debug => 2}); #$anvil->System->generate_state_json({debug => 2}); + +$anvil->Words->language_list(); +foreach my $iso (sort {$a cmp $b} keys %{$anvil->data->{sys}{languages}}) +{ + print "iso: [".$iso."] -> [".$anvil->data->{sys}{languages}{$iso}."]\n"; +}