View file bolcms-3.0.1./users/reg.php

File size: 2.26Kb
<?php 
$title = 'Регистрация';
require("../system/core.php");


switch($_GET['act']){
default:

echo '<div class="phdr">' .$lng ['reg'] . ' </div><div class="bmenu">';
echo '<form action="?act=reg_do" method="post" name="form">';
echo ' ' .$lng ['log'] . ' :<br/><input name="login" type="text" maxlength="40" /><br/>';
echo 'E-mail:<br/><input name="mail" type="text" maxlength="20" /><br/>';
echo ' ' .$lng ['pass'] . ' :<br/><input name="pass" type="password" maxlength="30" /><br/>';

$_SESSION['captcha'] = rand(1234, 9999);
echo ' ' .$lng ['kap'] . ' : <b>'.$_SESSION['captcha'].'</b><br/><input name="captcha" type="text" maxlength="6" /><br/>';
echo '<input name="submit" type="submit" value=" ' .$lng ['reg'] . ' " /></form></div>';
nav();

break;

case 'reg_do':

if(!empty($_POST['login']) && !empty($_POST['mail']) && !empty($_POST['pass'])){
if(strlen($_POST['login']) >= 3 && strlen($_POST['login']) <= 40){
if(strlen($_POST['mail']) >= 5 && strlen($_POST['mail']) <= 20){
if(strlen($_POST['pass']) >= 3 && strlen($_POST['pass']) <= 30){
if($_SESSION['captcha'] == $_POST['captcha']){
			
 $login = sec($_POST['login']);
 $mail = sec($_POST['mail']);
 $pass = md5(sec($_POST['pass']));
 
 $same_login = mysql_result(mysql_query("SELECT count(*) FROM `users` WHERE `login` = '$login'"), 0);
 if($same_login == 0){
 $same_mail = mysql_result(mysql_query("SELECT count(*) FROM `users` WHERE `mail` = '$mail'"), 0);
 if($same_mail == 0){

  mysql_query("INSERT INTO `users` SET `login` = '$login', `mail` = '$mail', `pass` = '$pass', `reg_time` = '".time()."'");
echo '<div class="phdr">' .$lng ['inf'] . ' </div><div class="menu">' .$lng ['susce'] . ' </div>';
  nav();

}else{error(' ' .$lng ['ermail'] . ' !'); nav2('reg.php', ' ' .$lng ['nd'] . ' ');}
}else{error(' ' .$lng ['erpass'] . ' !'); nav2('reg.php', ' ' .$lng ['nd'] . ' ');}
}else{error(' ' .$lng ['erkap'] . ' !'); nav2('reg.php', ' ' .$lng ['nd'] . ' ');}
}else{error(' ' .$lng ['erpassr'] . ' !'); nav2('reg.php', ' ' .$lng ['nd'] . ' ');}
}else{error(' ' .$lng ['erml'] . ' !'); nav2('reg.php', ' ' .$lng ['nd'] . ' ');}
}else{error(' ' .$lng ['erlog'] . ' !'); nav2('reg.php', 'nd');}
}else{error(' ' .$lng ['edtd'] . ' !'); nav2('reg.php', ' ' .$lng ['nd'] . ' ');}
 
break;

}
require("../system/end.php");
?>