<?
function ValidNN($s)
{
return !eregi("[^a-z0-9_]",$s);
}
function ValidPass($s)
{
return !eregi("[^a-z0-9]",$s);
}
require("functionChat.ssp");
$r = GetRandom();
$nn=substr(ReplaceChar($nn),0,10);
$newnn = substr(ReplaceChar($newnn),0,10);
if (empty($newpass))
{
LogResult($ErrorMess,$EmptyFieldMess,"index.php?p=$r");
}
require("antimat.ssp");
$BadWord = GetBadWord($newnn);
if ($BadWord != "") LogResult($ErrorMess,"$BadWordMess<br/>$BadWord", "index.php?p=$r");
openDB();
$usetrans = $lang;
if ($log=="old")
{
$result = checkpass($nn,$pass,"names,vals");
InitParam(mysql_result($result,0, "names"),mysql_result($result,0, "vals"));
if (strtolower($nn) != strtolower($newnn)) LogResult($ErrorMess,$InvNNorPassMess,"index.php?p=$r");
}
else
{
if ($log=="new")
{
InitParam("","");
$sqlSel="select * from users where nick = '$newnn'";
$result=mysql_query($sqlSel) or die(mysql_error());
$Count=mysql_num_rows($result);
if ($Count != 0)
{
LogResult($ErrorMess,$NNRegMess,"index.php?p=$r");
}
}
else
{
LogResult($ErrorMess,$InvalidCallMess,"index.php?p=$r");
}
}
if (!ValidNN($newnn))
{
LogResult($ErrorMess,$InvNNSyntaxMess,"index.php?p=$r");
}
if (!ValidPass($newpass))
{
LogResult($ErrorMess,$InvPassSyntaxMess,"index.php?p=$r");
}
if (trim($email) != "" and !validEmail($email))
{
LogResult($ErrorMess,$InvEmailSyntaxMess,"index.php?p=$r");
}
if (!($subjectlen >= 1 and $subjectlen <= 255))
{
LogResult($ErrorMess,$InvSubjectLen,"index.php?p=$r");
}
SetParam('usetrans',$usetrans);
SetParam('image',$image);
SetParam('width',$w);
if ($log=="old")
{
$sqlUpd = "update users set names='$Names', vals='$Values', nick='$newnn', pass='$newpass', email='$email', subjectlen='$subjectlen' where nick = '$nn' and pass='$pass'";
mysql_query($sqlUpd) or die(mysql_error());
}
else
{
if ($log=="new")
{
$now = time();
$sqllogin ="insert into users (names,vals,status,sent,regtime,refrint,messlim,mode,nick,pass,email) values ('$Names','$Values','$RegStatus','0', '$now', '$DefRefrInt','$DefMessLim', '$CommonMode','$newnn', '$newpass','$email')";
mysql_query($sqllogin) or die(mysql_error()); // Вставляем незарегистр. юзера
}
}
LogResult($OKMess,$ProfSaveMess,"index.php?p=$r");
mysql_close();
?>