-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnewaccount.html
181 lines (148 loc) · 4.72 KB
/
newaccount.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<%args>
$username => undef
$realname => undef
$email => undef
</%args>
% unless(defined($email)) {
<font size="+3">
Register As A Jbovlaste Editor
</font>
<hr />
<p>
<font size="+10">
<strong>
DO NOT MAKE AN ACCOUNT UNLESS:<br/><br/>
- You want to create new words on jbovlaste (this site)<br/><br/>
- You are willing to be on the jbovlaste mailing list for
discussions of how best to create new words<br/><br/>
If you just want to look up words, <a href="/lookup">GO HERE</a>
</strong>
</font>
</p>
<p>
<strong>You do not need to register if you only want to read the data that's already here.</strong>
</p>
<p>
Thanks for your interest in becoming an editor. <a href="/help/howtohelp.html">There is plenty of work to do</a>, and we welcome all experienced Lojbanists. If you create an account, you can add words and definitions, change existing words and definitions, and cast votes that will be used for ranking words and definitions.
</p>
<p>
After your account is created, you will be added to the Jbovlaste mailing list at <em>jbovlaste@lojban.org</em>. This list will be used for important announcements and (occasionally) discussions that are relevant for the project. Reading this mailing list is <strong>mandatory</strong> for all Jbovlaste editors.
</p>
<form method="post" action="newaccount.html">
<%perl>
# reCaptcha Output form
# Public key
print $c->get_html_v2( '6Lf1RwAAAAAAANZIsJS0Ra-ycdARlCNMTzOkkC-v' );
</%perl>
<table>
<tr>Please use simple alphanumeric characters only.</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="username" size="80"></td>
</tr>
<tr>
<td>Real Name</td>
<td><input type="text" name="realname" size="80"></td>
</tr>
<tr>
<td>E-Mail Address</td>
<td><input type="text" name="email" size="80"></td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</table>
</form>
<%perl>
# Check the form results (both of them)
} else {
# Verify ReCaptcha submission
my $result = $c->check_answer_v2(
# Private key
'6Lf1RwAAAAAAAP6IcWCSHjdtZ5yh1y2muHE7f1Zy', $recaptcha_response, $ENV{'REMOTE_ADDR'},
);
# Munge the input
$username =~ s/[^a-zA-Z0-9_-]//g;
$realname =~ s/[^a-zA-Z0-9 _-]//g;
$email =~ s/[^a-zA-Z0-9@._+-]//g;
my $bademail='';
use Email::Valid;
if( ! Email::Valid->address($email) ) {
$bademail = $email;
$email = '';
}
#print "<pre>".Dumper(\$result)."</pre>";
#print "<pre> $username, $realname, $email.\n</pre>";
if ( $result->{is_valid} && $username && $realname && $email ) {
</%perl>
<font size="+3">
Account Created
</font>
<p>You will get a mail shortly with your password in it; please
use that to log in. You will be automatically in the
jbovlaste mailing list using the address you just
entered.</p>
<p>Please read all of
<a href="/help/index.html">the help
section</a> before you start entering data.</p>
<p>If you need any help, please let
<a href="mailto:<% $m->base_comp->attr('admin_email') %>">the admins</a>
know.</p>
<%perl>
# Make up a password
my $password = chr(int(rand(62))+60) . chr(int(rand(62))+60)
. chr(int(rand(62))+60) . chr(int(rand(62))+60) .
chr(int(rand(62))+60) . chr(int(rand(62))+60) .
chr(int(rand(62))+60) . chr(int(rand(62))+60);
# Munge it the same way the login form does
my $dbpassword = $password;
$dbpassword =~ y/A-Za-z/N-ZA-Mn-za-m/;
$dbh->do("INSERT INTO users
(username, password, email, realname, votesize)
VALUES (?, ?, ?, ?, ?)", undef,
$username, md5_hex($dbpassword), $email, $realname, 1);
#Now send mail to the user
utils::sendemail( [ $email ], "New jbovlaste Account", "
Someone from the IP address $ENV{'REMOTE_ADDR'} registered the
following account on jbovlaste.lojban.org:
User Name: $username
Real Name: $realname
Password: $password
If this means nothing to you, please discard this e-mail.
", $session{'username'} );
} else {
if( ! $email ) {
</%perl>
<font size="+3">
Invalid email address <% $bademail %>!
</font>
<%perl>
} elsif( $result->{is_valid} ) {
</%perl>
<font size="+3">
ReCaptcha correct, but input invalid, sorry. Try again. <pre><% Dumper($result) %>, <% $recaptcha_response %></pre>
</font>
<%perl>
} else {
</%perl>
<font size="+3">
ReCaptcha failed, sorry. Try again. <pre><% Dumper($result) %>, <% $recaptcha_response %></pre>
</font>
<%perl>
}
}
}
</%perl>
<%method title>
New Account Creation
</%method>
<%init>
our($dbh,%session);
use utils;
use Unicode::String;
use Digest::MD5 qw(md5_hex);
$r->content_type("text/html; charset=utf-8");
use Captcha::reCAPTCHA;
my $c = Captcha::reCAPTCHA->new;
my $recaptcha_response = $ARGS{'g-recaptcha-response'};
</%init>