use strict;
use diagnostics;
use warnings;
use CGI;
my $q = new CGI;
my $user_name = $q->param('user_name');
my $gender = $q->param('gender');
my $real_name = $q->param('real_name');
my $city = $q->param('city');
my $country = $q->param('country');
my $email = $q->param('email');
my $confirmemail = $q->param('confirmemail');
my $mm = $q->param('birthmm');
my $dd = $q->param('birthdd');
my $yy = $q->param('birthyy');
my ($title, $body, $i, $s, @v, @c);
#---------------------------------------------------------------------
#START OF MAIN PROGRAM
#---------------------------------------------------------------------
my ($password) = &password(5);
my $dateofbirth = ("$dd/$mm/$yy");
my @info = ($user_name, $password, $email, $gender, $real_name, $dateofbirth, $city, $country);
open(USRNF,"pass") or die "Couldn't find user file.\n";
if ($email ne $confirmemail){
($title, $body) = &email_invalid();}
elsif (&check_user_email($user_name,$email) eq "good"){
($title, $body) = &good(@info);}
else {
($title, $body) = &check_user_email($user_name,$email);
}
print qq(Content-type: text/html\n
$title
$body
);
#---------------------------------------------------------------------
#END OF MAIN PROGRAM:BEGINING OF VERIFICATION
#---------------------------------------------------------------------
sub email_invalid {
my $title = "Email's do not match!!";
my $body = q(
Your e-mail doesn't match.
Please click on your browsers back button and try again.
);
return ($title, $body);
}
#---------------------------------------------------------------------
sub check_user_email{
while(){
chomp;
my $user = @_;
my $email = @_;
my (@userinfo) = split(/\t/, $_);
if ( ($userinfo[0] ne $user) && ($userinfo[2] ne $email) ){
return "good";
}
elsif ( $userinfo[0] eq $user ){
my $title = "User name already in use.!";
my $body = q(
The username $user is already in use.
Please click on your browser's back button and try a different one.
);
return ($title, $body);
}
else {
my $title = "Account already activated.!";
my $body = q(
Our records show that you already have a valid account.
If you wish to create another one you must first delete the old one.
Please email me here to edit any account info.
);
return ($title, $body);
close(USRNF);
}
}
#---------------------------------------------------------------------
sub good{
my @info = @_;
my $title = "Registration successful!";
my $body = q(
Registration Confirmation
Dear , $real_name
Thank you for registering with us. You have supplied us with
the following information:
Real name:\t$real_name
Username:\t$user_name
Password:\t$password
E-mail:\t$email
Date of Birth:\t$dateofbirth
City:\t$city
Country:\t$country
If any of this information is incorrect, please email me here to change it. I
reserve the right to delete any user if he\she use this account
for illegal purposes.
Sincerely,
Webmaster, Eoin.
You may return to the feedback form by using the Back
button in your browser.
Revised: December 31, 2002.
);
open(USRNF,">>pass") or die "Couldn't find user file.\n";
printf USRNF "$info[0] $info[1] $info[2] $info[3]. $info[4] $info[5] $info[6] $info[7]";
close(USRNF);
return($title, $body);
}
sub password{
$s = @_;
srand($s ^ time);
@c=split(/ */, "bcdfghjklmnpqrstvwxyz");
@v=split(/ */, "aeiou");
for($i = 1; $i <= 4; $i += 1)
{
my $password = print $c[int(rand(20))], $v[int(rand(5))]
}
}}