forked from kestasjk/webDiplomacy
/
register.php
executable file
·236 lines (175 loc) · 8.59 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
<?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(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 e-mail
$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 e-mail address?
$email = trim($DB->escape($_REQUEST['emailValidate']));
if( User::findEmail($email) )
throw new Exception(
l_t("The e-mail address '%s', is already in use. Please choose another.",$email));
if ( !libAuth::validate_email($email) )
throw new Exception(l_t("A first check of this e-mail 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 e-mail
$Mailer->Send(array($email=>$email), l_t('Your new webDiplomacy account'),
l_t("Hello and welcome!")."<br><br>
".l_t("Thanks for validating your e-mail address; just use this link to create your new webDiplomacy account:")."<br>
".libAuth::email_validateURL($email)."<br><br>
".l_t("There are two main rules that we want you to be aware of:")."<br>
".l_t("1. No Multi-Accounting")."<br><br>
".l_t("You may only have one account, second accounts are not allowed under any circumstances, and will be banned. This may also lead to your first account also being banned. If you forget your password, use the lost password finder here: http://www.webdiplomacy.net/logon.php?forgotPassword=1. If you are still unable to log in, contact the mods.")."<br><br>
".l_t("2. No Meta-gaming")."<br><br>
".l_t("You cannot play a public game with players that you know outside of the site. In doing so, you create an unfair environment for other players by giving yourself the opportunity to form alliances for reasons outside the game. This includes playing public games with family, friends, relatives, coworkers, or even joining a game with any player of a previous game with a predetermined intent to ally with or attack certain players.")."<br><br>
".l_t("Because Diplomacy is a social game, we always encourage playing with friends. However, you should always do so in a private, password-protected game and make sure that every player knows about any real life connections before the game begins.")."<br><br>
".l_t("The rest of the rules can be found here: http://www.webdiplomacy.net/rules.php")."<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 e-mail token was given, please try again"));
$email = trim($DB->escape($email));
$page = 'userForm';
// The user's e-mail is authenticated; he's not a robot and he has a real e-mail 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 e-mail 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 e-mail 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('So that we can all enjoy fun, fair games we need to quickly double check that '.
'you\'re a human and that you have an e-mail address. It only takes a moment '.
'and it keeps the server free of spam and cheaters! :-)').'</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("Okay, now that we know you're a human we need to check that you have a real e-mail address.")."</p>";
print '<div class="hr"></div>';
print '<h3>'.l_t('E-mail Validation').'</h3>';
print l_t("An e-mail 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 e-mail address, and then you're ".
"ready to go!",htmlentities($_REQUEST['emailValidate']))."</p>";
print "<p>".l_t("The e-mail may take a couple of minutes to arrive; if it doesn't appear check your spam inbox.")."</p>";
print '<p>'.l_t('If you have problems e-mail this server\'s admin at %s',Config::$adminEMail).'</p>';
break;
case 'emailTokenFailed':
print '<p>'.l_t('The e-mail token you provided was not accepted; please go back to the e-mail you were sent and '.
'check that you visited the exact URL given.').'</p>';
print '<p>'.l_t('If the e-mail 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 e-mail this server\'s admin at %s',Config::$adminEMail).'</p>';
break;
case 'firstUserForm':
print '<h3>'.l_t('E-mail address confirmed!').'</h3>';
print "<p>".l_t("Alright; you're a human with an e-mail address!</p>
<p>Enter the username and password you want, and any of the optional details/settings, into the screen below to
complete the registration process.")."</p>";
case 'userForm':
print '<form method="post"><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'));
break;
}
print '</div>';
libHTML::footer();
?>