<?php
// ServerAion Web by Pr00f & Sky (serveraion.ru)
// Eddit Lark (x714 serveraion.ru)
require "header.php";
require "modules/reg_m.php";
?>
<div class="case">
<div class="content">
<div class="news">
<div class="news-title">Регистрация аккаунта</div>
<div>
<table align="center">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<tr>
<td width="150px">Логин:</td>
<td><input type="text" class="field-reg" name="name" ></td>
</tr>
<tr>
<td width="150px">Пароль:</td>
<td><input type="password" class="field-reg" name="pass1" ></td>
</tr>
<tr>
<td width="150px">Повторите пароль:</td>
<td><input type="password" class="field-reg" name="pass2"></td>
</tr>
<td width="150px">Ваш E-mail:</td>
<td><input type="text" class="field-reg" name="mail"></td>
</tr>
<tr>
<td width="150px"><img src="modules/captcha.php"/></td>
<td><input type="text" class="field-reg" name="code" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" class="button-submit dark-shadow" value="Создать" name="submit" ></td>
</tr>
</form>
</table>
<?php if(!empty($reg_error)) echo '<div class="error" align="center">'.$reg_error.'</div>'; ?>
<?php if(!empty($reg_success)) echo '<div class="accept" align="center">'.$reg_success.'</div>'; ?>
</div>
</div>
</div>
<?php require "sidebar.php"; ?>
</div>
<?php require "footer.php"; ?><?php
// ServerAion Web by Pr00f & Sky (serveraion.ru)
// Eddit Lark (x714 serveraion.ru)
function phpbb_hash($password)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$random_state = unique_id();
$random = '';
$count = 6;
if (($fh = @fopen('/dev/urandom', 'rb')))
{
$random = fread($fh, $count);
fclose($fh);
}
if (strlen($random) < $count)
{
$random = '';
for ($i = 0; $i < $count; $i += 16)
{
$random_state = md5(unique_id() . $random_state);
$random .= pack('H*', md5($random_state));
}
$random = substr($random, 0, $count);
}
$hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64);
if (strlen($hash) == 34)
{
return $hash;
}
return md5($password);
}
function phpbb_check_hash($password, $hash)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (strlen($hash) == 34)
{
return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
}
return (md5($password) === $hash) ? true : false;
}
function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
{
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
{
$iteration_count_log2 = 8;
}
$output = '$H$';
$output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)];
$output .= _hash_encode64($input, 6, $itoa64);
return $output;
}
function _hash_encode64($input, $count, &$itoa64)
{
$output = '';
$i = 0;
do
{
$value = ord($input[$i++]);
$output .= $itoa64[$value & 0x3f];
if ($i < $count)
{
$value |= ord($input[$i]) << 8;
}
$output .= $itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
{
break;
}
if ($i < $count)
{
$value |= ord($input[$i]) << 16;
}
$output .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
{
break;
}
$output .= $itoa64[($value >> 18) & 0x3f];
}
while ($i < $count);
return $output;
}
function _hash_crypt_private($password, $setting, &$itoa64)
{
$output = '*';
// Check for correct hash
if (substr($setting, 0, 3) != '$H$')
{
return $output;
}
$count_log2 = strpos($itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
{
return $output;
}
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
{
return $output;
}
/**
* We're kind of forced to use MD5 here since it's the only
* cryptographic primitive available in all versions of PHP
* currently in use. To implement our own low-level crypto
* in PHP would result in much worse performance and
* consequently in lower iteration counts and hashes that are
* quicker to crack (by non-PHP code).
*/
if (PHP_VERSION >= 5)
{
$hash = md5($salt . $password, true);
do
{
$hash = md5($hash . $password, true);
}
while (--$count);
}
else
{
$hash = pack('H*', md5($salt . $password));
do
{
$hash = pack('H*', md5($hash . $password));
}
while (--$count);
}
$output = substr($setting, 0, 12);
$output .= _hash_encode64($hash, 16, $itoa64);
return $output;
}
function unique_id($extra = 'c'){
$rand_seed = '8a414598ba18a512b8fe97f1497fa22b';
$val = $rand_seed . microtime();
$val = md5($val);
return substr($val, 4, 16);
}
if(isset($_POST['submit'])) {
if(!empty($_POST['name']) && !empty($_POST['pass1']) && !empty($_POST['pass2'])& !empty($_POST['mail']) && !empty($_POST['code'])) {
$code = strtolower($_POST['code']);
if($code == $_SESSION['rand_code']) {
$connect = @mysql_connect($dbhost,$dbuser,$dbpassword);
if(!empty($_POST))
{
$name = $_POST["name"];
$pass1 = $_POST["pass1"];
$pass2 = $_POST["pass2"];
$hpass = phpbb_hash($pass);
$mail = trim($_POST["mail"]);
$hemail = crc32(strtolower($email) . strlen($email));
if($pass1!=$pass2) {
$reg_error = "Пароли не совпадают";
} else if( !preg_match("/^([a-z0-9]([\-\_\.]*[a-z0-9])*)+@([a-z0-9]([\-]*[a-z0-9])*\.)+[a-z]{2,6}$/i", $mail) OR empty( $mail ) OR strlen( $mail ) > 50) {
$reg_error .= "Не правильно заполнено поле E-mail";
} else{
$conn = mysql_connect($dbhost,$dbuser,$dbpassword);
mysql_select_db($ls, $conn);
mysql_query("set names 'utf8'");
$name = trim(mysql_real_escape_string($_POST["name"]));
$pass1 = trim(mysql_real_escape_string($_POST["pass1"]));
$pass2 = trim(mysql_real_escape_string($_POST["pass2"]));
$query = "SELECT `id`,`name` FROM `account_data` WHERE `name`='$name'";
$res = mysql_query($query, $conn);
if ($res) {
if ($rs=mysql_fetch_array($res)) {
if($rs[1]==$name){
$reg_error = "Имя занято";
return;
}
}
}
$password = trim($pass1);
$password = base64_encode(sha1($password, true));
$query = "INSERT INTO `account_data` (`name`,`password`,`email`) VALUES ('$name','$password','$mail')";
$res = mysql_query($query, $conn);
$reg_success = "Добро пожаловать!".$name;
mysql_close($conn);
}
}
}
else {
$reg_error = "Проверочный код не совпадает";
}
}
else {
$reg_error = "Заполните все поля";
}
}
Вернуться в phpBB-пространство
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0