#################################################################### # Ban email domains from signup # by JPDeni # Written 19 Jun 2000 # # This mod will allow you to prohibit users who have certain domains # in their email addresses. The most common use of this is to ban # free email domains, requiring users to give their true email # address. This mod will also allow you to edit the list of domains # within the DBMan script, so you don't have to download the file, # edit it and then upload it again. # # The mod will, however, allow anyone with admin permission to add # a user who has a "banned" domain, through the Admin page. #################################################################### #################################################################### # Create a new directory in in your dbman directory -- email # Set the permissions for the directory to 777. # # You can pick up a set of files which list free domains at # http://www.jpdeni.com/dbman/Mods/email.zip # The list of domains is courtesy of LoisC. # # or you can create your own files. # # Be aware of the following: # you must have at least one file, even if it's empty, in the # directory # you can name the files anything you wish, but they must have a # ".txt" extension # the file names will be listed for you to choose the file you # want to edit, so the names should have some meaning to you # textareas will only hold about 29K of text. If you have more # than that, you will not be able to edit the files online. # (This is the reason the .zip distribution is broken up into # individual letter files.) # it doesn't matter which file a domain is listed in. All files # will be checked. # if you find that a file is too large to edit in the textarea, # you will need to download the file and break it into several # files offline. You will also have to create any new files # offline. # # However you get your starting files, they must be uploaded into # the "email" directory -- in ASCII mode --and the permissions for # each one must be set to 777. # # Do not put anything else into this directory, except for (if you # wish) an index.html file to prevent the listing of the directory. #################################################################### # In default.cfg, add the following to the # "# File and URL's" section # Full path and file name of the "bad email" file directory. $email_dir = $db_script_path . "/email"; #################################################################### # In html.pl, sub admin display, after &html_footer; # add print qq|
Edit banned domains
|; #################################################################### # In html.pl, add the following subroutine # The following is for those who are using the *default* html.pl # file. sub html_bad_email_form { # -------------------------------------------------------- # &html_print_headers; print qq| $html_title: Edit banned domains
$html_title: Edit banned domains

<$font_title>Edit banned domains

|; print "
<$font>"; opendir (MAILDIR, "$email_dir") || &cgierr("unable to open directory in html_bad_email_form: $email_dir. Reason: $!"); @files = readdir(MAILDIR); # Read in list of files in directory.. closedir (MAILDIR); FILE: foreach $file (sort @files) { next if ($file =~ /^\./); # Skip "." and ".." entries.. next if ($file =~ /^index/); # Skip index.htm type files.. $file =~ s/.txt//; print qq|$file |; } unless ($in{'email_file'}) { print qq|

To edit a file, click on the file name above.|; } else { open (EMAIL, "<$email_dir/$in{'email_file'}.txt") or &cgierr("error in html_bad_email_form. unable to open email file: $in{'email_file'}.txt.\nReason: $!"); if ($db_use_flock) { flock(EMAIL, 1); } @lines = ; close EMAIL; foreach $line (sort @lines) { $file_data .= $line; } print "

"; # < -- Start page text -- > print qq|

To add or delete a domain in this file, make changes in the text area below. Be sure to have just one domain per line. Don't forget to click the "Submit" button to save your changes.

To load a different file into the text area, click on the file name above.

|; # < -- End page text --> print qq|

|; } &html_footer; print qq|
|; } #################################################################### # In html.pl, add the following subroutine # The following is for those who are using the *user-friendly* html.pl # file. sub html_bad_email_form { # -------------------------------------------------------- # $page_title = "Edit banned domains"; &html_page_top; $submit_button = "Submit"; $reset_button = "Reset"; print "
<$font>"; opendir (MAILDIR, "$email_dir") || &cgierr("unable to open directory in html_bad_email_form: $email_dir. Reason: $!"); @files = readdir(MAILDIR); # Read in list of files in directory.. closedir (MAILDIR); FILE: foreach $file (sort @files) { next if ($file =~ /^\./); # Skip "." and ".." entries.. next if ($file =~ /^index/); # Skip index.htm type files.. $file =~ s/.txt//; print qq|$file |; } unless ($in{'email_file'}) { print qq|

To edit a file, click on the file name above.|; } else { open (EMAIL, "<$email_dir/$in{'email_file'}.txt") or &cgierr("error in html_bad_email_form. unable to open email file: $in{'email_file'}.txt.\nReason: $!"); if ($db_use_flock) { flock(EMAIL, 1); } @lines = ; close EMAIL; foreach $line (sort @lines) { $file_data .= $line; } print "

"; # < -- Start page text -- > print qq|

To add or delete a domain in this file, make changes in the text area below. Be sure to have just one domain per line. Don't forget to click the "Submit" button to save your changes.

To load a different file into the text area, click on the file name above.

|; # < -- End page text --> print qq|

|; } &html_footer; &html_page_bottom; } #################################################################### # In db.cgi, sub main, after elsif ($in{'admin_display'}) { if ($per_admin) { &admin_display; } else { &html_unauth; } } # add elsif ($in{'bad_email_form'}) { if ($per_admin) { &html_bad_email_form; } else { &html_unauth; } } elsif ($in{'bad_email'}) { if ($per_admin) { &bad_email; } else { &html_unauth; } } #################################################################### # In db.cgi, add the following subroutine sub bad_email { # -------------------------------------------------------- my (@emails,$email,$output); @emails = split "\n",$in{'save_file'}; foreach $email (@emails) { if ($email) { $output .= lc($email) . "\n"; } } chomp $output; open (EMAIL, ">$email_dir/$in{'save_file_name'}.txt") or &cgierr("error in bad_email. unable to open email file: $in{'save_file_name'}.txt.\nReason: $!"); if ($db_use_flock) { flock(EMAIL, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!"); } print EMAIL $output; close EMAIL; # automatically removes file lock &html_bad_email_form; } #################################################################### # In db.cgi, sub signup, before if ($message) { &html_signup_form ($message); return; } # add opendir (MAILDIR, "$email_dir") || &cgierr("unable to open directory in signup: $email_dir. Reason: $!"); @files = readdir(MAILDIR); # Read in list of files in directory.. closedir (MAILDIR); FILE: foreach $file (@files) { next if ($file =~ /^\./); # Skip "." and ".." entries.. next if ($file =~ /^index/); # Skip index.htm type files.. open (EMAIL, "<$email_dir/$file") or &cgierr("error in signup. unable to open email file: $file.\nReason: $!"); if ($db_use_flock) { flock(EMAIL, 1); } @lines = ; close EMAIL; CHECK: foreach $line (@lines) { chomp $line; if ($line eq lc(substr($in{'email'},index($in{'email'},'@')+1))) { $message .= "This site does not accept free e-mail accounts for registration. Please use your email address from you internet service provider.
"; last FILE; } } } #################################################################### # In db.cgi, sub parse_form, after $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # add $value =~ s/\r//g; #################################################################### # To edit the domains, log in with a username that has 'admin' # permission. Go to the "Admin" link. At the bottom of the page will # be a link to edit the domains.