###############################################################################
# Register.pl #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 1 Gold - SP 1.1 #
# Released: December 2001; Updated March 22, 2002 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2002 Xnull (www.xnull.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
$registerplver = "1 Gold - SP 1.1";
sub Register {
# add in dynamic number
$randomnumber = time;
$yymain .= qq~
<table border=0 width=100% cellspacing=1 bgcolor="$color{'bordercolor'}" class="bordercolor" cellpadding="2">
<tr>
<td class="titlebg" bgcolor="$color{'titlebg'}">
<img src="$imagesdir/register.gif" alt="$txt{'97'}" border="0"> <font size=2 class="text1" color="$color{'titletext'}"><b>$txt{'97'}</b> $txt{'517'}</font></td>
</tr><tr>
<td class="windowbg" bgcolor="$color{'windowbg'}" width="100%"><font size=2>
<form action="$cgi;action=register2" method="POST" name="creator">
<table cellpadding="3" cellspacing="0" border=0 width="100%">
<tr>
<td width="40%"><font size=2>* <b>Enter Code:</b></font> <img src="Sources/captcha.cgi?$randomnumber"></td>
<td><input type=text name=verifytext size=8 maxlength="10"></td>
</tr>
<tr>
<td width="40%"><font size=2>* <b>$txt{'98'}:</b></font>
<BR><font size="1">$txt{'520'}</font></td>
<td><input type=text name=username size=20 maxlength="18"></td>
</tr><tr>
<td width="40%"><font size=2>* <b>$txt{'69'}:</b></font>
<BR><font size="1">$txt{'679'}</font></td>
~;
if ($allow_hide_email == 1) { $yymain .= qq~
<td><font size=2><input type=text maxlength="40" name=email size=30> <input type="checkbox" name="hideemail" value="checked" checked> $txt{'721'}</font></td>
~;
} else { $yymain .= qq~
<td><input type=text name=email size=30>
<BR><font size="1">$txt{'679'}</font></td>
~;
}
$yymain .= qq~
</tr>
~;
unless( $emailpassword ) {
$yymain .= qq~
<tr>
<td width="40%"><font size=2>* <b>$txt{'81'}:</b></font></td>
<td><font size=2><input type=password maxlength="30" name=passwrd1 size=30></font></td>
</tr><tr>
<td width="40%"><font size=2>* <b>$txt{'82'}:</b></font></td>
<td><font size=2><input type=password maxlength="30" name=passwrd2 size=30></font></td>
</tr>
~;
}
$yymain .= qq~
</table>
</font>
</td>
</tr>
</table>
~;
if ($RegAgree) {
fopen(FILE, "$vardir/agreement.txt");
@agreement = <FILE>;
fclose(FILE);
$fullagree = join( "", @agreement );
$fullagree =~ s/\n/<BR>/g;
$yymain .= qq~
<table border=0 cellspacing=1 cellpadding="5" bgcolor="$color{'bordercolor'}" class="bordercolor" width="100%" align="center">
<tr>
<td bgcolor="$color{'windowbg2'}">
<font size=2><BR>$fullagree<BR><BR></font>
</td>
</tr><tr>
<td bgcolor="$color{'windowbg'}" align="center"><font size=2>
<B>$txt{'585'}</B> <input type=radio name=fflover value="yes">
<B>$txt{'586'}</B> <input type=radio name=fflover value="no" checked>
<div style="display: none;"><br>Are you a Russian spam bot? <B>Yes</B> <input type=radio name=regagree value="yes">
<B>No</B> <input type=radio name=regagree value="no" checked></div>
</font></td>
</tr>
</table>
~;
}
$yymain .= qq~
<BR><center><input type=submit value="$txt{'97'}"></center>
</form>
~;
$yytitle = "$txt{'97'}";
&template;
exit;
}
sub Register2 {
# add captcha check here
&checkcaptcha;
if($FORM{'regagree'} eq "yes") {
die "Be gone you Russian spambot";
}
if($FORM{'fflover'} eq "no") {
$yySetLocation = qq~$scripturl~;
&redirectexit;
}
my %member;
while( ($key,$value) = each(%FORM) ) {
$value =~ s~\A\s+~~;
$value =~ s~\s+\Z~~;
$value =~ s~[\n\r]~~g;
$member{$key} = $value;
}
$member{'username'} =~ s/\s/_/g;
if (length($member{'username'}) > 25) { $member{'username'} = substr($member{'username'},0,25); }
&fatal_error("($member{'username'}) $txt{'37'}") if($member{'username'} eq '');
&fatal_error("($member{'username'}) $txt{'99'}") if($member{'username'} eq '_' || $member{'username'} eq '|');
&fatal_error("$txt{'244'} $member{'username'}") if($member{'username'} =~ /guest/i);
&fatal_error("$txt{'240'} $txt{'35'} $txt{'241'}") if($member{'username'} !~ /\A[0-9A-Za-z#%+-\.@^_]+\Z/);
&fatal_error("$txt{'240'}") if($member{'username'} =~ /,/);
&fatal_error("($member{'username'}) $txt{'76'}") if($member{'email'} eq "");
&fatal_error("($member{'username'}) $txt{'100'}") if(-e ("$memberdir/$member{'username'}.dat"));
if ($send_welcomeim == 1) {
$messageid = $^T.$$;
$imtext =~ s/\&\&/\n/g;
$imtext =~ s/\</</g;
$imtext =~ s/\>/>/g;
$imtext =~ s/</</g;
$imtext =~ s/>/>/g;
$imtext =~ s/\t/ \ \ \ /g;
$imtext =~ s/\cM//g;
$imtext =~ s/\n/<br>/g;
$imtext =~ s/\|/\|/g;
fopen(FILE,">$memberdir/$member{'username'}.msg", 1);
print FILE "$sendname|$imsubject|$date|$imtext|$messageid|$ENV{'REMOTE_ADDR'}|1\n";
fclose(FILE);
}
if( $emailpassword ) {
srand();
$member{'passwrd1'} = int( rand(100) );
$member{'passwrd1'} =~ tr/0123456789/ymifxupbck/;
$_ = int( rand(77) );
$_ =~ tr/0123456789/q8dv7w4jm3/;
$member{'passwrd1'} .= $_;
$_ = int( rand(89) );
$_ =~ tr/0123456789/y6uivpkcxw/;
$member{'passwrd1'} .= $_;
$_ = int( rand(188) );
$_ =~ tr/0123456789/poiuytrewq/;
$member{'passwrd1'} .= $_;
$_ = int( rand(65) );
$_ =~ tr/0123456789/lkjhgfdaut/;
$member{'passwrd1'} .= $_;
} else {
&fatal_error("($member{'username'}) $txt{'213'}") if($member{'passwrd1'} ne $member{'passwrd2'});
&fatal_error("($member{'username'}) $txt{'91'}") if($member{'passwrd1'} eq '');
&fatal_error("$txt{'240'} $txt{'36'} $txt{'241'}") if($member{'passwrd1'} !~ /\A[\s0-9A-Za-z!@#$%\^&*\(\)_\+|`~\-=\\:;'",\.\/?\[\]\{\}]+\Z/);
}
&fatal_error("$txt{'240'} $txt{'69'} $txt{'241'}") if($member{'email'} !~ /\A[0-9A-Za-z@\._\-]+\Z/);
&fatal_error("$txt{'500'}") if(($member{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($member{'email'} !~ /\A.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?\Z/));
fopen(FILE, "$vardir/ban_email.txt");
@banned = <FILE>;
fclose(FILE);
foreach $curban (@banned) {
if($member{'email'} eq "$curban") { &fatal_error("$txt{'678'}$txt{'430'}!"); }
}
fopen(FILE, "$memberdir/memberlist.txt");
@memberlist = <FILE>;
fclose(FILE);
$testname = lc $member{'username'};
for ($a = 0; $a < @memberlist; $a++) {
chomp $memberlist[$a];
$membername = lc $memberlist[$a];
if( fopen(FILE2, "$memberdir/$memberlist[$a].dat") ) {
# Load users and check email
if( !$yyUDLoaded{$memberlist[$a]} && -e("$memberdir/$memberlist[$a].dat") ) {
# If user is not in memory, s/he must be loaded.
&LoadUser($memberlist[$a]);
if($userprofile{$memberlist[$a]}->[2] eq $member{'email'}) { &fatal_error("$txt{'730'} ($member{'email'}) $txt{'731'}"); }
}
$tmpa=<FILE2>;
$realname=<FILE2>;
fclose(FILE2);
chomp $realname;
$realname = lc $realname;
if ($realname eq $testname || $membername eq $testname) { &fatal_error("($member{'username'}) $txt{'473'}"); }
}
elsif( $testname eq $membername ) { &fatal_error("($member{'username'}) $txt{'473'}"); }
}
&ToHTML($member{'email'});
fopen(FILE, "$vardir/reserve.txt") || &fatal_error("$txt{'23'} reserve.txt");
@reserve = <FILE>;
fclose(FILE);
fopen(FILE, "$vardir/reservecfg.txt") || &fatal_error("$txt{'23'} reservecfg.txt");
@reservecfg = <FILE>;
fclose(FILE);
for( $a = 0; $a < @reservecfg; $a++ ) {
chomp $reservecfg[$a];
}
$matchword = $reservecfg[0] eq 'checked';
$matchcase = $reservecfg[1] eq 'checked';
$matchuser = $reservecfg[2] eq 'checked';
$matchname = $reservecfg[3] eq 'checked';
$namecheck = $matchcase eq 'checked' ? $member{'username'} : lc $member{'username'};
foreach $reserved (@reserve) {
chomp $reserved;
$reservecheck = $matchcase ? $reserved : lc $reserved;
if ($matchuser) {
if ($matchword) {
if ($namecheck eq $reservecheck) { &fatal_error("$txt{'244'} $reserved"); }
}
else {
if ($namecheck =~ $reservecheck) { &fatal_error("$txt{'244'} $reserved"); }
}
}
}
&fatal_error("$txt{'100'})") if(-e ("$memberdir/$member{'username'}.dat"));
fopen(FILE, ">$memberdir/$member{'username'}.dat");
print FILE "$member{'passwrd1'}\n";
print FILE "$member{'username'}\n";
print FILE "$member{'email'}\n";
print FILE "\n\n\n0\n\n\n\n\n\n$txt{'209'}\nblank.gif\n$date\n\n\n\n\n";
if ($member{'hideemail'} ne "checked") { $member{'hideemail'} = ""; }
print FILE "$member{'hideemail'}\n";
fclose(FILE);
fopen(FILE, ">$memberdir/memberlist.txt", 1);
foreach $curmem (@memberlist) { print FILE "$curmem\n"; }
print FILE "$member{'username'}\n";
fclose(FILE);
my $membershiptotal = @memberlist + 1;
fopen(FILE, "+>$memberdir/members.ttl");
print FILE qq~$membershiptotal|$member{'username'}~;
fclose(FILE);
###### Start YaMS add-on Member-number ######
fopen(FILE, "$memberdir/membernumb.txt");
@membernumb = <FILE>;
$membernumber = @membernumb;
fclose(FILE);
fopen(FILE, ">$memberdir/membernumb.txt", 1);
foreach $curnum (@membernumb) {
chomp $curnum;
print FILE "$curnum\n";
}
print FILE "$membernumber|$member{'username'}\n";
fclose(FILE);
fopen(FILE, ">$memberdir/$member{'username'}.yam");
print FILE "$membernumber\n";
print FILE "0|0|0\n";
fclose(FILE);
chmod(0666,"$memberdir/$member{'username'}.yam");
###### End YaMS add-on Member-number ######
&FormatUserName($member{'username'});
if($emailpassword) {
&sendmail($member{'email'},"$txt{'700'} $mbname", "$txt{'248'} $member{'username'}!\n\n$txt{'719'} $member{'username'}, $txt{'492'} $member{'passwrd1'}.\n\n$txt{'701'}\n$scripturl?action=profile;username=$useraccount{$member{'username'}}\n\n$txt{'130'}");
$yymain .= qq~<BR><table border=0 width=100% cellspacing=1 bgcolor="$color{'bordercolor'}" class="bordercolor" align="center">~;
require "$sourcedir/LogInOut.pl";
$sharedLogin_title="$txt{'97'}";
$sharedLogin_text="$txt{'703'}";
&sharedLogin;
$yymain .= qq~</table>~;
}
else {
if($emailwelcome) {
&sendmail($member{'email'},"$txt{'700'} $mbname", "$txt{'248'} $member{'username'}!\n\n$txt{'719'} $member{'username'}, $txt{'492'} $member{'passwrd1'}.\n\n$txt{'701'}\n$scripturl?action=profile;username=$useraccount{$member{'username'}}\n\n$txt{'130'}");
}
$yymain .= qq~
<BR><BR>
<table border=0 width=300 cellspacing=1 bgcolor="$color{'bordercolor'}" class="bordercolor" align="center">
<tr>
<td class="titlebg" bgcolor="$color{'titlebg'}">
<img src="$imagesdir/register.gif" alt="$txt{'97'}" border="0"> <font size=2 class="text1" color="$color{'titletext'}"><b>$txt{'97'}</b></font></td>
</tr><tr>
<td class="windowbg" bgcolor="$color{'windowbg'}" align="center"><font size=2><form action="$cgi;action=login2" method="POST">
<BR>$txt{'431'}<BR><BR>
<input type=hidden name="username" value="$member{'username'}">
<input type=hidden name="passwrd" value="$member{'passwrd1'}">
<input type=hidden name="cookielength" value="$Cookie_Length">
<input type=submit value="$txt{'34'}">
</form></font></td>
</tr>
</table>
<BR><BR>
~;
}
if ($popup_on) { $y = "on"; }
open(FILE, ">$memberdir/$member{'username'}.imconfig");
print FILE "\n\n$sound\n$y";
close(FILE);
$yytitle="$txt{'245'}";
&template;
exit;
}
#########
# add in captcha subs
#########
# captcha uses everything below this line
sub checkcaptcha {
# path to temporary directory must be chmod 0777
$tempdir = "/server/location/of/yourdomain.com/cgi-bin/theGridiron/Sources/temp";
# use this program to remove all old temp files
# this keeps the director clean without setting up a cron job
opendir TMPDIR, "$tempdir";
@alltmpfiles = readdir TMPDIR;
foreach $oldtemp (@alltmpfiles) {
$age = 0;
$age = (stat("$tempdir/$oldtemp"))[9];
# if age is more than 18000 seconds or 5 hours
if ((time - $age) > 18000){unlink "$tempdir/$oldtemp";}
}
# lets block direct access that is not via the form post
if ($ENV{"REQUEST_METHOD"} ne "POST"){&captchanopost;}
# open the temp datafile for current user based on ip
$tempfile = "$tempdir/$ENV{'REMOTE_ADDR'}";
open (TMPFILE, "<$tempfile")|| ($nofile = 1);
(@tmpfile) = <TMPFILE>;
close TMPFILE;
# if no matching ip file check for a cookie match
# this will compensate for AOL proxy servers accessing images
if ($nofile == 1){
$cookieip = $ENV{HTTP_COOKIE};
$cookieip =~ /checkme=([^;]*)/;
$cookieip = $1;
if ($cookieip ne ""){
$tempfile = "$tempdir/$cookieip";
open (TMPFILE, "<$tempdir/$cookieip")|| &captchanofile;
(@tmpfile) = <TMPFILE>;
close TMPFILE;
}
}
$imagetext = $tmpfile[0];
chomp $imagetext;
#$verifytext = $FORM{'verifytext'};
# set the form input to lower case
$FORM{'verifytext'} = lc($FORM{'verifytext'});
# compare the form input with the file text
if ($FORM{'verifytext'} ne "$imagetext"){&captchaerror;}
# now delete the temp file so it cannot be used again by the same user
unlink "$tempdir/$ENV{'REMOTE_ADDR'}";
unlink "$tempdir/$cookieip";
# if no error continue with the program
}
sub captchaerror {
print "Content-type: text/html\n\n";
print "The code you input does not match the text on the image. You will
automatically be returned to the registration page in a moment.";
print qq~<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
redirTime = "5000";
redirURL = "http://www.fantasyfootballer.com/cgi-bin/theGridiron/YaBB.cgi?board=;action=register";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
// End -->
</script>
</HEAD>
<BODY onLoad="redirTimer()">
</BODY>~;
# now delete the temp file so it cannot be used again by the same user
unlink "$tempdir/$ENV{'REMOTE_ADDR'}";
exit;
}
sub captchanofile {
print "Content-type: text/html\n\n";
print "No file found for verification. You are most likely receiving this
error because you need a new image code on the registration page. Wait a moment,
and you will automatically be returned to the registration page and given a new image
code with which to register.";
print qq~<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
redirTime = "10000";
redirURL = "http://www.fantasyfootballer.com/cgi-bin/theGridiron/YaBB.cgi?board=;action=register";
function redirTimer() { self.setTimeout("self.location.href =
redirURL;",redirTime); }
// End -->
</script>
</HEAD>
<BODY onLoad="redirTimer()">
</BODY>~;
exit;
}
sub captchanopost {
print "Content-type: text/html\n\n";
print "Method not allowed, input must be via a form post.";
exit;
}
1;