% if ($confirm) { <& /request_confirm.html, %ARGS &> % return; % }
Please provide your email address that you used to subscribe to our mailing list and we'll send the voting code to you.
% if ($msg) {Hint: <% $msg %>
% } <%init> my $confirm; my $msg; my $status; $confirm = 0; ($status, $msg) = sanitize_email_input(\%ARGS); if ($status) { $ARGS{'ip'} = $r->connection->remote_ip(); ($status, $msg) = send_vote_code_to_email(\%ARGS); if ($status) { $confirm = 1; } else { $msg = "Sorry, the voting code has been sent to this email address before. To avoid spam, we don't send voting code to the same email address more than once every day. Please try again the next day.\n"; } } sub sanitize_email_input { my ($args) = (@_); my $pat; if ($args->{action} ne 'Request') { return (0, ""); # initial page load } $pat = '-_a-zA-z.0-9@'; if ($args->{email} !~ /^[$pat]+$/) { $args->{email} =~ s/[^$pat]+//g; return (0, "Please limit your email address to English letters, underscore (_), hyphen (-), digits, @ and dot (.).\n"); } if (!check_email_in_list($args->{email})) { return (0, "Sorry, your email address is not in our mailing list. Please join our mailing list first.\n"); } # Need to check when we sent the email last time if any return (1, ""); } %init> % # vim: filetype=mason