#!/usr/bin/perl
print "Content-type: text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);
      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
      $cgi{$name} = $value;
}
# load in the form contents
$real = $cgi{'realname'};
$email = $cgi{'email'};
$nick = $cgi{'username'};
if((length($real)) == 0){
	print "<BLINK>Please go back and fill the name...";
}elsif(length($email) == 0){
	print "<BLINK>Please go back and fill the email...";
}elsif(length($nick) == 0){
	print "<BLINK>Please go back and fill the nickname...";
}
$time = localtime(time);
@rad = split(/ /,$time);
@time = split(/:/,@rad[3]);
$rad = @time[2]*7;
open(F,"rad.dat");
while(<F>){
	$rad = eval($rad) + $_;
}
close(F);
open(F,">rad.dat");
print F $rad;
close(F);
$passwd = "kims";
$cryptpasswd = crypt($passwd,"43");
open(FP,">>/usr/local/etc/httpd/cgi-bin/kims/chk/.htpasswd");
print FP "kims:$cryptpasswd\n";
close(FP);
exit;
open(MAIL,"| /bin/mail $email");
print MAIL "From: root\@ezenet.com\n";
print MAIL "Subject: Your Login name and Password\n";
print MAIL "Hello";
close(MAIL);
print "<BR><BR><BR>\n";
print "Your password has been send to Your email address\n";
print "Please check your email to get your password\n";
