View file registration.php

File size: 29.35Kb
<?php
#==============================================================================================#
#                                   Name  :  Imperial CHAT                                     #
#                               Made by  :  MaZaFaKa (___хакер___)                             #
#                                  MODED :  vipsds  (   BOT  )                                 #
#                                  ICQ  :  350502220 (vipsds)                                  #
#                                E-mai :  [email protected]                                     #
# По всем вопросам и дополнительным модам обращайтесь на выше указанные данные                 #
#==============================================================================================#
list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;

$configs = file("system/configs.dat");
$reg_status = $configs[0];
$computer = $configs[2];




if(isset($_POST['action']))
{
session_id("".$_POST['sid']."");
session_start();
}
else
{
session_start();
$number = rand(1000, 9999);
$_SESSION['code'] = $number;
$press_kod=rand(1000,9999);
$_SESSION['press_kod'] = "$press_kod";
}
$ttl="Новый пользователь";
error_reporting(0);

include("config.php");
include("./includes/constants/registration");
include("./includes/".$ver."/banned");

define("uagent",addslashes(strip_tags($_SERVER['HTTP_USER_AGENT'])));
$short=explode("/",uagent);
define("short_agent",$short[0]);
define("ip",strip_tags($_SERVER['REMOTE_ADDR']));


$nocache = rand(1000, 9999);
$mobile = strtok(getenv('HTTP_USER_AGENT'), "/");
$ip = getenv('REMOTE_ADDR');
$ua = mysql_escape_string(htmlspecialchars(getenv('HTTP_USER_AGENT')));

