25) // This usually doesn't happen since the form element only accepts 25 characters
message($lang_common['Bad request']);
else if (strlen($password1) < 4)
message($lang_prof_reg['Pass too short']);
else if ($password1 != $password2)
message($lang_prof_reg['Pass not match']);
else if (!strcasecmp($username, 'invité') || !strcasecmp($username, $lang_common['Guest']))
message($lang_prof_reg['Username guest']);
else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username))
message($lang_prof_reg['Username IP']);
else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
message($lang_prof_reg['Username reserved chars']);
else if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[quote=|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username))
message($lang_prof_reg['Username BBCode']);
// Check username for any censored words
if ($pun_config['o_censoring'] == '1')
{
// If the censored username differs from the username
if (censor_words($username) != $username)
message($lang_register['Username censor']);
}
// Check that the username (or a too similar username) is not already registered
$result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\')') or error('Impossible de retrouver les informations utilisateur', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
$busy = $db->result($result);
message($lang_register['Username dupe 1'].' '.pun_htmlspecialchars($busy).'. '.$lang_register['Username dupe 2']);
}
// Validate e-mail
require PUN_ROOT.'include/email.php';
if (!is_valid_email($email1))
message($lang_common['Invalid e-mail']);
else if ($pun_config['o_regs_verify'] == '1' && $email1 != $email2)
message($lang_register['E-mail not match']);
// Check it it's a banned e-mail address
if (is_banned_email($email1))
{
if ($pun_config['p_allow_banned_email'] == '0')
message($lang_prof_reg['Banned e-mail']);
$banned_email = true; // Used later when we send an alert e-mail
}
else
$banned_email = false;
// Check if someone else already has registered with that e-mail address
$dupe_list = array();
$result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE email=\''.$email1.'\'') or error('Impossible de retrouver les informations utilisateur', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
if ($pun_config['p_allow_dupe_email'] == '0')
message($lang_prof_reg['Dupe e-mail']);
while ($cur_dupe = $db->fetch_assoc($result))
$dupe_list[] = $cur_dupe['username'];
}
$timezone = intval($_POST['timezone']);
$language = isset($_POST['language']) ? $_POST['language'] : $pun_config['o_default_lang'];
$save_pass = (!isset($_POST['save_pass']) || $_POST['save_pass'] != '1') ? '0' : '1';
$email_setting = intval($_POST['email_setting']);
if ($email_setting < 0 || $email_setting > 2) $email_setting = 1;
// Insert the new user into the database. We do this now to get the last inserted id for later use.
$now = time();
$intial_group_id = ($pun_config['o_regs_verify'] == '0') ? $pun_config['o_default_user_group'] : PUN_UNVERIFIED;
$password_hash = pun_hash($password1);
// Add the user
$db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$email1.'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Impossible de créer un utilisateur', __FILE__, __LINE__, $db->error());
$new_uid = $db->insert_id();
// If we previously found out that the e-mail was banned
if ($banned_email && $pun_config['o_mailing_list'] != '')
{
$mail_subject = 'Alerte - Adresse e-mail bannis détectée';
$mail_message = 'L\'utilisateur \''.$username.'\' s\est inscrit avec l\'adresse e-mail bannis : '.$email1."\n\n".'Profil utilisateur : '.$pun_config['o_base_url'].'/profile.php?id='.$new_uid."\n\n".'-- '."\n".'E-mail automatique'."\n".'(Ne répondez pas à ce message)';
pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
}
// If we previously found out that the e-mail was a dupe
if (!empty($dupe_list) && $pun_config['o_mailing_list'] != '')
{
$mail_subject = 'Alerte - Adresse e-mail en doublon détéctée';
$mail_message = 'L\'utilisateur \''.$username.'\' s\'est inscrit avec l\'adresse qui appartient également à : '.implode(', ', $dupe_list)."\n\n".'User profile: '.$pun_config['o_base_url'].'/profile.php?id='.$new_uid."\n\n".'-- '."\n".'E-mail automatique'."\n".'(Ne répondez pas à ce message)';
pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
}
// Should we alert people on the admin mailing list that a new user has registered?
if ($pun_config['o_regs_report'] == '1')
{
$mail_subject = 'Alerte - Nouvelle inscription';
$mail_message = 'L\'utilisateur \''.$username.'\' registered in the forums at '.$pun_config['o_base_url']."\n\n".'Profil utilisateur : '.$pun_config['o_base_url'].'/profile.php?id='.$new_uid."\n\n".'-- '."\n".'E-mail automatique'."\n".'(Ne répondez pas à ce message)';
pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
}
// Must the user verify the registration or do we log him/her in right now?
if ($pun_config['o_regs_verify'] == '1')
{
// Load the "welcome" template
$mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/welcome.tpl'));
// The first row contains the subject
$first_crlf = strpos($mail_tpl, "\n");
$mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
$mail_message = trim(substr($mail_tpl, $first_crlf));
$mail_subject = str_replace('', $pun_config['o_board_title'], $mail_subject);
$mail_message = str_replace('', $pun_config['o_base_url'].'/', $mail_message);
$mail_message = str_replace('', $username, $mail_message);
$mail_message = str_replace('', $password1, $mail_message);
$mail_message = str_replace('', $pun_config['o_base_url'].'/login.php', $mail_message);
$mail_message = str_replace('', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);
pun_mail($email1, $mail_subject, $mail_message);
message($lang_register['Reg e-mail'].' '.$pun_config['o_admin_email'].'.', true);
}
pun_setcookie($new_uid, $password_hash, ($save_pass != '0') ? $now + 31536000 : 0);
redirect(isset($_GET["from"]) ? urldecode($_GET["from"]) : "index.php", $lang_register['Reg complete']);
}
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_register['Register'];
$required_fields = array('req_username' => $lang_common['Username'], 'req_password1' => $lang_common['Password'], 'req_password2' => $lang_prof_reg['Confirm pass'], 'req_email1' => $lang_common['E-mail'], 'req_email2' => $lang_common['E-mail'].' 2');
$focus_element = array('register', 'req_username');
require PUN_ROOT.'header.php';
?>