View file Spiderwap.in File Hosting/reg.php

File size: 3.02Kb
<?php
require('sys/config.php');

if(isset($user)){
header ('Location: /panel/index.php');
}


$smarty->assign('title','Registration');

if(!isset($_POST['reg'])){

$smarty->display('header.tpl');
$smarty->display('reg_do.tpl');
$smarty->display('footer.tpl');

} else {

$_POST['mail'] = fil($_POST['mail'],'str');
$_POST['nick'] = fil($_POST['nick'],'str');
$_POST['pass1'] = trim($_POST['pass1']);
$_POST['pass2'] = trim($_POST['pass2']);

if(empty($_POST['pass1']) || empty($_POST['pass2']) || empty($_POST['nick']) || empty($_POST['mail'])){
	$err = 'Fill in all fields';}

if($_POST['pass1']!=$_POST['pass2']){
	$err = 'Passwords do not match';}

if(mb_strlen($_POST['pass1'])<3 || mb_strlen($_POST['pass1'])>20){
	$err = 'Password must be between 3 and 20 characters';}

if(!filter_var($_POST['mail'],FILTER_VALIDATE_EMAIL)){
	$err = 'Email is not valid';}

if($sql->result('SELECT COUNT(*) FROM `acc` WHERE `email`="'.strtolower($_POST['mail']).'"')>0){
 	$err = 'This email is already registered ';}

if($sql->result('SELECT COUNT(*) FROM `acc` WHERE `nick`="'.$_POST['nick'].'"')>0){
 	$err = 'This username is already registered ';}

if(!preg_match('|^[A-z0-9А-я\-\_\)\(]+$|si',$_POST['nick'])){
	$err = 'In the nick you can use only the letters of the Russian, anliyskogo alphabet, numbers and punctuation:	-,_,(,)';}

if(isset($err)){
	$smarty->assign('error',$err);
	$smarty->assign('title','Error');
	$smarty->assign('back','/reg.php');
	$smarty->display('header.tpl');
	$smarty->display('error.tpl');
	$smarty->display('footer.tpl');
	} else {
if($sql->result('SELECT COUNT(`id`) FROM `acc`')==0){$assec = 2;} else {$assec = 0;}
if($sql->query('INSERT INTO `acc` SET `email`="'.strtolower($_POST['mail']).'", `nick`="'.$_POST['nick'].'", `pass`="'.
md5($_POST['pass1']).'", `time`="'.time().'", `assec`="'.$assec.'"')){

$theme='Check-in file hosting '.$_SERVER['HTTP_HOST'];
$message='Hello, you successfully have registered a Spiderwap.in file hosting '.$_SERVER['HTTP_HOST'].'. Use your login to your control panel. Email: '.$_POST['mail'].' , Password :  '.$_POST['pass1'].'.You can also use this link to autologin http://'.$_SERVER['HTTP_HOST'].'/enter.php?mail='.$_POST['mail'].'&amp;pass='.$_POST['pass1'].'. Sincerely administration '.$_SERVER['HTTP_HOST'];
mail($_POST['mail'],$theme,$message,"From: admin@".$_SERVER['HTTP_HOST']."\r\n". "Content-type:text/plain;Charset = UTF-8\r\n");
	$smarty->assign('title','Complete the registration');
	$smarty->assign('ok','Registration was successful<br/> your login: '. $_POST['nick'] .'<br/> Пароль: '.$_POST['pass1']);
	$smarty->assign('back','/enter.php');
	$smarty->assign('nz','Login');
	$smarty->display('header.tpl');
	$smarty->display('ok.tpl');
	$smarty->display('footer.tpl');
	}	else {
	$smarty->assign('error','Error, contact your administrator');
	$smarty->assign('title','Error');
	$smarty->assign('back','/reg.php');
	$smarty->display('header.tpl');
	$smarty->display('error.tpl');
	$smarty->display('footer.tpl');
	}

}
}


?>