switch($ver)
{
case 'wml':
///////////////////////////////////////////////////////
//WML VERSION
///////////////////////////////////////////////////////

header("Content-type: text/vnd.wap.wml; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
$podarok_user = file("system/podarok.dat");
$podarok = trim($podarok_user[0]);
$postov = trim($podarok_user[1]);

if($reg_status == 0)
{
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"error\" title=\"Ошибка\"><p align=\"left\">\n";
echo "<small>Регистрация временно закрыта администратором чата.</small><br/>\n";
echo"$wmlfoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo "</p></card></wml>";
exit();
}

if(((strpos($ua, "Opera") !== false) or (strpos($ua, "Mozilla") !== false) or (strpos($ua, "MSIE") !== false)  or (strpos($ua, "Netscape") !== false)) && $computer == 1)
{
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"error\" title=\"Ошибка\"><p align=\"left\">\n";
echo "<small>Регистрация с компьютера запрещена.</small><br/>\n";
echo"$wmlfoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo "</p></card></wml>";
exit();
}

echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"registration\" title=\"Новый пользователь\"><p align=\"left\">\n";
echo "<!-- Registration ".$_SERVER['SERVER_NAME']."-->\n";
if(!isset($_POST['action']))
{
echo "* Ник:<br/>\n";
echo "<input type=\"text\" name=\"nickname\" maxlength=\"15\"/><br/>\n";
echo "* Пароль:<br/>\n";
echo "<input type=\"text\" name=\"password\" maxlength=\"20\"/><br/>\n";
echo "* Пароль (повтор):<br/>\n";
echo "<input type=\"text\" name=\"repassword\" maxlength=\"20\"/><br/>\n";
echo "* Пол:<br/>\n";
echo "<select name=\"sex\" value=\"0\">\n";
echo "<option value=\"0\">Мужской</option>\n";
echo "<option value=\"1\">Женский</option>\n";
echo "</select><br/>\n";
 if($_GET['asp']=='nocode')
 {
 }
 else
 {
 echo"<img src='/code/index.php' /><br/>\n";
 }



 if($_GET['asp']=='nocode')
 {
        $result=@mysql_query("SELECT * FROM `chat_code` WHERE `ip`='".ip."' && `ua`='".short_agent."'");
        $code=mysql_result($result,0,'code');
        $code = str_replace("0","ноль ",$code);
        $code = str_replace("1","один ",$code);
        $code = str_replace("2","два ",$code);
        $code = str_replace("3","три ",$code);
        $code = str_replace("4","четыри ",$code);
        $code = str_replace("5","пять ",$code);
        $code = str_replace("6","шесть ",$code);
        $code = str_replace("7","семь ",$code);
        $code = str_replace("8","восемь ",$code);
        $code = str_replace("9","девять ",$code);


 print "<b>Код:</b> ".$code."<br/>\n";
 }

echo"* Введите код:\n";

 if($_GET['asp']=='nocode')
 {
 echo"<br/>\n";
 }
 else
 {
 echo"[<a href=\"/registration/wml/nocode/".$number."\">не вижу</a>]<br/>\n";
 }
echo "<input type=\"text\" name=\"provkod\" maxlength=\"6\"/><br/>\n";
echo "<anchor>Регнуться<go href=\"/registration/wml/$nocache\" method=\"post\">\n";
echo "<postfield name=\"nickname\" value=\"$(nickname)\"/>\n";
echo "<postfield name=\"password\" value=\"$(password)\"/>\n";
echo "<postfield name=\"provkod\" value=\"$(provkod)\"/>\n";
echo "<postfield name=\"repassword\" value=\"$(repassword)\"/>\n";
echo "<postfield name=\"number\" value=\"$number\"/>\n";
echo "<postfield name=\"sid\" value=\"".session_id()."\"/>\n";
echo "<postfield name=\"action\" value=\"registration\"/>\n";
echo "</go></anchor><br/>\n";
echo '<br/>';
echo "• <a href=\"/rules/wml/registration\">Правила</a><br/>\n";
echo "• <a href=\"/wml\">Отмена</a><br/><br/>\n";
}
else
{
////////////////////////////////Global OFF////////////////////////////////////
$nickname = trim(htmlspecialchars(mysql_escape_string($_POST['nickname'])));
$nickname = str_replace('$', '$$', $nickname);
$password = trim(htmlspecialchars(mysql_escape_string($_POST['password'])));
$sex = intval($_POST['sex']);
if($sex != 0 && $sex != 1) $sex = 2;
$from = trim(htmlspecialchars(mysql_escape_string($_POST['from'])));
$from = str_replace('$', '$$', $from);
$number = mysql_escape_string(htmlspecialchars(intval($_POST['number'])));
$provkod = mysql_escape_string(htmlspecialchars(intval($_POST['provkod'])));
//////////////////////////////////////////////////////////////////////////////
$error = "";

        $results=@mysql_query("SELECT * FROM `chat_code` WHERE `ip`='".ip."' && `ua`='".short_agent."' && `ts`>=".(time()-18000));
        If (!$results)
        {
        $error .= "Не верно введён проверочный код!<br/>\n";
        }
        $code=mysql_result($results,0,'code');
        If (strtolower($provkod)!=$code)
        {
        $error .= "Не верно введён проверочный код!<br/>\n";
        }

if(empty($nickname)) $error .= "Не введен никнейм!<br/>\n";
if(empty($password)) $error .= "Не введен пароль!<br/>\n";
if(strlen($nickname) > 45) $error .= "Слишком длинный никнейм!<br/>\n";
if(strlen($password) > 20) $error .= "Пароль слишком длинный!<br/>\n";

                function replace_rus($str){
                $str = str_replace("а","|",$str);
                $str = str_replace("б","|",$str);
                $str = str_replace("в","|",$str);
                $str = str_replace("г","|",$str);
                $str = str_replace("д","|",$str);
                $str = str_replace("е","|",$str);
                $str = str_replace("ё","|",$str);
                $str = str_replace("ж","|",$str);
                $str = str_replace("з","|",$str);
                $str = str_replace("и","|",$str);
                $str = str_replace("й","|",$str);
                $str = str_replace("к","|",$str);
                $str = str_replace("л","|",$str);
                $str = str_replace("м","|",$str);
                $str = str_replace("н","|",$str);
                $str = str_replace("о","|",$str);
                $str = str_replace("п","|",$str);
                $str = str_replace("р","|",$str);
                $str = str_replace("с","|",$str);
                $str = str_replace("т","|",$str);
                $str = str_replace("у","|",$str);
                $str = str_replace("ф","|",$str);
                $str = str_replace("х","|",$str);
                $str = str_replace("ч","|",$str);
                $str = str_replace("ц","|",$str);
                $str = str_replace("ш","|",$str);
                $str = str_replace("щ","|",$str);
                $str = str_replace("ь","|",$str);
                $str = str_replace("ы","|",$str);
                $str = str_replace("ъ","|",$str);
                $str = str_replace("э","|",$str);
                $str = str_replace("ю","|",$str);
                $str = str_replace("я","|",$str);
                $str = str_replace("А","|",$str);
                $str = str_replace("Б","|",$str);
                $str = str_replace("В","|",$str);
                $str = str_replace("Г","|",$str);
                $str = str_replace("Д","|",$str);
                $str = str_replace("Е","|",$str);
                $str = str_replace("Ё","|",$str);
                $str = str_replace("Ж","|",$str);
                $str = str_replace("З","|",$str);
                $str = str_replace("И","|",$str);
                $str = str_replace("Й","|",$str);
                $str = str_replace("К","|",$str);
                $str = str_replace("Л","|",$str);
                $str = str_replace("М","|",$str);
                $str = str_replace("Н","|",$str);
                $str = str_replace("О","|",$str);
                $str = str_replace("П","|",$str);
                $str = str_replace("Р","|",$str);
                $str = str_replace("С","|",$str);
                $str = str_replace("Т","|",$str);
                $str = str_replace("У","|",$str);
                $str = str_replace("Ф","|",$str);
                $str = str_replace("Х","|",$str);
                $str = str_replace("Ч","|",$str);
                $str = str_replace("Ц","|",$str);
                $str = str_replace("Ш","|",$str);
                $str = str_replace("Щ","|",$str);
                $str = str_replace("Ь","|",$str);
                $str = str_replace("Ы","|",$str);
                $str = str_replace("Ъ","|",$str);
                $str = str_replace("Э","|",$str);
                $str = str_replace("Ю","|",$str);
                $str = str_replace("Я","|",$str);
                return $str;
                }


$bak = replace_rus($nickname);

if((preg_match("/[^A-Za-z1-9\@\*\(\)\?\!\-\~\_\[\]\=]+/",$nickname))&&(!preg_match("!^[@\\*\\)\\(\\?\\!\\-_\\]\\|\\[=~]+$!i",$bak))) $error .= "Никнейм содержит недопустимые символы!<br/>\n";

if(preg_match("/[^0-9a-zA-Z_]+/", $password)) $error .= "В пароле содержаться недопустимые символы!<br/>\n";


	if(!empty($error))
	{
	echo $error;
    echo"$wmlfoot";
    list($msec, $sec) = explode(chr(32), microtime());
    echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
    echo "</p></card></wml>";
	exit();
	}

    $q = mysql_query("SELECT `id` FROM `chat_users` WHERE `nickname` = '".$nickname."';");
	if(mysql_num_rows($q) != 0)
	{
	echo "К сожалению ник ".$nickname." уже занят. Попробуйте зарегистрировать другой ник.<br/>\n";
    echo"$wmlfoot";
    list($msec, $sec) = explode(chr(32), microtime());
    echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
    echo "</p></card></wml>";
	exit();
	}

    $q = mysql_query("SELECT * FROM `chat_banned_nicknames` WHERE `nickname` = '".$nickname."';");
	if(mysql_affected_rows() != 0)
	{
	echo "Никнейм ".$nickname." забанен!<br/>\n";
	echo "<a href=\"/registration/wml/$nocache\">Назад</a><br/><br/>\n";
    echo"$wmlfoot";
    list($msec, $sec) = explode(chr(32), microtime());
    echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
    echo "</p></card></wml>";
	exit();
	}
$rnd = rand(0,99999999);
if($podarok == 1)
{

$registration = mysql_query("INSERT INTO `chat_users` SET `nickname` = '".$nickname."', `password` = '".md5($password)."', `status` = 'Новичок', `sex` = ".$sex.", `birthday` = '".$birthday."', `ip` = '".$ip."', `ua` = '".$ua."', `time` = ".time().", `posts` = '".$postov."', `key` = '', `regdate` = '".date('d-m-Y')."', `version` = '".$ver."', `foto` = '4', `music` = '2', `video` = '2', `goodpass` = '".$password."';");

 $msgx="<b>Встречайте и не обижайте</b>, Нашего Нового Пользователя <b>".$nickname."</b>! в подарок ему зачисленно <b>".$postov."</b> постов!";

  $sql = mysql_query("SELECT `id` FROM `chat_rooms` WHERE `type` != 1;");

while($room_id = mysql_fetch_array($sql)){
	mysql_query("INSERT INTO `chat".$room_id['id']."` VALUES(0, '5', '".$bots[3]."', '".$msgx."', '0', '".date("H:i")."',".time().",0);");
      }
}
else
{ $registration = mysql_query("INSERT INTO `chat_users` SET `nickname` = '".$nickname."', `password` = '".md5($password)."', `status` = 'Новичок', `sex` = ".$sex.", `birthday` = '".$birthday."', `ip` = '".$ip."', `ua` = '".$ua."', `time` = ".time().", `key` = '', `regdate` = '".date('d-m-Y')."', `version` = '".$ver."', `foto` = '4', `music` = '2', `video` = '2', `goodpass` = '".$password."';");


 $msgx="<b>Встречайте и не обижайте</b>, Нашего Нового Пользователя <b>".$nickname."</b>!";

  $sql = mysql_query("SELECT `id` FROM `chat_rooms` WHERE `type` != 1;");

while($room_id = mysql_fetch_array($sql)){

	mysql_query("INSERT INTO `chat".$room_id['id']."` VALUES(0, '5', '".$bots[3]."', '".$msgx."', '0', '".date("H:i")."',".time().",0);");

}          }

 mysql_query("DELETE FROM `chat_code` WHERE `ip`='".ip."' && `ua`='".short_agent."'");

	if($registration)
	{
	$id = mysql_insert_id();
	echo REGISTRATION_SUCCESS."<br/>\n";
	echo "Примечание!<br/>\n";
	echo "Когда Вы будите входить в чат (сегодня завтра неважно когда) пароль и логин нужно будет вводить с учётом регистра!<br/>\n";
	echo "Пример: Есле у Вас логин КАтЯ, то есле вы введёте при авторизации катя то вам система скажит что такого несуществует нужно ввести именно КАтЯ.<br/>\n";
	echo "Ник: <u>".$nickname."</u><br/>\n";
	echo "Пароль: <u>".$password."</u><br/>\n";
	echo "<anchor>[Продолжить]<go href=\"/menu/wml/$nocache\" method=\"post\">\n";
	echo "<postfield name=\"nickname\" value=\"$nickname\"/>\n";
	echo "<postfield name=\"password\" value=\"$password\"/>\n";
	echo "<postfield name=\"action\" value=\"auth\"/>\n";
	echo "</go></anchor><br/>\n";
	echo "<a href=\"/wml\">Выход</a><br/><br/>\n";
	}
	else
	{
	echo REGISTRATION_ERROR."<br/>\n";
	echo mysql_error()."<br/>\n";
	}
session_destroy();
}
echo"$wmlfoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo "</p></card></wml>";
break;

case 'html':
///////////////////////////////////////////////////////
//HTML VERSION
///////////////////////////////////////////////////////

header("Content-type: text/html; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo "$css";
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">'.$ttl.'</div>';
$podarok_user = file("system/podarok.dat");
$podarok = trim($podarok_user[0]);
$postov = trim($podarok_user[1]);

if($reg_status == 0)
{
echo "Регистрация временно закрыта администрацией.Извините за неудобства.<br/>\n";
echo'<div class="d3">';
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo'</div>';
echo "</body></html>";
exit();
}

if(((strpos($ua, "Opera") !== false) or (strpos($ua, "Mozilla") !== false) or (strpos($ua, "MSIE") !== false)  or (strpos($ua, "Netscape") !== false)) && $computer == 1)
{
echo "Регистрация с компьютера запрещена.<br/>\n";
echo'<div class="d3">';
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo'</div>';
echo "</body></html>";
exit();
}

echo "<!-- Registration ".$_SERVER['SERVER_NAME']."-->\n";
if(!isset($_POST['action']))
{
echo "<div>\n";
echo "<form action=\"/registration/html/$nocache\" method=\"post\">\n";
echo "* Ник:<br/>\n";
echo "<input type=\"text\" name=\"nickname\" maxlength=\"15\"/><br/>\n";
echo "* Пароль:<br/>\n";
echo "<input type=\"text\" name=\"password\" maxlength=\"20\"/><br/>\n";
echo "* Пароль (повтор):<br/>\n";
echo "<input type=\"text\" name=\"repassword\" maxlength=\"20\"/><br/>\n";
echo "* Пол:<br/>\n";
echo "<select name=\"sex\">\n";
echo "<option value=\"0\" selected=\"selected\">Мужской</option>\n";
echo "<option value=\"1\">Женский</option>\n";
echo "</select><br/>\n";


 if($_GET['asp']=='nocode')
 {
 }
 else
 {
 echo"<img src='/code/index.php' /><br/>\n";
 }





 if($_GET['asp']=='nocode')
 {
        $result=@mysql_query("SELECT * FROM `chat_code` WHERE `ip`='".ip."' && `ua`='".short_agent."'");
        $code=mysql_result($result,0,'code');
        $code = str_replace("0","ноль ",$code);
        $code = str_replace("1","один ",$code);
        $code = str_replace("2","два ",$code);
        $code = str_replace("3","три ",$code);
        $code = str_replace("4","четыри ",$code);
        $code = str_replace("5","пять ",$code);
        $code = str_replace("6","шесть ",$code);
        $code = str_replace("7","семь ",$code);
        $code = str_replace("8","восемь ",$code);
        $code = str_replace("9","девять ",$code);


 print "<b>Код:</b> ".$code."<br/>\n";
 }

echo"* Введите код:\n";

 if($_GET['asp']=='nocode')
 {
 echo"<br/>\n";
 }
 else
 {
 echo"[<a href=\"/registration/html/nocode/".$number."\">не вижу</a>]<br/>\n";
 }

echo"<input name=\"provkod\" maxlength=\"4\" value=\"\" /><br>";
echo "<input type=\"hidden\" name=\"number\" value=\"$number\" />\n";
echo "<input type=\"hidden\" name=\"sid\" value=\"".session_id()."\" />\n";
echo "<input type=\"hidden\" name=\"action\" value=\"registration\" />\n";
echo "<input type=\"submit\" value=\"Регнуться\" /></form>\n";
echo'<div class="d1">';
echo "• <a href=\"/rules/html/registration\">Правила</a><br/>\n";
echo "• <a href=\"/html\">Отмена</a></div></div>\n";
}
else
{
////////////////////////////////Global OFF////////////////////////////////////
$nickname = trim(htmlspecialchars(mysql_escape_string($_POST['nickname'])));
$nickname = str_replace('$', '$$', $nickname);
$password = trim(htmlspecialchars(mysql_escape_string($_POST['password'])));
$sex = intval($_POST['sex']);
if($sex != 0 && $sex != 1) $sex = 2;
$from = trim(htmlspecialchars(mysql_escape_string($_POST['from'])));
$from = str_replace('$', '$$', $from);
$number = mysql_escape_string(htmlspecialchars(intval($_POST['number'])));
$provkod = mysql_escape_string(htmlspecialchars(intval($_POST['provkod'])));
//////////////////////////////////////////////////////////////////////////////

$error = "";

        $result=@mysql_query("SELECT * FROM `chat_code` WHERE `ip`='".ip."' && `ua`='".short_agent."' && `ts`>=".(time()-18000));
        If (!$result)
        {
        $error .= "Не верно введён проверочный код!<br/>\n";
        }
        $code=mysql_result($result,0,'code');
        If (strtolower($provkod)!=$code)
        {
        $error .= "Не верно введён проверочный код!<br/>\n";
        }


if(empty($nickname)) $error .= "Не введен никнейм!<br/>\n";
if(empty($password)) $error .= "Не введен пароль!<br/>\n";
if(strlen($nickname) > 45) $error .= "Слишком длинный никнейм!<br/>\n";
if(strlen($password) > 20) $error .= "Пароль слишком длинный!<br/>\n";

                function replace_rus($str)
                {
                $str = str_replace("а","|",$str);
                $str = str_replace("б","|",$str);
                $str = str_replace("в","|",$str);
                $str = str_replace("г","|",$str);
                $str = str_replace("д","|",$str);
                $str = str_replace("е","|",$str);
                $str = str_replace("ё","|",$str);
                $str = str_replace("ж","|",$str);
                $str = str_replace("з","|",$str);
                $str = str_replace("и","|",$str);
                $str = str_replace("й","|",$str);
                $str = str_replace("к","|",$str);
                $str = str_replace("л","|",$str);
                $str = str_replace("м","|",$str);
                $str = str_replace("н","|",$str);
                $str = str_replace("о","|",$str);
                $str = str_replace("п","|",$str);
                $str = str_replace("р","|",$str);
                $str = str_replace("с","|",$str);
                $str = str_replace("т","|",$str);
                $str = str_replace("у","|",$str);
                $str = str_replace("ф","|",$str);
                $str = str_replace("х","|",$str);
                $str = str_replace("ч","|",$str);
                $str = str_replace("ц","|",$str);
                $str = str_replace("ш","|",$str);
                $str = str_replace("щ","|",$str);
                $str = str_replace("ь","|",$str);
                $str = str_replace("ы","|",$str);
                $str = str_replace("ъ","|",$str);
                $str = str_replace("э","|",$str);
                $str = str_replace("ю","|",$str);
                $str = str_replace("я","|",$str);
                $str = str_replace("А","|",$str);
                $str = str_replace("Б","|",$str);
                $str = str_replace("В","|",$str);
                $str = str_replace("Г","|",$str);
                $str = str_replace("Д","|",$str);
                $str = str_replace("Е","|",$str);
                $str = str_replace("Ё","|",$str);
                $str = str_replace("Ж","|",$str);
                $str = str_replace("З","|",$str);
                $str = str_replace("И","|",$str);
                $str = str_replace("Й","|",$str);
                $str = str_replace("К","|",$str);
                $str = str_replace("Л","|",$str);
                $str = str_replace("М","|",$str);
                $str = str_replace("Н","|",$str);
                $str = str_replace("О","|",$str);
                $str = str_replace("П","|",$str);
                $str = str_replace("Р","|",$str);
                $str = str_replace("С","|",$str);
                $str = str_replace("Т","|",$str);
                $str = str_replace("У","|",$str);
                $str = str_replace("Ф","|",$str);
                $str = str_replace("Х","|",$str);
                $str = str_replace("Ч","|",$str);
                $str = str_replace("Ц","|",$str);
                $str = str_replace("Ш","|",$str);
                $str = str_replace("Щ","|",$str);
                $str = str_replace("Ь","|",$str);
                $str = str_replace("Ы","|",$str);
                $str = str_replace("Ъ","|",$str);
                $str = str_replace("Э","|",$str);
                $str = str_replace("Ю","|",$str);
                $str = str_replace("Я","|",$str);
                return $str;
                }


$bak = replace_rus($nickname);

if((preg_match("/[^A-Za-z1-9\@\*\(\)\?\!\-\~\_\[\]\=]+/",$nickname))&&(!preg_match("!^[@\\*\\)\\(\\?\\!\\-_\\]\\|\\[=~]+$!i",$bak))) $error .= "Никнейм содержит недопустимые символы!<br/>\n";

if(preg_match("/[^0-9a-zA-Z_]+/",$password)) $error .= "В пароле содержаться недопустимые символы!<br/>\n";


	if(!empty($error))
	{
	echo'<div class="d5">';
	echo $error;
    echo'</div>';
    echo'<div class="d3">';
    echo"$sitefoot";
    list($msec, $sec) = explode(chr(32), microtime());
    echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
    echo'</div>';
    echo "</body></html>";
	exit();
	}

    $q = mysql_query("SELECT `id` FROM `chat_users` WHERE `nickname` = '".$nickname."';");
	if(mysql_num_rows($q) != 0)
	{
	echo'<div class="d5">';
	echo "К сожалению ник <b>".$nickname."</b> уже занят. Попробуйте зарегистрировать другой ник.<br/>\n";
	echo'</div>';
    echo'<div class="d3">';
    echo"$sitefoot";
    list($msec, $sec) = explode(chr(32), microtime());
    echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
    echo'</div>';
    echo "</body></html>";
	exit();
	}

    $q = mysql_query("SELECT * FROM `chat_banned_nicknames` WHERE `nickname` = '".$nickname."';");
	if(mysql_affected_rows() != 0)
	{
	echo'<div class="d5">';
	echo "Никнейм <b>".$nickname."</b> забанен!<br/>\n";
	echo "</div>";
    echo'<div class="d3">';
    echo"$sitefoot";
    list($msec, $sec) = explode(chr(32), microtime());
    echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
    echo'</div>';
    echo "</body></html>";
	exit();
	}

if($podarok == 1)
{
$registration = mysql_query("INSERT INTO `chat_users` SET `nickname` = '".$nickname."', `password` = '".md5($password)."', `status` = 'Новичок', `sex` = ".$sex.", `birthday` = '".$birthday."', `ip` = '".$ip."', `ua` = '".$ua."', `time` = ".time().", `posts` = '".$postov."', `key` = '', `regdate` = '".date('d-m-Y')."', `version` = '".$ver."', `foto` = '4', `music` = '2', `video` = '2', `goodpass` = '".$password."';");

$box="<b>Системка</b>";
 $msgx="<b>Встречайте и не обижайте</b>, Нашего Нового Пользователя <b>".$nickname."</b>! В подарок ему зачисленно <b>".$postov."</b> постов!";
  $sql = mysql_query("SELECT `id` FROM `chat_rooms` WHERE `type` != 1;");

while($room_id = mysql_fetch_array($sql)){
	mysql_query("INSERT INTO `chat".$room_id['id']."` VALUES(0, '5', '".$box."', '".$msgx."', '0', '".date("H:i")."',".time().",0);");

   }
}
else
{
$registration = mysql_query("INSERT INTO `chat_users` SET `nickname` = '".$nickname."', `password` = '".md5($password)."', `status` = 'Новичок', `sex` = ".$sex.", `birthday` = '".$birthday."', `ip` = '".$ip."', `ua` = '".$ua."', `time` = ".time().", `key` = '', `regdate` = '".date('d-m-Y')."', `version` = '".$ver."', `foto` = '4', `music` = '2', `video` = '2', `goodpass` = '".$password."';");

 $box="<b>Системка</b>";
 $msgx="<b>Встречайте и не обижайте</b>, Нашего Нового Пользователя <b>".$nickname."</b>!";


 $sql = mysql_query("SELECT `id` FROM `chat_rooms` WHERE `type` != 1;");

while($room_id = mysql_fetch_array($sql)){
	mysql_query("INSERT INTO `chat".$room_id['id']."` VALUES(0, '5', '".$box."', '".$msgx."', '0', '".date("H:i")."',".time().",0);");}
    }

 mysql_query("DELETE FROM `chat_code` WHERE `ip`='".ip."' && `ua`='".short_agent."'");


	if($registration)
	{
	$id = mysql_insert_id();
	echo REGISTRATION_SUCCESS."<br/>\n";
	echo "Примечание!<br/>\n";
	echo "Когда Вы будите входить в чат (сегодня завтра неважно когда) пароль и логин нужно будет вводить с учётом регистра!<br/>\n";
	echo "Пример: Есле у Вас логин КАтЯ, то есле вы введёте при авторизации катя то вам система скажит что такого несуществует нужно ввести именно КАтЯ.<br/>\n";
	echo "Ник: <u>".$nickname."</u><br/>\n";
	echo "Пароль: <u>".$password."</u><br/>\n";
	echo "<br/><form action=\"/menu/html/$nocache\" method=\"post\">\n";
	echo "<input type=\"hidden\" name=\"password\" value=\"$password\" />\n";
	echo "<input type=\"hidden\" name=\"nickname\" value=\"$nickname\" />\n";
	echo "<input type=\"hidden\" name=\"action\" value=\"auth\" />\n";
	echo "<input type=\"submit\" value=\"Вход\" /></form>\n";
	echo "<a href=\"/html\">Выход</a><br/>\n";
	}
	else
	{
	echo REGISTRATION_ERROR."<br/>\n";
	echo mysql_error()."<br/>\n";
	}
session_destroy();
}
echo'<div class="d3">';
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo'</div>';
echo "</body></html>";
break;
}
?>