I am trying to modify the signup so that the admin is notified by e-mail that a new user has signed up and what his/ her login name is. I stole the following from the validate mod but I definately have the syntax wrong if I don't have more wrong. I added the following variables to the authorization section of default.cfg:
# Full path to sendmail on your system
$mailprog = "|/usr/sbin/sendmail";
# Fieldname that contains the email address of the user
$db_email_field = 'e-mail';
# Your email address
$admin_email = '*****.******@******.org';
Here's my feable attempt to write add the mail script to the sub_signup section of db.cgi:
sub signup {
# --------------------------------------------------------
# Allows a user to sign up without admin approval. Must have $auth_signup = 1
# set. The user gets @default_permissions.
#
my $message;
# Check to make sure userid is ok, pw ok, and userid is unique.
unless ((length($in{'userid'}) >= 5) and (length($in{'userid'}) <= 30) and ($in{'userid'} =~ /^[a-zA-Z0-9\.]+$/)) {
$message = "Invalid userid: $in{'userid'}. Must only contain only letters and be less then 30 and greater then 5 characters.";
}
unless ((length($in{'pw'}) >= 3) and (length($in{'pw'}) <= 12)) {
$message = "Invalid pw: '$in{'pw'}'. Must be less then 12 and greater then 3 characters.";
}
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1); }
while (<PASS>) {
/^\Q$in{'userid'}\E:/ and ($message = "userid already exists. Please try another.");
}
unless ($in{'question1'} =~ /griffiths/i) {
$message = "$in{'question1'} is not a correct answer.";
}
unless ($in{'question2'} =~ /west end/i) {
$message = "$in{'question2'} is not a correct answer.";
}
unless ($in{'question3'} =~ /pavilion/i) {
$message = "$in{'question3'} is not a correct answer.";
}
close PASS;
if ($message) {
&html_signup_form ($message);
return;
}
# Add the userid into the file with default permissions.
open (PASS, ">>$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($in{'pw'}, $salt);
my $permissions = join (":", @auth_signup_permissions);
print PASS "$in{'userid'}:$encrypted:$permissions\n";
close PASS;
&html_signup_success;
}
# Send an email to the administrator telling him of the new user.
open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New Record at $html_title\n\n";
print MAIL "A new record was added at $html_title with the following information:\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}
print MAIL "\n\n";
close MAIL;
sub get_record {
# --------------------------------------------------------
# Given an ID as
# Full path to sendmail on your system
$mailprog = "|/usr/sbin/sendmail";
# Fieldname that contains the email address of the user
$db_email_field = 'e-mail';
# Your email address
$admin_email = '*****.******@******.org';
Here's my feable attempt to write add the mail script to the sub_signup section of db.cgi:
sub signup {
# --------------------------------------------------------
# Allows a user to sign up without admin approval. Must have $auth_signup = 1
# set. The user gets @default_permissions.
#
my $message;
# Check to make sure userid is ok, pw ok, and userid is unique.
unless ((length($in{'userid'}) >= 5) and (length($in{'userid'}) <= 30) and ($in{'userid'} =~ /^[a-zA-Z0-9\.]+$/)) {
$message = "Invalid userid: $in{'userid'}. Must only contain only letters and be less then 30 and greater then 5 characters.";
}
unless ((length($in{'pw'}) >= 3) and (length($in{'pw'}) <= 12)) {
$message = "Invalid pw: '$in{'pw'}'. Must be less then 12 and greater then 3 characters.";
}
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1); }
while (<PASS>) {
/^\Q$in{'userid'}\E:/ and ($message = "userid already exists. Please try another.");
}
unless ($in{'question1'} =~ /griffiths/i) {
$message = "$in{'question1'} is not a correct answer.";
}
unless ($in{'question2'} =~ /west end/i) {
$message = "$in{'question2'} is not a correct answer.";
}
unless ($in{'question3'} =~ /pavilion/i) {
$message = "$in{'question3'} is not a correct answer.";
}
close PASS;
if ($message) {
&html_signup_form ($message);
return;
}
# Add the userid into the file with default permissions.
open (PASS, ">>$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($in{'pw'}, $salt);
my $permissions = join (":", @auth_signup_permissions);
print PASS "$in{'userid'}:$encrypted:$permissions\n";
close PASS;
&html_signup_success;
}
# Send an email to the administrator telling him of the new user.
open (MAIL, "$mailprog") or &cgierr("unable to open mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: New Record at $html_title\n\n";
print MAIL "A new record was added at $html_title with the following information:\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $rec{$column}\n";
}
print MAIL "\n\n";
close MAIL;
sub get_record {
# --------------------------------------------------------
# Given an ID as