<?
function ValidNN($s)
{
return !eregi("[^a-z0-9_]",$s);
}
function ValidPass($s)
{
return !eregi("[^a-z0-9]",$s);
}
function validEmail($email)
{
return eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email);
}
require("functionChat.ssp");
$r = GetRandom();
$nn=substr(ReplaceChar($nn),0,10);
$newnn = substr(ReplaceChar($newnn),0,10);
if (empty($newpass))
{
LogResult(utf(4),utf(34),"index.php?p=$r");
}
openDB();
if ($log=="old")
{
$result = checkpass($nn,$pass,"");
if (strtolower($nn) != strtolower($newnn)) LogResult(utf(4),utf(5),"index.php?p=$r");
}
else
{
if ($log=="new")
{
$sqlSel="select * from users where nick = '$nn'";
$result=mysql_query($sqlSel) or die(mysql_error());
$Count=mysql_num_rows($result);
if ($Count != 0)
{
LogResult(utf(4),utf(27),"index.php?p=$r");
}
}
else
{
LogResult(utf(4),utf(28),"index.php?p=$r");
}
}
if (!ValidNN($nn))
{
LogResult(utf(4),utf(35),"index.php?p=$r");
}
if (!ValidPass($newpass))
{
LogResult(utf(4),utf(36),"index.php?p=$r");
}
if (trim($email) != "" and !validEmail($email))
{
LogResult(utf(4),utf(37),"index.php?p=$r");
}
if (!($subjectlen >= 1 and $subjectlen <= 255))
{
LogResult(utf(4),utf(38),"index.php?p=$r");
}
if ($log=="old")
{
$sqlUpd = "update users set 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 = msk_time();
$sqllogin ="insert into users (status,sent,lastrefr,regtime,refrint,messlim,mode,nick,pass,email) values ('$RegStatus','0', '$now', '$now', '$DefRefrInt','$DefMessLim', '$CommonMode','$nn', '$newpass','$email')";
mysql_query($sqllogin) or die(mysql_error());
}
}
LogResult(utf(12),utf(39),"index.php?p=$r&login=$nn&pass=$newpass");
mysql_close();
?>