-
Notifications
You must be signed in to change notification settings - Fork 114
/
register.php
executable file
·243 lines (183 loc) · 8.98 KB
/
register.php
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
/*
Copyright (C) 2004-2010 Kestas J. Kuliukas
This file is part of webDiplomacy.
webDiplomacy is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
webDiplomacy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with webDiplomacy. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @package Base
* @subpackage Forms
*/
require_once('header.php');
require_once('lib/sms.php');
require_once(l_r('objects/mailer.php'));
global $Mailer;
$Mailer = new Mailer();
if ( $Misc->Panic )
{
libHTML::notice(l_t('Registration disabled'),
l_t("Registration has been temporarily disabled while we take care of an ".
"unexpected problem. Please try again later, sorry for the inconvenience."));
}
// The user must be guest to register a new account
if( $User->type['User'] )
{
libHTML::error(l_t("You're attempting to create a ".
"new user account when you already have one. Please use ".
"your existing user account."));
}
libHTML::starthtml();
$page = 'firstValidationForm';
if ( isset($_COOKIE['imageToken']) && isset($_REQUEST['imageText']) && isset($_REQUEST['emailValidate']) )
{
try
{
// Validate and send email
$imageToken = explode('|', $_COOKIE['imageToken'], 2);
if ( count($imageToken) != 2 )
throw new Exception(l_t("A bad anti-script code was given, please try again"));
list($Hash, $Time) = $imageToken;
if ( md5(Config::$secret.$_REQUEST['imageText'].$_SERVER['REMOTE_ADDR'].$Time) != $Hash )
{
throw new Exception(l_t("An invalid anti-script code was given, please try again"));
}
elseif( (time() - 3*60) > $Time)
{
throw new Exception(l_t("This anti-script code has expired, please submit it within 3 minutes"));
}
// The user's imageText is validated; he's not a robot. But does he have a real email address?
$email = trim($DB->escape($_REQUEST['emailValidate']));
if( User::findEmail($email) )
throw new Exception(
l_t("The email address '%s', is already in use. If this is your email, please use the Forgot your username and password features to recover your account or contact the moderators at %s for assistance. Making a second account for any reason is against the site rules.",$email, Config::$modEMail));
if ( !libAuth::validate_email($email) )
throw new Exception(l_t("A first check of this email is finding it invalid. Remember you need one to ".
"play, and it will not be spammed or released."));
// Prelim checks look okay, lets send the email
$Mailer->Send(array($email=>$email), l_t('Your new webDiplomacy account'),
l_t("Hello and welcome!")."<br><br>
".l_t("Thanks for validating your email! Use this link to create your webDiplomacy account: ").libAuth::email_validateURL($email)."<br><br>
".l_t("There are two main rules to keep in mind:")."<br>
".l_t("1. You may only have one account.")."<br>
".l_t("2. You need to have an invitation code on any game you play with people you know from outside the site to keep games fair.")."<br>
".l_t("The rest of the rules can be found here: http://www.webdiplomacy.net/rules.php")."<br><br>
".l_t("Join the webDiplomacy community on Discord at https://discord.gg/dPm4QnY")."<br><br>
".l_t("If you forgot your password, use the lost password finder here: http://www.webdiplomacy.net/logon.php?forgotPassword=1")."<br><br>
".l_t("If you have any further problems contact the server's admin at %s.",Config::$adminEMail)."<br><br>
".l_t("Enjoy your new account!")."<br>"
);
$page = 'emailSent';
}
catch(Exception $e)
{
print '<div class="content">';
print '<p class="notice">'.$e->getMessage().'</p>';
print '</div>';
$page = 'validationForm';
}
}
elseif ( isset($_REQUEST['emailToken']) )
{
try
{
if( !($email = libAuth::emailToken_email($_REQUEST['emailToken'])) )
throw new Exception(l_t("A bad email token was given, please try again"));
$email = trim($DB->escape($email));
$page = 'userForm';
// The user's email is authenticated; he's not a robot and he has a real email address
// Let him through to the form, or process his form if he has one
if ( isset($_REQUEST['userForm']) )
{
$_REQUEST['userForm']['email'] = $email;
// If the form is accepted the script will end within here.
// If it isn't accepted they will be shown back to the userForm page
require_once(l_r('register/processUserForm.php'));
}
else
{
$_REQUEST['userForm']=array('email' => $email);
$page = 'firstUserForm';
}
}
catch( Exception $e)
{
print '<div class="content">';
print '<p class="notice">'.$e->getMessage().'</p>';
print '</div>';
$page = 'emailTokenFailed';
}
}
switch($page)
{
case 'firstValidationForm':
case 'validationForm':
print libHTML::pageTitle(l_t('Register a webDiplomacy account'),l_t('<strong>Validate your email address</strong> -> Enter your account settings -> Play webDiplomacy!'));
break;
case 'emailSent':
case 'emailTokenFailed':
case 'firstUserForm':
case 'userForm':
print libHTML::pageTitle(l_t('Register a webDiplomacy account'),l_t('Validate your email address -> <strong>Enter your account settings</strong> -> Play webDiplomacy!'));
}
switch($page)
{
case 'firstValidationForm':
print '<h2>'.l_t('Welcome to webDiplomacy!').'</h2>';
print '<p>'.l_t('We are a competitive community looking for fair and fun games; to ensure you are a human with a working email address, please fill out the registration form below. Help us keep the server free of spam and cheaters!').'</p>';
/*
print '<h2>'.l_t('Site User Agreement (We aren’t Apple™, so please read this.)').'</h2>';
print '<p>'.l_t('I agree not to create more than one account.<br /> '.
'I agree not to work around game communication rules.<br /> '.
'I agree not to make alliances based on out-of-game relationships.<br /> '.
'I agree not to play public games with family, or friends.<br /> '.
'I agree to treat all members with respect regardless of race, religion, gender, or creed.<br /><br /> '.
'If you can agree to these values and adhere to our site rules, you are welcome here!').'</p>';
*/
case 'validationForm':
require_once(l_r('locales/English/validationForm.php'));
break;
case 'emailSent':
print '<h3>'.l_t('Anti-bot Validation - Confirmed!').'</h3>';
print "<p>".l_t("Now that we know you're a human, we need to check that you have a real email address.")."</p>";
print '<div class="hr"></div>';
print '<h3>'.l_t('Email Validation').'</h3>';
print l_t("An email has been sent to the address you provided (<strong>%s</strong>) ".
"with a link that you can click on to confirm that it's your real email address, and then you're ".
"ready to go!",htmlentities($_REQUEST['emailValidate']))."</p>";
print "<p>".l_t("The email may take a couple of minutes to arrive. If it doesn't appear, check your spam folder.")."</p>";
print '<p>'.l_t('If you have problems, email this server\'s admin at %s',Config::$adminEMail).'</p>';
break;
case 'emailTokenFailed':
print '<p>'.l_t('The email token you provided was not accepted; please go back to the email you were sent and '.
'check that you visited the exact URL given.').'</p>';
print '<p>'.l_t('If the email did not arrive, check your spam box. If you are sure you haven\'t received it and that '.
'you have waited long enough for it try going through the registration process from the start.').'<br /><br />
'.l_t('If it still fails email this server\'s admin at %s',Config::$adminEMail).'</p>';
break;
case 'firstUserForm':
print '<h3 style = "margin-left: 0px;">'.l_t('Email address confirmed!').'</h3>';
print "<p>".l_t("Thank you for verifying your email address!</p>
<p>Enter the username, password, and any of the optional settings you want into the screen below to
complete the registration process.")."</p>";
//" </br></br><font color='darkred'>Your username is visible to other members and cannot be changed, so please make sure you're sure about it. Keep it appropriate and
//and avoid using your full name if you are concerned about privacy.</font>
case 'userForm':
print '<form method="post" class = "settings_show" autocomplete="off"><ul class="formlist">';
print '<input type="hidden" name="emailToken" value="'.$_REQUEST['emailToken'].'" />';
require_once(l_r('locales/English/userRegister.php'));
require_once(l_r('locales/English/user.php'));
print '</div>';
break;
}
print '</div>';
libHTML::footer();
?>