Вход Регистрация
Файл: Dvig/reg.php
Строк: 79
<?php
####################
## Автор - USER-X ##
## Copyright 2013 ##
## xcms.mcdir.ru  ##
####################
        
define'xcms_pro') ;
        include_once ( 
'core/core.php' ) ;
        
$title 'Регистрация нового пользователя' ;
        include_once 
'core/head.php' ;
        if ( ! 
$users)
        {
                        switch ( 
$act )
                        {
                                        case 
'ok':

                                                        
###блок приема переменных
                                                        
$cap = isset( $_POST['kod'] ) ? trim$_POST['kod'] ) : '' ;
                                                        
$password = isset( $_POST['password'] ) ? trim$_POST['password'] ) : '' ;
                                                        
$login = isset( $_POST['login'] ) ? trim(check$_POST['login'] )) : '' ;
                                                        
$email = isset( $_POST['email'] ) ? trim$_POST['email'] ) : '';
                                                        
#########
                                                        
$result mysql_query"SELECT `id` FROM `users` WHERE `login`='$login' LIMIT 1" ) ;
                                                        
$myrow mysql_num_rows$result ) ;
                                                        if(
$myrow){
                                                        
$_SESSION['error'] = 'Логин уже существует!<br/>' ;
                                                        echo
'<div id="razd">Логин уже существует</div><a id="nav" href="/reg.php">Назад</a>';
                                                        exit ;
                                                        }else{
                                                        if ( empty( 
$cap ) || mb_strlen$cap ) < ){
                                                                        unset( 
$_SESSION['code'] ) ;
                                                                        
$_SESSION['error'] = 'Не введён проверочный код!<br/>' ;
                                                                        
header"location: ?" ) ;
                                                                        exit ;
                                                        }
                                                        elseif ( 
$cap != $_SESSION['code'] ){
                                                                        unset( 
$_SESSION['code'] ) ;
                                                                        
$_SESSION['error'] = 'Проверочный код неверен!<br/>' ;
                                                                        
header"location: ?" ) ;
                                                                        exit ;
                                                        }

                                                        unset( 
$_SESSION['code'] ) ;

                                                        
// Проверка пароля
                                                        
if ( empty( $password ) )
                                                        {
                                                                        
$_SESSION['error'] = 'Введите пароль!<br/>' ;
                                                                        
header"location: ?" ) ;
                                                                        exit ;
                                                        }
                                                        elseif ( 
mb_strlen$password ) < and mb_strlen$password ) > 10 )
                                                        {
                                                                        
$_SESSION['error'] = 'Неверная длина пароля!<br />От 3 до 10 символов!<br/>' ;
                                                                        
header"location: ?" ) ;
                                                                        exit ;
                                                        }
                                                        if ( ! 
preg_match"#^[a-z0-9]+$#i"$password ) )
                                                                        
//если чел ввел не то что надо то
                                                        
{
                                                                        
$_SESSION['error'] =
                                                                                        
'Пароль разрешен только из набора латинских букв и цыфр!<br/>' ;
                                                                        
header"location: ?" ) ;
                                                                        exit ;
                                                        }

                                                        
#Проверяем логин
                                                        
if ( empty( $login ) )
                                                        {
                                                                        
$_SESSION['error'] = 'Введите логин!<br/>' ;
                                                                        
header"location: ?" ) ;
                                                                        exit ;
                                                        }
                                                        elseif ( 
mb_strlen$login ) < || mb_strlen$login ) > 15 )
                                                        {
                                                                        
$_SESSION['error'] = 'Логин должен быть не меньше 3х и не более 15 символов<br/>' ;
                                                                        
header"location: ?" ) ;
                                                                        exit ;
                                                        }
                                                        
                                                        
$email mysql_real_escape_string$email ) ;
                                                        
$pass =  md5$password );
                                                        
$log mysql_real_escape_string$login ) ;
                                                        
// если такого нет, то сохраняем данные
                                                        
$time time();
                                                        
$result2 mysql_query"INSERT INTO `users` (login,password,time,reg_time,email,gorod_money) VALUES('$log','$pass',
                                                        '
