Subversion Repositories ORC

Rev

Rev 8 | Rev 17 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8 - 1
#!/usr/bin/perl
2
 
3
use strict;
4
use cPanelUserConfig;
5
use RollerCon;
6
use CGI;
7
use CGI::Cookie;
8
 
9
#my $cookie_string = authenticate(1) || die;
10
#my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
11
my $query = new CGI;
12
my ($FORM, $userref, $buttonValue, $RCid);
13
my ($USRMSG, $USRMSGERR, $RO, $RCid_input) = ("", "", "", "");
14
 
15
if ($ENV{'QUERY_STRING'}) {
16
	$FORM->{email} = $query->param('email');
17
	$FORM->{action} = $query->param('action');
18
 
19
	if ($FORM->{action} eq "Cancel") {
20
		$FORM->{email} = "";
21
		$FORM->{action} = "";
22
		$buttonValue = "Lookup";
23
	} elsif ($FORM->{action} eq "Lookup") {
24
		if ($userref = getUser($FORM->{email})) {
25
			$USRMSG = "User info found.  Click Reset to reset your password, or Cancel to go back";
26
			$buttonValue = "Reset";
27
			$RO = "readonly";
28
			$RCid_input = "<input type=hidden name=RCid value=$userref->{RCid}>";
29
		} else {
30
			$USRMSGERR = "No user found with that email address.";
31
			$buttonValue = "Lookup";
32
		}
33
	} elsif ($FORM->{action} eq "Reset") {
34
		if ($userref = getUser($FORM->{email})) {
35
			if ($userref->{RCid} eq $query->param('RCid')) {
36
				&resetPass($FORM->{email});
37
				logit($userref->{RCid}, "Automated Password Reset");
38
				exit;
39
			} else {
40
				$USRMSGERR = "There appear to be shenanigans afoot. Please don't.";
41
				$buttonValue = "Lookup";
42
			}
43
		} else {
44
			$USRMSGERR = "There appears to be tomfoolery afoot. Please don't.";
45
			$buttonValue = "Lookup";
46
		}
47
	}
48
 
49
} else {
50
	$FORM->{email} = "";
51
	$FORM->{action} = "";
52
	$buttonValue = "Lookup";
53
}
54
 
55
 
56
print CGI::header();
57
 
58
#foreach (sort keys %ENV) {
59
#	print "$_: $ENV{$_}\n<br>";
60
#}
61
 
62
printRCHeader("Password Reset");
63
print<<page1;
64
 
65
<p class="hint">This will reset a user's password to a random string and email that new password to them.<br>
66
They will still need access to their email to get logged back in.</p>
67
 
68
 <FORM method=GET action=password_reset.pl> $RCid_input
69
	<TR><TD colspan=2>&nbsp</TD></TR>
70
	<TR><TD colspan=2 align=center>$USRMSG <FONT color=red><b>$USRMSGERR</b></font></TD></TR>
71
	<TR>
72
		<TD valign=top align=right><b>Email Address: </b></td>
73
		<TD valign=top><input type=text name=email value=$FORM->{email} $RO></TD>
74
	</TR>
75
	<TR><TD colspan=2>&nbsp</TD></TR>
76
	<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>
77
 </FORM>
78
</TABLE>
79
 
80
page1
81
 
82
sub updateDBPass {
83
	my ($EM, $STR) = @_;
84
	use DBI;
10 - 85
	use WebDB;
86
 
87
	my $dbh = WebDB->connect;
8 - 88
	my $sth = $dbh->prepare("update official set password = password(?) where email=?");
89
	$sth->execute($STR, $EM);
90
}
91
 
92
sub resetPass {
93
	my $email = shift;
94
 
95
	my @chars = ("A".."Z", "a".."z", "1".."0", "(", ")", "-", "_", "*", "^", "!", "[", "]");
96
	my $string;
97
	$string .= $chars[rand @chars] for 1..8;
98
 
99
	&updateDBPass($email, $string);
100
 
101
	use RCMailer;
102
	my $subject = 'RollerCon Officials Schedule Manager - Password Reset';
103
	my $body = "Greetings,
104
 
105
It appears as though you've requested us to reset your password.  We've done so, and your new password is '$string'.
106
 
107
We'd recommend you log in and change it to your liking at the following link:
108
 
109
http://officials.rollercon.com/schedule/manage_user.pl
110
 
111
If 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.
112
 
113
-RollerCon Officiating Management
114
";
115
 
116
	# send the message
117
	EmailUser($email, $subject, $body);
118
 
119
 
120
print CGI::header();
121
print<<resetPage;
122
 
123
<HTML><HEAD><TITLE>RollerCon Officials Schedule Manager - Password Reset</TITLE></HEAD>
124
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
125
<TABLE>
126
	<TR>
127
		<TD align=right><img SRC="/logo.jpg"></TD>
128
		<TD align=center valign=middle><b><font size=+3>RollerCon Official<br>Schedule Manager<br>Password Reset</font></b></TD>
129
	</TR>
130
	<TR><TD colspan=2>&nbsp</TD></TR>
131
	<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).&nbsp</TD></TR>
132
	<TR><TD colspan=2>&nbsp</TD></TR>
133
	<TR><TD colspan=2 align=center><a href=/schedule/>[home]</a>&nbsp</TD></TR>
134
</TABLE>
135
 
136
resetPage
137
}