<?php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$user->setup('ucp');
//ajout captcha
if ($config['enable_confirm'])
{
require_once($phpbb_root_path . 'phpbb/captcha/factory.' . $phpEx);
$captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']);
$captcha->init(CONFIRM_REG);
}
//
$error=array();
$data = array(
'username' => $request->variable('username', '', true),
'new_password' => $request->variable('new_password', '', true),
'password_confirm' => $request->variable('password_confirm', '', true),
'email' => strtolower($request->variable('email', '')),
'email_confirm' => strtolower(request_var('email_confirm', '')),
'lang' => basename($request->variable('lang', $user->lang_name)),
'tz' => $request->variable('tz', $timezone),
);
if (isset($_POST['submit']))
{
$error = validate_data($data, array(
'username' => array(
array('string', false, $config['min_name_chars'], $config['max_name_chars']),
array('username', '')),
'new_password' => array(
array('string', false, $config['min_pass_chars'], 0),
array('password')),
'password_confirm' => array('string', false, $config['min_pass_chars'], 0),
'email' => array(
array('string', false, 6, 60),
array('user_email')),
'email_confirm' => array('string', false, 6, 60),
));
// Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error);
//ajout captcha
if ($config['enable_confirm'])
{
$vc_response = $captcha->validate($data);
if ($vc_response !== false)
{
$error[] = $vc_response;
}
if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts'])
{
$error[] = $user->lang['TOO_MANY_REGISTERS'];
}
}
// DNSBL check
if ($config['check_dnsbl'])
{
if (($dnsbl = $user->check_dnsbl('register')) !== false)
{
$error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]);
}
}
if (!count($error))
{
if ($data['new_password'] != $data['password_confirm'])
{
$error[] = $user->lang['NEW_PASSWORD_ERROR'];
}
if ($data['email'] != $data['email_confirm'])
{
$error[] = $user->lang['NEW_EMAIL_ERROR'];
}
}
$vars = array('submit', 'data', 'cp_data', 'error');
extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_after', compact($vars)));
if (!count($error))
{
$$server_url = generate_board_url();
// Which group by default?
$group_name = ($coppa) ? 'REGISTERED_COPPA' : 'REGISTERED';
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
WHERE group_name = '" . $db->sql_escape($group_name) . "'
AND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row)
{
trigger_error('NO_GROUP');
}
$group_id = $row['group_id'];
if (($coppa ||
$config['require_activation'] == USER_ACTIVATION_SELF ||
$config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable'])
{
$user_actkey = gen_rand_string(mt_rand(6, 10));
$user_type = USER_INACTIVE;
$user_inactive_reason = INACTIVE_REGISTER;
$user_inactive_time = time();
}
else
{
$user_type = USER_NORMAL;
$user_actkey = '';
$user_inactive_reason = 0;
$user_inactive_time = 0;
}
// Instantiate passwords manager
/* @var $passwords_manager \phpbb\passwords\manager */
$passwords_manager = $phpbb_container->get('passwords.manager');
$user_row = array(
'username' => $data['username'],
'user_password' => $passwords_manager->hash($data['new_password']),
'user_email' => $data['email'],
'group_id' => (int) $group_id,
'user_timezone' => 'Europe/Paris',
'user_lang' => $data['lang'],
'user_type' => $user_type,
'user_actkey' => $user_actkey,
'user_ip' => $user->ip,
'user_regdate' => time(),
'user_inactive_reason' => $user_inactive_reason,
'user_inactive_time' => $user_inactive_time,
);
if ($config['new_member_post_limit'])
{
$user_row['user_new'] = 1;
}
$user_id = user_add($user_row);
if ($user_id === false)
{
trigger_error('NO_USER', E_USER_ERROR);
}
//ajout captcha
if ($config['enable_confirm'])
{
$captcha->reset();
}
$url = append_sid('./index.php');
die( '<html>
<head>
<META http-equiv="Refresh"
content="10; URL=' . $url . '">
</head>
<body>
Votre compte a été enregistré avec succès<br />
Vous allez être maintenant redirigé vers <a href="' . $url . '">la page d\'index</a>
</body>
</html>');
}
}
echo '<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Vous enregistrer</title>
</head>
<body>
<form method="post">
<h1>Vous enregistrer</h1>';
//ajout patcha
if ($config['enable_confirm'])
{
$confirm_id = $captcha->confirm_id;
$confirm_code = true;
$confirm_image='<img src="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=confirm&confirm_id=' . $confirm_id . '&type=' . CONFIRM_REG) . '" alt="" title="" />';
}
if (sizeof($error))
{
echo '<font color="red"><b>' . implode('<br />', $error) . '</b></font>';;
}
?>
<table>
<tr>
<td align="right">Pseudonyme:</td>
<td><input type="text" tabindex="1" name="username" size="25" value="<?php echo $data['username']; ?>" /></td>
</tr>
<tr>
<td align="right">Mot de passe:</td>
<td><input type="password" tabindex="2" name="new_password" size="25" value="<?php echo $data['password']; ?>" /></td>
</tr>
<tr>
<td align="right">Confirmez votre mot de passe:</td>
<td><input type="password" tabindex="3" name="password_confirm" size="25" value="<?php echo $data['password_confirm']; ?>" /></td>
</tr>
<tr>
<td align="right">Email:</td>
<td><input type="text" tabindex="4" name="email" size="25" maxlength="100" value="<?php echo $data['email']; ?>" /></td>
</tr>
<tr>
<td align="right">Confirmez votre Email</td>
<td><input type="text" tabindex="5" name="email_confirm" size="25" maxlength="100" value="<?php echo $data['email_confirm']; ?>" /></td>
</tr>
<?php
if ($confirm_code)
{
?>
<tr>
<td><?php echo $user->lang['CONFIRM_CODE'] . '<br />' . $user->lang['CONFIRM_CODE_EXPLAIN']; ?></td>
<td><input type="hidden" name="confirm_id" value="<?php echo $confirm_id; ?>" /><?php echo $confirm_image; ?></td>
</tr>
<tr>
<td> </td>
<td><input type="text" name="confirm_code" id="confirm_code" size="8" maxlength="8" /></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2" align="center">
<input type="reset" value="Remettre à zéro" name="reset" />
<input type="submit" name="submit" id ="submit" value="S'enregistrer" />
</td>
</tr>
</table>
</form>
</body>
</html>
?>