Просмотр файла reg.php

Размер файла: 2.78Kb
<?php
require 'inc/func.php';
bk_head(''.$lng_reg['title'].'');
require 'inc/head.php';

echo '<div class="list1"><div class="tt">&nbsp;'.$lng_reg['title'].'</div>';
if($user){
header('location: index.php');
}
if(isset($_POST['submit']) && !empty($_POST['username']) && !empty($_POST['pass']) && !empty($_POST['mail']) && !empty($_POST['code'])){
$username = bk_check($_POST['username']);
$pass = bk_check($_POST['pass']);
$md5pass = md5($pass);
$mail = bk_check($_POST['mail']);
$gender = bk_check($_POST['gender']);
$code = num($_POST['code']);
$time = time();
if(mysql_num_rows(mysql_query("SELECT `id` FROM `users` WHERE `username` = '$username' "))!=0)
{
err(''.$lng_reg['erussername'].'! <a href="'.$_SERVER['PHP_SELF'].'">'.$lng_reg['back'].'</a>');
}elseif(mysql_num_rows(mysql_query("SELECT `mail` FROM `users` WHERE `mail` = '$mail' "))!=0)
{
err(''.$lng_reg['ermail'].'! <a href="'.$_SERVER['PHP_SELF'].'">'.$lng_reg['back'].'</a>');
}elseif(!preg_match("^[A-Za-z0-9]+$^","$username"))
{
err(''.$lng_reg['erupreg'].'! <a href="'.$_SERVER['PHP_SELF'].'">'.$lng_reg['back'].'</a>');
}elseif(!check_mail($mail))
{
err(''.$lng_reg['ermpreg'].'! <a href="'.$_SERVER['PHP_SELF'].'">'.$lng_reg['back'].'</a>');
}elseif(strlen($_POST['username']) > 20 OR strlen($_POST['username']) < 3 OR strlen($_POST['pass']) > 20 OR strlen($_POST['pass'] < 3))
{
err(''.$lng_reg['erstr'].'! <a href="'.$_SERVER['PHP_SELF'].'">'.$lng_reg['back'].'</a>');
}elseif($code != $_SESSION['code'])
{
err(''.$lng_reg['ercode'].'! <a href="'.$_SERVER['PHP_SELF'].'">'.$lng_reg['back'].'</a>');
}else{

@mysql_query("INSERT INTO `users` SET `username` = '$username', `nick` = '$username', `pass` = '$md5pass', `mail` = '$mail', `gender` = '$gender',`level` = '0',`regtime` = '$time', `language` = 'en' ");
echo ''.$lng_reg['success'].'<br />Username : '.$username.'<br />
Password : '.$pass.'<br />
Auto link: <input type="text" value="'.homeurl.'/login.php?user='.$username.'&pass='.$pass.'" name="auto"><br />
<a href="'.homeurl.'/login.php?username='.$username.'&password='.$pass.'">'.$lng_reg['1'].'</a>';
}

}else{
$rcode = rand(1111,9999);
$_SESSION['code'] = $rcode;
echo '<form method="post">';
echo '<b>'.$lng_reg['wc'].'</b><br />
'.$lng_reg['username'].' :<br /><input type="text" name="username"><br />
'.$lng_reg['password'].' :<br /><input type="text" name="pass"><br />
'.$lng_reg['gender'].' :<br/><select name="gender"><option value="m">'.$lng_reg['boy'].'</option><option value="f">'.$lng_reg['girl'].'</option></select><br />
'.$lng_reg['mail'].' :<br /><input type="text" name="mail"><br />
'.$lng_reg['code'].' :<br />'.$rcode.'<br /><input type="text" name="code"><br />
<input type="submit" value="'.$lng_reg['but'].'" name="submit">
';
echo '</form>';
}
echo '</div>';
bk_foot();
?>