$time','$time','$email','20000')" ) ;
                                                        
// Проверяем, есть ли ошибки
                                                        
if ( $result2 == 'TRUE' ){
                                                        
$uid mysql_insert_id() ;
                                                        
#ставим куки
                                                        
$login base64_encode$uid ) ;
                                                        
$passw md5$password ) ;

                                                        
setcookie"setlogin"$logintime() + 3600 24 365 ) ;
                                                        
setcookie"setpassw"$passwtime() + 3600 24 365 ) ;

                                                        
#ставим сесии
                                                        
$_SESSION['login'] = $uid ;
                                                        
$_SESSION['passw'] = $pass ;
                                                        
$new mysql_insert_id() ;
                                                        
$time time();
                                                        
$_SESSION['oke'] = 'Вы зарегистрировались!<br/>' ;
                                                        
$to  "<$email>, " 
                                                        
$subject "Регистрация на $_SERVER[HTTP_HOST]"
                                                        
$message 
                                                        Добро пожаловать на портал '
.$_SERVER['HTTP_HOST'].'<br>
                                                        Благодарим вас за регистрацию, и дарим вам 50 баллов<br>
                                                        Ваши регистрационные данные - <br>
                                                        Логин - '
.$log.'<br>
                                                        Пароль - '
.$password.'<br><br>
                                                        Если вы не регистрировались на нашем портале, то, пожалуйста, проигнорируйте это письмо<br>'

                                                        
$headers  "Content-type: text/html; charset=utf-8 rn"
                                                        
$headers .= "From:  $_SERVER[HTTP_HOST] <robot@$_SERVER[HTTP_HOST]>rn"
                                                        
mail($to$subject$message$headers); 
                                                        
mysql_query("INSERT INTO `mail` SET `kto`='2', `komu`='$new', `text`='Добрый день! 
                                                        Вы успешно зарегистрировались<br>
                                                        Мы благодарны за вашу регистрацию<br>
                                                        И дарим вам 50 баллов', `time`='
$time', `status`='1'");
                                                        
mysql_query("INSERT INTO `podarok` SET 
                                                        `kto`='2', 
                                                        `komu`='
$new', 
                                                        `podarok`='1', 
                                                        `podp`='Добро пожаловать к нам!',
                                                        `cost`='0',
                                                        `time`='
$time'");
                                                        
mysql_query("UPDATE `users` SET `balans`=balans+50,`design`='1' WHERE `id`='$new'");
                                                        echo
'<div id="razd">Вы успешно зарегистрировались</div><a id="nav" href="/upfoto.php">Далее</a>';
                                                        exit ;}

                                                        
                                                        else
                                                        {
                                                                        
$_SESSION['error'] = 'Ошибка! Вы не зарегистрированы.' ;
                                                                        
header"location: index.php" ) ;
                                                                        exit ;

                                                        }
                                                        }

                                                        break ;

                                        default:

                                                        
                                                        echo 
'<div id="razd">'.$title.'</div>
                                                        <form action="?act=ok" method="post">
                                                        <div id="body">Регистрируясь на нашем портале вы соглашаетесь с <a href="/info?act=rul">правилами</a> портала</div>
                                                        <div id="body">
                                                        Логин:<br/><input type="text" name="login" value="" maxlength="20"/><br/>
                                                        Пароль:<br/><input type="password" name="password" maxlength="20"/><br/>
                                                        Ваша почта:<br/><input type="text" name="email" value="" maxlength="40"/><br/>
                                                        <img src="' 
$host .'/cap.php?r=' rand1000999999 ) . '" alt="код"/><br />
                                                        Введите код:<br/><input type="text" size="5" maxlength="5"  name="kod"/>
                                                        <input type="submit" value="Окей"/></form>' 
;
                                                        echo 
'</div>' ;

                        }
        }
        else
        {
                        
$_SESSION['error'] = 'Вы уже регистрировались!<br/>' ;
                        
header"location: index.php" ) ;
                        exit ;
        }
        include_once ( 
'core/foot.php' ) ;

?>
Онлайн: 1
Реклама