Subversion Repositories ORC

Rev

Rev 7 | Rev 10 | 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;
85
	my $dsn = "DBI:mysql:database=rollerco_data;host=qnap.home.lan;port=3306";
86
	my $dbh = DBI->connect($dsn, 'root', 'Jopy666!');
87
	my $sth = $dbh->prepare("update official set password = password(?) where email=?");
88
	$sth->execute($STR, $EM);
89
}
90
 
91
sub resetPass {
92
	my $email = shift;
93
 
94
	my @chars = ("A".."Z", "a".."z", "1".."0", "(", ")", "-", "_", "*", "^", "!", "[", "]");
95
	my $string;
96
	$string .= $chars[rand @chars] for 1..8;
97
 
98
	&updateDBPass($email, $string);
99
 
100
	use RCMailer;
101
	my $subject = 'RollerCon Officials Schedule Manager - Password Reset';
102
	my $body = "Greetings,
103
 
104
It appears as though you've requested us to reset your password.  We've done so, and your new password is '$string'.
105
 
106
We'd recommend you log in and change it to your liking at the following link:
107
 
108
http://officials.rollercon.com/schedule/manage_user.pl
109
 
110
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.
111
 
112
-RollerCon Officiating Management
113
";
114
 
115
	# send the message
116
	EmailUser($email, $subject, $body);
117
 
118
 
119
print CGI::header();
120
print<<resetPage;
121
 
122
<HTML><HEAD><TITLE>RollerCon Officials Schedule Manager - Password Reset</TITLE></HEAD>
123
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
124
<TABLE>
125
	<TR>
126
		<TD align=right><img SRC="/logo.jpg"></TD>
127
		<TD align=center valign=middle><b><font size=+3>RollerCon Official<br>Schedule Manager<br>Password Reset</font></b></TD>
128
	</TR>
129
	<TR><TD colspan=2>&nbsp</TD></TR>
130
	<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>
131
	<TR><TD colspan=2>&nbsp</TD></TR>
132
	<TR><TD colspan=2 align=center><a href=/schedule/>[home]</a>&nbsp</TD></TR>
133
</TABLE>
134
 
135
resetPage
136
}