Файл: modules/user/sign_up.php
Строк: 175
<?php
$page = 'reg';
if(isset($user)) header('location: /');
$title = $lang->word('sign_up');
require_once(SYS .'/view/header.php');
if($system['open_reg'] == 'no') {
$tpl->div('menu', $lang->word('reg_closed'));
echo '<div class="block">
'. NAV .' <a href="/sign_in/">'.$lang->word('sign_in').'</a><br/>
'. HICO .' <a href="/">'.$lang->word('home').'</a>
</div>';
require_once(SYS .'/view/footer.php');
exit;
}
if (isset($_POST['user_reg'])) {
$nick = htmlspecialchars(trim($_POST['nick']));
$name = htmlspecialchars(trim($_POST['name']));
$gender = substr(abs(intval($_POST['gender'])), 0, 1);
$email = htmlspecialchars(trim($_POST['email']));
$password = htmlspecialchars(trim($_POST['password']));
$password2 = htmlspecialchars(trim($_POST['password2']));
if (empty($nick)) $err .= $lang->word('no_nick').'<br />';
if (empty($name)) $err .= $lang->word('no_name').'<br />';
if (empty($email)) $err .= $lang->word('no_email').'<br />';
if (empty($password)) $err .= $lang->word('no_pass').'<br />';
if (empty($password2)) $err .= $lang->word('no_pass2').'<br />';
if (!empty($nick) && (mb_strlen($nick, 'UTF-8') < 3 || mb_strlen($nick, 'UTF-8') > 32)) $err .= $lang->word('e_nick').'<br />';
if (!empty($nick) && !preg_match("#^([A-zА-я0-9-_ ])+$#ui", $nick)) $err .= $lang->word('b_nick').'<br />';
if (!empty($name) && (mb_strlen($name, 'UTF-8') > 32)) $err .= $lang->word('e_name').'<br />';
if (!empty($email) && (mb_strlen($email, 'UTF-8') < 3 || mb_strlen($email, 'UTF-8') > 72)) $err .= $lang->word('b_mail').'<br />';
if (!empty($email) && !preg_match('|^([a-z0-9_.-]{1,20})@([a-z0-9.-]{1,20}).([a-z]{2,4})$|ius', $email)) $err .= $lang->word('e_email').'<br />';
if (!empty($password) && (mb_strlen($password, 'UTF-8') < 5 || mb_strlen($password, 'UTF-8') > 64)) $err .= $lang->word('e_pass').'<br />';
if (!empty($password) && !empty($password2) && $password != $password2) $err .= $lang->word('e_pass2').'<br />';
if($db->query("SELECT * FROM `users` WHERE `nick` = '$nick'")->rowCount() == 1) $err .= $lang->word('ex_nick').'<br/>';
if($db->query("SELECT * FROM `users` WHERE `email` = '$email'")->rowCount() == 1) $err .= $lang->word('ex_mail').'<br/>';
if($_SESSION['captcha'] != $_POST['captcha']) $err .= 'Неверно введен код с картинки<br/>';
if (!isset($err)) {
$password = crypto($password);
$db->query("INSERT INTO `users` SET `name` = '". escape(trim($name)) ."', `nick` = '". escape(trim($nick)) ."', `password` = '". escape(trim($password)) ."', `reg_time` = '". time() ."', `time` = '". time() ."', `email` = '". escape(trim($email)) ."', `level` = '1', `gender` = '$gender', `device` = '', `icq` = '0', `phone` = '', `info` = '', `day` = '0', `month` = '0', `year` = '0', `interests` = '', `city` = '', `country` = '', `locate` = 'in_index', `ban_time` = '0', `ban_text` = '', `surname` = '', `site` = ''");
// print_r($db->errorInfo());
$language = $system['lang'];
$db->query("INSERT INTO `settings` SET `user_id` = '". $db->lastInsertId() ."', `lang` = '". $language ."', `ames` = '10', `theme` = 'default', `web_theme` = 'default', `fast_mess` = 'yes', `view_profile` = 'all', `show_email` = 'no', `timezone` = '". $system['timezone']."'");
session_destroy();
echo '<div class="title">'.$lang->word('sign_up').'</div>
<div class="menu">
'.$lang->word('end_r_t').' <a href="/sign_in/?nick='. $nick .'&password='. $password2 .'">'.$lang->word('sign_in_1').'</a>
</div>
<div class="block">
'. NAV .' <a href="/sign_in/">'.$lang->word('sign_in').'</a><br/>
'. HICO .' <a href="/">'.$lang->word('home').'</a>
</div> ';
require_once(SYS .'/view/footer.php');
exit();
}
}
if (isset($err)) echo '<div class="error">'. $err .'</div>';
echo '<form method="post" action="?">
<div class="title">'.$lang->word('sign_up').'</div>
<div class="menu">
'.$lang->word('nick').':<br />
<input type="text" name="nick" value="'. (isset($_POST['nick']) ? htmlspecialchars($_POST['nick']) : NULL) .'" /><br />
'.$lang->word('name').':<br />
<input type="text" name="name" value="'. (isset($_POST['name']) ? htmlspecialchars($_POST['name']) : NULL) .'" /><br />
'.$lang->word('gender').':<br/>
<select name="gender">
<option value="1">'.$lang->word('male').'</option>
<option value="2">'.$lang->word('female').'</option>
</select><br/>
E-Mail:<br />
<input type="text" name="email" value="'. (isset($_POST['email']) ? htmlspecialchars($_POST['email']) : NULL) .'" /><br />
'.$lang->word('password').':<br />
<input type="password" name="password" /><br />
'.$lang->word('password2').':<br />
<input type="password" name="password2" /><br />
'.$lang->word('enter_captcha').':<br />
<script>
function captcha_reload() {
document.getElementById('captcha').src = "/system/view/captcha.php?" + Math.random();
}
</script>
<img id="captcha" src="'. URL .'/system/view/captcha.php" alt="captcha" /><br />
<a href="javascript:captcha_reload();">'.$lang->word('refresh').'</a><br />
<input type="text" name="captcha" size="6" /><br/>
<input type="submit" name="user_reg" value="'.$lang->word('sign_up').'" /><br />
<font color="red"><b>*</b></font>Регистрируясь, вы автоматически соглашаетесь с <a href="/pages/rules">правилами</a> сайта!
</div>
</form>
<div class="block">
'. img('key.png').' <a href="/sign_in/">'.$lang->word('sign_in').'</a><br/>
'. HICO .' <a href="/">'.$lang->word('home').'</a>
</div>';
require_once(SYS .'/view/footer.php');
?>