Location: PHPKode > projects > VSecure > newlogin.php
<?php

/*******************************************************************/
/*                        Vsecurity                                */
/*        Copyrights(C)2001 Jan Vilimek(hide@address.com)         */
/*               See GPL license in file license.txt               */
/*           and http://www.guanoweb.cz for more details           */    
/*                                                                 */
/* Function: Secure your pages  (newlogin)                         */
/* for instalation see readme.txt                                  */
/*******************************************************************/

if (!defined("LOADED_PROPERLY"))
 {
 echo "<h1>Acess denied!</h1><br>-VSecurity required-<br><br>get it on www.guano.kgb.cz/main";
 exit();
 }

/*get variables from POST*/
$login=$_POST['login'];
$usname=$_POST['usname'];
$usnick=$_POST['usnick'];
$paswd=$_POST['paswd'];
$paswd2=$_POST['paswd2'];
$email=$_POST['email'];
for ($i=0;isset($VSecure_form_user_data[$i][0]);$i++)
	${$VSecure_form_user_data[$i][0]}=$_POST[$VSecure_form_user_data[$i][0]];


$correctlogin="";
$warn=false;
for ($i=0;$i<strlen($login);$i++)
 { if($login[$i]!=" ")$correctlogin.=$login[$i];else $warn=true; }
$login=$correctlogin;
if ($warn)alert($warning_correctlogin.$login);


/*ERRORS IN USER FORM - REPAIR IT!!*/
$message=" ";

$qw="SELECT login FROM `$VSecure_tbl_usr` WHERE login='".md5($login)."' " ;
$result= mysql_query ($qw , $MySQL_link)
 or die ("Could not find logins in the main VSecure table...");

if (mysql_fetch_row($result)){$message.="<br>".$message_loginexist; $error_1=true; }

$qw="SELECT nick FROM `$VSecure_tbl_usr` WHERE nick='".$usnick."' " ;
$result= mysql_query ($qw , $MySQL_link) or die ("Could not find nick in the main VSecure table...");
IF(mysql_fetch_row($result)){$message.="<br>".$error_nickexist; $error_1=true; }

If ($paswd=='') {$message.="<br>".$error_badpaswd;$error_1=true; }
If (($email=='')||(!ereg ("@", $email))||(!ereg ('\.', $email))) {$message.="<br>".$error_bademail;$error_1=true;  }
If ($usnick=='') {$message.="<br>".$error_badnick;$error_1=true; }
If ($login=='') {$message.="<br>".$error_badlogin;$error_1=true; }
If ($login==$usnick) {$message.="<br>".$error_sameloginnick;$error_1=true; }

$k=0;
while (isset($VSecure_form_user_data[$k]))
{
if (($VSecure_type_definition[$VSecure_form_user_data[$k][1]][2])&&
   ($$VSecure_form_user_data[$k][0]==""))
   {
   $message.="<br>".$VSecure_form_user_data[$k][2]." ".$error_baddata;
   $error_1=true;
   }
$k++;
}

if ($error_1) { include dirname(__FILE__)."/newuserform.php"; }

/*add new user*/
 $qw="INSERT INTO $VSecure_tbl_usr (login,status,password,name,nick,email,dt,note) VALUES ( '".md5($login)."',";
 if ($login=='admin')$qw.=" 'admin', ";else $qw.="'user',"; 
 $qw.="'".md5($paswd)."','$usname','$usnick', '$email','".date('Y-m-d')."','New user...')"; 
$result= mysql_query ($qw , $MySQL_link)
      or die("Can't create new user... <br> error(".mysql_error().")");
$i=0;
while ($VSecure_form_user_data[$i])
{
save_user_data($VSecure_form_user_data[$i][0],$$VSecure_form_user_data[$i][0],$login);
$i++;
}

set_user_session($login);

/*send information to the email address*/

$subject=$message_newlogin_email;
$message=$message_sendpaswd_mess1 . $usname.
         $message_sendpaswd_mess2 . $login .
 		 $message_sendpaswd_mess6 . $usnick.
		 $message_sendpaswd_mess4 . $email.
		 $message_sendpaswd_mess3 . $paswd.
		 "\n***********************************\n\nInfo:\n";
         $i=0;
         while ($VSecure_form_user_data[$i])
           {
           $message.= $VSecure_form_user_data[$i][2]." ... ". $$VSecure_form_user_data[$i][0] ." \n";
           $i++;
           }
         $message.=$message_sendpaswd_mess5;

$multipleextras="From: ".$VSecure_conf['admin_email']."\nReply-To: ".$VSecure_conf['admin_email']."\nX-Mailer: autobot PHP/" . phpversion();

if (!@mail($email, $subject, $message,$multipleextras))alert($message_sendpaswd_failed);



do_redir($MAIN_URL.'?login='.$login.'&action=iscorrect&paswd='.MD5($paswd).'&md5=true&id_form='.$ID_form_login);

?>
Return current item: VSecure