Rev 17 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/perluse strict;use cPanelUserConfig;use RollerCon;use CGI;use CGI::Cookie;#my $cookie_string = authenticate(1) || die;#my ($EML, $PWD, $LVL) = split /&/, $cookie_string;my $query = new CGI;my ($FORM, $userref, $buttonValue, $RCid);my ($USRMSG, $USRMSGERR, $RO, $RCid_input) = ("", "", "", "");if ($ENV{'QUERY_STRING'}) {$FORM->{email} = $query->param('email');$FORM->{action} = $query->param('action');if ($FORM->{action} eq "Cancel") {$FORM->{email} = "";$FORM->{action} = "";$buttonValue = "Lookup";} elsif ($FORM->{action} eq "Lookup") {if ($userref = getUser($FORM->{email})) {$USRMSG = "User info found. Click Reset to reset your password, or Cancel to go back";$buttonValue = "Reset";$RO = "readonly";$RCid_input = "<input type=hidden name=RCid value=$userref->{RCid}>";} else {$USRMSGERR = "No user found with that email address.";$buttonValue = "Lookup";}} elsif ($FORM->{action} eq "Reset") {if ($userref = getUser($FORM->{email})) {if ($userref->{RCid} eq $query->param('RCid')) {&resetPass($FORM->{email});logit($userref->{RCid}, "Automated Password Reset");exit;} else {$USRMSGERR = "There appear to be shenanigans afoot. Please don't.";$buttonValue = "Lookup";}} else {$USRMSGERR = "There appears to be tomfoolery afoot. Please don't.";$buttonValue = "Lookup";}}} else {$FORM->{email} = "";$FORM->{action} = "";$buttonValue = "Lookup";}print CGI::header();#foreach (sort keys %ENV) {# print "$_: $ENV{$_}\n<br>";#}printRCHeader("Password Reset");print<<page1;<p class="hint">This will reset a user's password to a random string and email that new password to them.<br>They will still need access to their email to get logged back in.</p><FORM method=GET action=password_reset.pl> $RCid_input<TR><TD colspan=2> </TD></TR><TR><TD colspan=2 align=center>$USRMSG <FONT color=red><b>$USRMSGERR</b></font></TD></TR><TR><TD valign=top align=right><b>Email Address: </b></td><TD valign=top><input type=text name=email value=$FORM->{email} $RO></TD></TR><TR><TD colspan=2> </TD></TR><TR><TD colspan=2 align=center><input type=submit name=action value=$buttonValue><input type=button name=action value=Cancel onClick="location.href='/schedule/'"></TD></TR></FORM></TABLE>page1sub updateDBPass {my ($EM, $STR) = @_;use DBI;use WebDB;my $dbh = WebDB->connect;my $sth = $dbh->prepare("update official set password = password(?) where email=?");$sth->execute($STR, $EM);}sub resetPass {my $email = shift;my @chars = ("A".."Z", "a".."z", "1".."0", "(", ")", "-", "_", "*", "^", "!", "[", "]");my $string;$string .= $chars[rand @chars] for 1..8;&updateDBPass($email, $string);use RCMailer;my $subject = 'RollerCon Officials Schedule Manager - Password Reset';my $body = "Greetings,It appears as though you've requested us to reset your password. We've done so, and your new password is '$string' (without the quotes).We'd recommend you log in and change it to your liking at the following link:https://volunteers.rollercon.com/schedule/manage_user.plIf you didn't make this request, well, you're still the only one who received this email, and this is now your password. You should probably let us know that someone is messing with you.-RollerCon Officiating Management";# send the messageEmailUser($email, $subject, $body);print CGI::header();print<<resetPage;<HTML><HEAD><TITLE>RollerCon Officials Schedule Manager - Password Reset</TITLE></HEAD><body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000"><TABLE><TR><TD align=right><img SRC="/logo.jpg"></TD><TD align=center valign=middle><b><font size=+3>RollerCon Official<br>Schedule Manager<br>Password Reset</font></b></TD></TR><TR><TD colspan=2> </TD></TR><TR><TD colspan=2 align=center>Your password has been reset and emailed to the address on record.<br>Please check your email (including Spam folders). </TD></TR><TR><TD colspan=2> </TD></TR><TR><TD colspan=2 align=center><a href=/schedule/>[home]</a> </TD></TR></TABLE>resetPage}