Вход Регистрация
Файл: reg.php
Строк: 73
<?php
////////////////////////////////////////
//                                    //
//          Core for site             //
//         Ядро для сайта             //
//          Author: UndeX             //
//          Автор: UndeX              //
//       Contacts/Контакты:           //
//  Mail: undex.project@gmail.com     //
//  ICQ: 676768169                    //
//                                    //
////////////////////////////////////////

////////////////////////////////////////
//                                    //
//           For FREE use             //
//   Для бесплатного использования    //
//                                    //
////////////////////////////////////////

require_once('system/core.php');

if(
$user["id"]){
    
header('Location: /');
    exit;
}

if(!isset(
$_POST["send"])){
    echo 
'<b>Registration</b><br />';
    if(isset(
$_SESSION["error"])){
        echo 
'<div style="text-align: center; color: red; padding: 5px; background: #EFEFEF; border: 1px solid #DEDEDE; border-radius: 15px;">'.$_SESSION["error"].'</div>';
        unset(
$_SESSION["error"]);
    }
    echo 
'<form method="POST">';
    echo 
'Login: <br />';
    echo 
'<input type="text" name="login" placeholder="Login"><br />';
    echo 
'Password: <br />';
    echo 
'<input type="text" name="password" placeholder="Password"><br />';
    echo 
'Repeat password: <br />';
    echo 
'<input type="text" name="repeat" placeholder="Repeat"><br />';
    echo 
'Mail: <br />';
    echo 
'<input type="text" name="mail" placeholder="example@example.com"><br />';
    echo 
'Security: <br />';
    echo 
'<img src="/captcha.php" style="border: 2px solid #DEDEDE; border-radius: 15px"><br />';
    echo 
'<input type="text" name="code" placeholder="code" maxlength="'.$sys['capcha_sign'].'"><br />';
    echo 
'<input type="submit" name="send" value="Registration" /></form>';
}else{
    
$login $_POST["login"];
    
$pass $_POST["password"];
    
$repeat $_POST["repeat"];
    
$mail $_POST["mail"];
    
    if(
$_SESSION["img_code"]!=$_POST["code"]) $error "Incorrect captcha";
    if(empty(
$_POST["code"])) $error "Empty captcha";
    if(!
preg_match('|^[-a-zA-Z0-9_.]+@[-a-zA-Z0-9.]+.[a-zA-Z]{2,6}$|i'$mail)) $error "Incorrect mail";
    if(empty(
$mail)) $error "Empty mail";
    if(
$pass!=$repeat$error "Passwords do not match";
    if(
mb_strlen($pass)<6$error "A short password";
    if(empty(
$repeat)) $error "Empty repeat password";
    if(empty(
$pass)) $error "Empty password";
    if(
check_forbiden_nick($login$sys['forbiden_nicks'])) $error "Thi's login is forbiden";
    if(!
preg_match('/^([a-zA-Z0-9_]*)$/i'$login)) $error "Incorrect login";
    if(
mb_strlen($login)>32 or mb_strlen($login)<4$error "Short or long login";
    if(empty(
$login)) $error "Empty login";
    if(isset(
$error)){
        
$_SESSION["error"] = $error;
        
header('Location: /reg.php');
        exit;
    }else{
        
$login $db->real_escape_string($login);
        
$pass generateHash($pass);
        
$mail $db->real_escape_string($mail);
        
$token md5(rand().rand());
            
            
$tables '`login`, `password`, `mail`, `token`, `ip_reg`, `date_reg`';
            
$values "'$login', '$pass', '$mail', '$token', '".getIp()."', '".time()."'";
            
$q $db->query("INSERT INTO `users` ($tables) VALUES ($values)");
            
        if(
$q){
            
header("Location: /aut.php");
        }else{
            
$_SESSION["error"] = "Error registration";
            
header('Location: /reg.php');
            exit;
        }
        
    }
}
?>
Онлайн: 0
Реклама