<?php
#==============================================================================================#
#                                   Name  :  Imperial CHAT                                     #
#                               Made by  :  MaZaFaKa (___хакер___)                             #
#                                  MODED :  vipsds  (   BOT  )                                 #
#                                  ICQ  :  350502220 (vipsds)                                  #
#                                E-mai :  vipsds@wapnn.org                                     #
# По всем вопросам и дополнительным модам обращайтесь на выше указанные данные                 #
#==============================================================================================#
error_reporting(0);
include('start.php');
include("config.php");
$ttl = "Анкета";
$id = intval($_SESSION['id']);
$nocache = rand(10000, 99999);
//polu4enie parolya pol'zovatelya
$q_pass = mysql_query("SELECT `password` FROM `chat_users` WHERE `id` = '".$id."';");
$usr_pass = mysql_result($q_pass, 0);
include("./includes/".$ver."/banned");

$ref = rand(1000, 9999);

$banner = file("system/banner.dat");
$ssylka = trim($banner[0]);
$img = trim($banner[1]);
$kabinet = trim($banner[4]);

list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;
$password = mysql_escape_string($_SESSION['password']);
$qinf = mysql_query("SELECT * FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
switch($ver)
{
////////////////////////////////////////////////////////
//WML VERSION
////////////////////////////////////////////////////////
case 'wml':
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");
  //AUTH
$id = intval($_SESSION['id']);
$password = mysql_escape_string($_SESSION['password']);
$q = mysql_query("SELECT `level` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
if(mysql_num_rows($q) == 0)
{
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";
echo "<card title=\"ERROR\" ontimer=\"/wml\"><timer value=\"15\"/><p align=\"left\">\n";
echo "<small>Ошибка авторизации!<br/>\n";
echo"<br/>$wmlfoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo "</small></p></card></wml>";
exit();
}
//END AUTH

//ONLINE
$online = time() + 60;
$update = mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 0, `ip` = '".getenv('REMOTE_ADDR')."', `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."' WHERE `id` = '".$id."';");
//END ONLINE

$user = mysql_fetch_array($qinf);
$nicknames = $user['nickname'];
$name = $user['name'];
$site = $user['site'];
$sex = $user['sex'];
$from = $user['from'];
$mobile = $user['mobile'];
$email = $user['email'];
$birthday = $user['birthday'];
$birthday = explode("-", $birthday);
$about = $user['about'];
$num = $user['nomer'];
$opsos = $user['opsos'];
$nickpary = $user['nickparu'];
$icq = $user['icq'];
$posts = $user['posts'];
$level = $user['level'];
$status = $user['status'];

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";
echo "<card title=\"Профиль\"><p align=\"left\">\n";


 if($_POST['action'])
 {

    $upass = $_POST['upass'];
    $name = mysql_escape_string(htmlspecialchars(trim($_POST['name'])));

	if($_POST['sex'] == 0 or $_POST['sex'] == 1 or $_POST['sex'] == 2)
	{
	$sex = intval($_POST['sex']);
	}
	else
	{
	$sex = 2;
	}

  $day = intval($_POST['day']);
  $day = substr($day, 0, 2);
  $month = intval($_POST['month']);
  $month = substr($month, 0, 2);
  $year = intval($_POST['year']);
  $year = substr($year, 0, 4);


  $options = mysql_escape_string(htmlspecialchars(trim($_POST['options'])));
  $nickpary= mysql_escape_string(htmlspecialchars(trim($_POST['nickpary'])));
  $opsos= mysql_escape_string(htmlspecialchars(trim($_POST['opsos'])));
  $num = mysql_escape_string(htmlspecialchars(trim($_POST['num'])));
  $icq = mysql_escape_string(htmlspecialchars(trim($_POST['icq'])));
  $name = mysql_escape_string(htmlspecialchars(trim($_POST['name'])));
  $from = mysql_escape_string(htmlspecialchars(trim($_POST['from'])));
  $mobile = mysql_escape_string(htmlspecialchars(trim($_POST['mobile'])));
  $email = mysql_escape_string(htmlspecialchars(trim($_POST['email'])));
  $site = strtolower(mysql_escape_string(htmlspecialchars(trim($_POST['site']))));
  $site = str_replace('http://', '', $site);
  $about = mysql_escape_string(htmlspecialchars(trim($_POST['about'])));


  ////////////////////////////////////////////////////////////////////////////////////////////////////////////

  if(empty($upass))$error .= $error1 .= "Не введен пароль!<br/>\n";
  if(preg_match("/[^0-9a-zA-Z_]+/",$upass)) $error2 .= "В пароле есть запрещенные символы!<br/>\n";
  if(strlen($mobile) > 20)$error .= $error3 .= "Слишком много информации в \"Модель мобильного телефона\"!<br/>\n";
  if(strlen($email) > 30) $error .=$error4 .= "Слишком длинный e-mail!<br/>\n";
  if(strlen($site) > 40) $error .=$error5 .= "Слишком длинный адрес сайта!<br/>\n";
  if(strlen($about) > 600) $error .=$error6 .= "Слишком много информации в \"О себе\"!<br/>\n";
  if($day > 31 or $day <= 0) $error .=$error7 .= "Не верно введен день рождения!<br/>\n";
  if($month > 12 or $month <= 0) $error .=$error8 .= "Не верно введен месяц рождения!<br/>\n";
  if($year > 2000 or $year < 1950) $error .=$error9 .="Не верно введен год рождения!<br/>\n";
  if(strlen($name) > 20)$error .= $error10 .= "Слишком длинное имя разрешенно только 10 букв.<br/>\n";
  if(strlen($sex) > 2)$error .= $error11 .= "Неверный индентификатор Пола!<br/>\n";
  if(strlen($from) > 30)$error .= $error12 .= "Не верно введён город разрешенно только 15 букв!<br/>\n";
  if(strlen($num) > 28)$error .= $error13 .= "Не верно введён номер телефона разрешенно только 13 цифр без плюса!<br/>\n";
  if(strlen($icq) > 18)$error .= $error14 .= "Не верно введён номер ICQ разрешенно только 9 цифр!<br/>\n";
  if(empty($name))$error .= $error15 .= "Не введенно имя!<br/>\n";
  if(empty($about))$error .= $error16 .= "Вы не заполнили информацию о Себе!<br/>\n";
  if(strlen($nickpary) > 18)$error .= $error17 .= "Не верно введён ник пары разрешенно только 9 символов!<br/>\n";
  if(strlen($opsos) > 30)$error .= $error18 .= "Не верно введён оператор сотовой связи разрешенно только 15 символов!<br/>\n";
  if(strlen($options) > 4)$error .= $error19 .= "Не верное опеределение цвета!<br/>\n";

  	if($options == 1)
	{
	$colornick = "EF3B37";
    }
	if($options == 2)
	{
	$colornick = "4649D6";
    }
	if($options == 3)
	{
	$colornick = "008000";
    }
	if($options == 4)
	{
	$colornick = "636166";
    }
	if($options == 5)
	{
	$colornick = "FFA500";
    }
	if($options == 6)
	{
	$colornick = "0066FF";
    }
	if($options == 7)
	{
	$colornick = "228B22";
    }
	if($options == 8)
	{
	$colornick = "D02090";
    }
	if($options == 9)
	{
	$colornick = "B03060";
    }
	if($options == 10)
	{
	$colornick = "8A2BE2";
    }
  if($posts > 20000 and $level == 0) // Guru
  {
	if($options == 11)
	{
	$colornick = "FFFFFF";
    }
	if($options == 12)
	{
	$colornick = "006400";
    }
	if($options == 13)
	{
	$colornick = "000080";
    }
  }

  if($level >= 1) // VIP
  {
	if($options == 14)
	{
	$colornick = "FFFF00";
    }
	if($options == 15)
	{
	$colornick = "C0C0C0";
    }
	if($options == 16)
	{
	$colornick = "9ACD32";
    }
  }
  if($level >= 2) // Killer
  {
	if($options == 17)
	{
	$colornick = "7FFF00";
    }
	if($options == 18)
	{
	$colornick = "90EE90";
    }
	if($options == 19)
	{
	$colornick = "4B0082";
    }
  }
  if($level >= 3) // Moder
  {
	if($options == 20)
	{
	$colornick = "8A2BE2";
    }
	if($options == 21)
	{
	$colornick = "008B8B";
    }
	if($options == 22)
	{
	$colornick = "4682B4";
    }
  }
  if($level >= 4) // Admin
  {
	if($options == 23)
	{
	$colornick = "DC143C";
    }
	if($options == 24)
	{
	$colornick = "FF69B4";
    }
	if($options == 25)
	{
	$colornick = "FF8C00";
    }
	if($options == 26)
	{
	$colornick = "FFD700";
    }
	if($options == 27)
	{
	$colornick = "FF7F50";
    }
  }



  /////////////////////////////////////////////////////////////////////////////////////////////////////////////

 }
 else
 {
 $error='open';
 }






 if($error)
 {




    if ($error!=='open')
    {

    echo "<font color=\"#FF0000\">При вводе были допущены следующие ошибки:</font><br/>";

    }


   echo "<b>".$nicknames."</b><br/>";


   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Пароль:<br/>\n";
   echo "<input type=\"text\" name=\"upass$ref\" value=\"$password\" maxlength=\"20\"/><br/>\n";
   echo "".$error1."".$error2."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Цвет ника:<br/>\n";
   echo "<select name=\"options$ref\">\n";
   echo "<option value=\"0\">Черный</option>\n";
   echo "<option value=\"1\">Красный</option>\n";
   echo "<option value=\"2\">Синий</option>\n";
   echo "<option value=\"3\">Зеленый</option>\n";
   echo "<option value=\"4\">Серый</option>\n";
   echo "<option value=\"5\">Оранжевый</option>\n";
   echo "<option value=\"6\">Голубой</option>\n";
   echo "<option value=\"7\">Зеленый лесной</option>\n";
   echo "<option value=\"8\">Красно-фиолетовый</option>\n";
   echo "<option value=\"9\">Темно-бордовый</option>\n";
   echo "<option value=\"10\">Фиолетово-синий</option>\n";
  if($posts > 20000 and $level == 0) // Guru
  {
  echo "<option value=\"11\">Белый</option>\n";
  echo "<option value=\"12\">Темно-зеленый</option>\n";
  echo "<option value=\"13\">Темно-синий</option>\n";
  }
  if($level >= 1) // VIP
  {
  echo "<option value=\"14\">Желтый</option>\n";
  echo "<option value=\"15\">Светло-серый</option>\n";
  echo "<option value=\"16\">Желто-зеленый</option>\n";
  }
  if($level >= 2) // Killer
  {
  echo "<option value=\"17\">Салатовый</option>\n";
  echo "<option value=\"18\">Светло-зеленый</option>\n";
  echo "<option value=\"19\">Индиго</option>\n";
  }
  if($level >= 3) // Moder
  {
  echo "<option value=\"20\">Фиолетовый</option>\n";
  echo "<option value=\"21\">Темно-голубой</option>\n";
  echo "<option value=\"22\">Голубая сталь</option>\n";
  }
  if($level >= 4) // Admin
  {
  echo "<option value=\"23\">Малиновый</option>\n";
  echo "<option value=\"24\">Розовый</option>\n";
  echo "<option value=\"25\">Оранжевый</option>\n";
  echo "<option value=\"26\">Золото</option>\n";
  echo "<option value=\"27\">Кораловый</option>\n";
  }

   echo "</select><br/>\n";
   echo "".$error19."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "*Имя:<br/>\n";
   echo "<input type=\"text\" name=\"name$ref\" value=\"$name\" maxlength=\"20\"/><br/>\n";
   echo "".$error10." ".$error15."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Ник пары:<br/>\n";
   echo "<input type=\"text\" name=\"nickpary$ref\" value=\"$nickpary\" maxlength=\"20\"/><br/>\n";
   echo "".$error17."";
   /////////////////////////////////////////////////////////////////////////////////////////

   echo "Пол:<br/>\n";
   echo "<select name=\"sex$ref\">\n";
   if($sex == 0)
   {
   echo "<option value=\"0\">Мужской</option>\n";
   echo "<option value=\"1\">Женский</option>\n";
   echo "</select><br/>\n";
   }
   elseif($sex == 1)
   {
   echo "<option value=\"1\">Женский</option>\n";
   echo "<option value=\"0\">Мужской</option>\n";
   echo "</select><br/>\n";
   }
   else
   {
   echo "<option value=\"1\">Женский</option>\n";
   echo "<option value=\"0\">Мужской</option>\n";
   echo "</select><br/>\n";
   }
   echo "".$error11."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "*Дата рождения:<br/>";
   echo "<input size=\"4\" name=\"day$ref\" value=\"".$birthday[0]."\" maxlength=\"2\"/> День<br/>";
   echo "".$error7."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "<input size=\"4\" name=\"month$ref\" value=\"".$birthday[1]."\" maxlength=\"2\"/> Месяц<br/>";
   echo "".$error8."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "<input size=\"4\" name=\"year$ref\" value=\"".$birthday[2]."\" maxlength=\"4\"/> Год<br/>";
   echo "".$error9."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Город:<br/>\n";
   echo "<input type=\"text\" name=\"from$ref\" value=\"$from\" maxlength=\"20\"/><br/>";
   echo "".$error12."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Модель телефона:<br/>\n";
   echo "<input type=\"text\" name=\"mobile$ref\" value=\"$mobile\" maxlength=\"20\"/><br/>";
   echo "".$error3."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Оператор СС:<br/>\n";
   echo "<input type=\"text\" name=\"opsos$ref\" value=\"$opsos\" maxlength=\"20\"/><br/>";
   echo "".$error18."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Номер тлф:<br/>\n";
   echo "<input type=\"text\" name=\"num$ref\" value=\"$num\" maxlength=\"20\"/><br/>";
   echo "".$error13."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Е-Маил:<br/>\n";
   echo "<input type=\"text\" name=\"email$ref\" value=\"$email\" maxlength=\"20\"/><br/>";
   echo "".$error4."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Номер ICQ:<br/>\n";
   echo "<input type=\"text\" name=\"icq$ref\" value=\"$icq\" maxlength=\"20\"/><br/>";
   echo "".$error14."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "*О себе:<br/>\n";
   echo "<input type=\"text\" name=\"about$ref\" value=\"$about\" maxlength=\"300\"/><br/>";
   echo "".$error6."".$error16."";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Wap сайт:<br/>\n";
   echo "<input type=\"text\" name=\"site$ref\" value=\"http://".$site."\" maxlength=\"30\"/><br/>";
   echo "".$error5."";
   /////////////////////////////////////////////////////////////////////////////////////////

  echo "<br/><anchor>Изменить<go href=\"profile.php?".SID."&amp;ref=$ref&amp;ver=wml\" method=\"post\">\n";
  echo "<postfield name=\"upass\" value=\"$(upass$ref)\"/>
  <postfield name=\"name\" value=\"$(name$ref)\"/>
  <postfield name=\"nickpary\" value=\"$(nickpary$ref)\"/>
  <postfield name=\"options\" value=\"$(options$ref)\"/>
  <postfield name=\"sex\" value=\"$(sex$ref)\"/>
  <postfield name=\"day\" value=\"$(day$ref)\"/>
  <postfield name=\"month\" value=\"$(month$ref)\"/>
  <postfield name=\"year\" value=\"$(year$ref)\"/>
  <postfield name=\"from\" value=\"$(from$ref)\"/>
  <postfield name=\"pass\" value=\"".$_POST['pass']."\"/>
  <postfield name=\"mobile\" value=\"$(mobile$ref)\"/>
  <postfield name=\"opsos\" value=\"$(opsos$ref)\"/>
  <postfield name=\"num\" value=\"$(num$ref)\"/>
  <postfield name=\"email\" value=\"$(email$ref)\"/>
  <postfield name=\"icq\" value=\"$(icq$ref)\"/>
  <postfield name=\"about\" value=\"$(about$ref)\"/>
  <postfield name=\"site\" value=\"$(site$ref)\"/>
  <postfield name=\"action\" value=\"save\"/>
  </go></anchor><br/>\n";
  echo"<br/>";
  echo "• <a href=\"/kabinet/wml\">Личный кабинет</a><br/>\n";
  echo "• <a href=\"/menu/wml\">В прихожую</a><br/>\n";
  include('banners/kabinet');
  echo"<br/>$wmlfoot";
  list($msec, $sec) = explode(chr(32), microtime());
  echo "[".round(($sec+$msec)-$headtime,5)."] сек.<br/>\n";
  echo "</p></card></wml>";
  exit();
 }



 if($_POST['action'])
 {

  $q = mysql_query("UPDATE `chat_users` SET `password` = '".md5($upass)."', `name` = '".$name."', `sex` = '".$sex."', `birthday` = '$day-$month-$year', `from` = '".$from."', `mobile` = '".$mobile."', `email` = '".$email."', `site` = '".$site."', `about` = '".$about."', `opsos` = '".$opsos."', `icq` = '".$icq."', `nomer` = '".$num."', `nickparu` = '".$nickpary."', `colornick` = '".$colornick."', `version` = '".$ver."' WHERE `id` = '".$id."';");
  $_SESSION['password']= $upass;
  echo "Профиль успешно сохранен!<br/>\n";
  echo "• <a href=\"/kabinet/wml\">Личный кабинет</a><br/>\n";
  echo "• <a href=\"/menu/wml\">В прихожую</a><br/>\n";
 }

include('banners/kabinet');
echo"<br/>$wmlfoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] сек.<br/>\n";
echo "</p></card></wml>";
break;

////////////////////////////////////////////////////////
//HTML VERSION
////////////////////////////////////////////////////////
case 'html':
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-revalidate");
   //AUTH
$id = intval($_SESSION['id']);
$password = mysql_escape_string($_SESSION['password']);
$q = mysql_query("SELECT `level` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
if(mysql_num_rows($q) == 0)
{
echo "$css";
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">Ошибка</div>';
echo "<div class=\"d5\">Ошибка авторизации!</div>\n";
echo'<div class="d3">';
include('banners/kabinet');
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] сек.<br/>\n";
echo'</div>';
echo "</body></html>";
exit();
}
//END AUTH

//ONLINE
$online = time() + 60;
$update = mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 0, `ip` = '".getenv('REMOTE_ADDR')."', `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."' WHERE `id` = '".$id."';");
//END ONLINE

$user = mysql_fetch_array($qinf);
$nicknames = $user['nickname'];
$name = $user['name'];
$site = $user['site'];
$sex = $user['sex'];
$from = $user['from'];
$mobile = $user['mobile'];
$email = $user['email'];
$birthday = $user['birthday'];
$birthday = explode("-", $birthday);
$about = $user['about'];
$num = $user['nomer'];
$opsos = $user['opsos'];
$nickpary = $user['nickparu'];
$icq = $user['icq'];
$posts = $user['posts'];
$level = $user['level'];
$status = $user['status'];
echo "$css";
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">'.$ttl.'</div>';




 if($_POST['action'])
 {

    $upass = $_POST['upass'];
    $name = mysql_escape_string(htmlspecialchars(trim($_POST['name'])));

	if($_POST['sex'] == 0 or $_POST['sex'] == 1 or $_POST['sex'] == 2)
	{
	$sex = intval($_POST['sex']);
	}
	else
	{
	$sex = 2;
	}

  $day = intval($_POST['day']);
  $day = substr($day, 0, 2);
  $month = intval($_POST['month']);
  $month = substr($month, 0, 2);
  $year = intval($_POST['year']);
  $year = substr($year, 0, 4);


  $options = mysql_escape_string(htmlspecialchars(trim($_POST['options'])));
  $nickpary= mysql_escape_string(htmlspecialchars(trim($_POST['nickpary'])));
  $opsos= mysql_escape_string(htmlspecialchars(trim($_POST['opsos'])));
  $num = mysql_escape_string(htmlspecialchars(trim($_POST['num'])));
  $icq = mysql_escape_string(htmlspecialchars(trim($_POST['icq'])));
  $name = mysql_escape_string(htmlspecialchars(trim($_POST['name'])));
  $from = mysql_escape_string(htmlspecialchars(trim($_POST['from'])));
  $mobile = mysql_escape_string(htmlspecialchars(trim($_POST['mobile'])));
  $email = mysql_escape_string(htmlspecialchars(trim($_POST['email'])));
  $site = strtolower(mysql_escape_string(htmlspecialchars(trim($_POST['site']))));
  $site = str_replace('http://', '', $site);
  $about = mysql_escape_string(htmlspecialchars(trim($_POST['about'])));


  ////////////////////////////////////////////////////////////////////////////////////////////////////////////

  if(empty($upass))$error .= $error1 .= "Не введен пароль!<br/>\n";
  if(preg_match("/[^0-9a-zA-Z_]+/",$upass)) $error2 .= "В пароле есть запрещенные символы!<br/>\n";
  if(strlen($mobile) > 20)$error .= $error3 .= "Слишком много информации в \"Модель мобильного телефона\"!<br/>\n";
  if(strlen($email) > 30) $error .=$error4 .= "Слишком длинный e-mail!<br/>\n";
  if(strlen($site) > 40) $error .=$error5 .= "Слишком длинный адрес сайта!<br/>\n";
  if(strlen($about) > 600) $error .=$error6 .= "Слишком много информации в \"О себе\"!<br/>\n";
  if($day > 31 or $day <= 0) $error .=$error7 .= "Не верно введен день рождения!<br/>\n";
  if($month > 12 or $month <= 0) $error .=$error8 .= "Не верно введен месяц рождения!<br/>\n";
  if($year > 2000 or $year < 1950) $error .=$error9 .="Не верно введен год рождения!<br/>\n";
  if(strlen($name) > 20)$error .= $error10 .= "Слишком длинное имя разрешенно только 10 букв.<br/>\n";
  if(strlen($sex) > 2)$error .= $error11 .= "Неверный индентификатор Пола!<br/>\n";
  if(strlen($from) > 30)$error .= $error12 .= "Не верно введён город разрешенно только 15 букв!<br/>\n";
  if(strlen($num) > 28)$error .= $error13 .= "Не верно введён номер телефона разрешенно только 13 цифр без плюса!<br/>\n";
  if(strlen($icq) > 18)$error .= $error14 .= "Не верно введён номер ICQ разрешенно только 9 цифр!<br/>\n";
  if(empty($name))$error .= $error15 .= "Не введенно имя!<br/>\n";
  if(empty($about))$error .= $error16 .= "Вы не заполнили информацию о Себе!<br/>\n";
  if(strlen($nickpary) > 18)$error .= $error17 .= "Не верно введён ник пары разрешенно только 9 символов!<br/>\n";
  if(strlen($opsos) > 30)$error .= $error18 .= "Не верно введён оператор сотовой связи разрешенно только 15 символов!<br/>\n";
  if(strlen($options) > 4)$error .= $error19 .= "Не верное опеределение цвета!<br/>\n";

  	if($options == 1)
	{
	$colornick = "EF3B37";
    }
	if($options == 2)
	{
	$colornick = "4649D6";
    }
	if($options == 3)
	{
	$colornick = "008000";
    }
	if($options == 4)
	{
	$colornick = "636166";
    }
	if($options == 5)
	{
	$colornick = "FFA500";
    }
	if($options == 6)
	{
	$colornick = "0066FF";
    }
	if($options == 7)
	{
	$colornick = "228B22";
    }
	if($options == 8)
	{
	$colornick = "D02090";
    }
	if($options == 9)
	{
	$colornick = "B03060";
    }
	if($options == 10)
	{
	$colornick = "8A2BE2";
    }
    ////////////////////

  if($posts > 20000 and $level == 0) // Guru
  {
	if($options == 11)
	{
	$colornick = "FFFFFF";
    }
	if($options == 12)
	{
	$colornick = "006400";
    }
	if($options == 13)
	{
	$colornick = "000080";
    }
  }

  if($level >= 1) // VIP
  {
	if($options == 14)
	{
	$colornick = "FFFF00";
    }
	if($options == 15)
	{
	$colornick = "C0C0C0";
    }
	if($options == 16)
	{
	$colornick = "9ACD32";
    }
  }
  if($level >= 2) // Killer
  {
	if($options == 17)
	{
	$colornick = "7FFF00";
    }
	if($options == 18)
	{
	$colornick = "90EE90";
    }
	if($options == 19)
	{
	$colornick = "4B0082";
    }
  }
  if($level >= 3) // Moder
  {
	if($options == 20)
	{
	$colornick = "8A2BE2";
    }
	if($options == 21)
	{
	$colornick = "008B8B";
    }
	if($options == 22)
	{
	$colornick = "4682B4";
    }
  }
  if($level >= 4) // Admin
  {
	if($options == 23)
	{
	$colornick = "DC143C";
    }
	if($options == 24)
	{
	$colornick = "FF69B4";
    }
	if($options == 25)
	{
	$colornick = "FF8C00";
    }
	if($options == 26)
	{
	$colornick = "FFD700";
    }
	if($options == 27)
	{
	$colornick = "FF7F50";
    }
  }

 }
 else
 {
 $error='open';
 }





 if($error)
 {


    if ($error!=='open')
    {

    echo "<font color=\"#FF0000\">При вводе были допущены следующие ошибки:</font><br/>";

    }


   echo "<b>".$nicknames."</b><br/>";


   echo "<form method=\"post\" action=\"profile.php?".SID."&amp;ref=$ref&amp;ver=html\">\n";


   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Пароль:<br/>\n";
   echo "<input type=\"text\" name=\"upass\" value=\"$password\" maxlength=\"20\"/><br/>\n";
   echo "<font color=\"#FF0000\">".$error1."".$error2."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Цвет ника:<br/>\n";
   echo "<select name=\"options\">\n";
   echo "<option value=\"0\" selected=\"selected\">Черный</option>\n";
   echo "<option value=\"1\">Красный</option>\n";
   echo "<option value=\"2\">Синий</option>\n";
   echo "<option value=\"3\">Зеленый</option>\n";
   echo "<option value=\"4\">Серый</option>\n";
   echo "<option value=\"5\">Оранжевый</option>\n";
   echo "<option value=\"6\">Голубой</option>\n";
   echo "<option value=\"7\">Зеленый лесной</option>\n";
   echo "<option value=\"8\">Красно-фиолетовый</option>\n";
   echo "<option value=\"9\">Темно-бордовый</option>\n";
   echo "<option value=\"10\">Фиолетово-синий</option>\n";

  if($posts > 20000 and $level == 0) // Guru
  {
  echo "<option value=\"11\">Белый</option>\n";
  echo "<option value=\"12\">Темно-зеленый</option>\n";
  echo "<option value=\"13\">Темно-синий</option>\n";
  }
  if($level >= 1) // VIP
  {
  echo "<option value=\"14\">Желтый</option>\n";
  echo "<option value=\"15\">Светло-серый</option>\n";
  echo "<option value=\"16\">Желто-зеленый</option>\n";
  }
  if($level >= 2) // Killer
  {
  echo "<option value=\"17\">Салатовый</option>\n";
  echo "<option value=\"18\">Светло-зеленый</option>\n";
  echo "<option value=\"19\">Индиго</option>\n";
  }
  if($level >= 3) // Moder
  {
  echo "<option value=\"20\">Фиолетовый</option>\n";
  echo "<option value=\"21\">Темно-голубой</option>\n";
  echo "<option value=\"22\">Голубая сталь</option>\n";
  }
  if($level >= 4) // Admin
  {
  echo "<option value=\"23\">Малиновый</option>\n";
  echo "<option value=\"24\">Розовый</option>\n";
  echo "<option value=\"25\">Оранжевый</option>\n";
  echo "<option value=\"26\">Золото</option>\n";
  echo "<option value=\"27\">Кораловый</option>\n";
  }

   echo "</select><br/>\n";
   echo "<font color=\"#FF0000\">".$error19."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "*Имя:<br/>\n";
   echo "<input type=\"text\" name=\"name\" value=\"$name\" maxlength=\"20\"/><br/>\n";
   echo "<font color=\"#FF0000\">".$error10." ".$error15."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Ник пары:<br/>\n";
   echo "<input type=\"text\" name=\"nickpary\" value=\"$nickpary\" maxlength=\"20\"/><br/>\n";
   echo "<font color=\"#FF0000\">".$error17."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////

   echo "Пол:<br/>\n";
   echo "<select name=\"sex\">\n";
   if($sex == 0)
   {
   echo "<option value=\"0\" selected=\"selected\">Мужской</option>\n";
   echo "<option value=\"1\">Женский</option>\n";
   echo "</select><br/>\n";
   }
   elseif($sex == 1)
   {
   echo "<option value=\"1\" selected=\"selected\">Женский</option>\n";
   echo "<option value=\"0\">Мужской</option>\n";
   echo "</select><br/>\n";
   }
   else
   {
   echo "<option value=\"1\">Женский</option>\n";
   echo "<option value=\"0\">Мужской</option>\n";
   echo "</select><br/>\n";
   }
   echo "<font color=\"#FF0000\">".$error11."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "*Дата рождения:<br/>";
   echo "<input size=\"4\" name=\"day\" value=\"".$birthday[0]."\" maxlength=\"2\"/> День<br/>";
   echo "<font color=\"#FF0000\">".$error7."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "<input size=\"4\" name=\"month\" value=\"".$birthday[1]."\" maxlength=\"2\"/> Месяц<br/>";
   echo "<font color=\"#FF0000\">".$error8."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "<input size=\"4\" name=\"year\" value=\"".$birthday[2]."\" maxlength=\"4\"/> Год<br/>";
   echo "<font color=\"#FF0000\">".$error9."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Город:<br/>\n";
   echo "<input type=\"text\" name=\"from\" value=\"$from\" maxlength=\"20\"/><br/>";
   echo "<font color=\"#FF0000\">".$error12."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Модель телефона:<br/>\n";
   echo "<input type=\"text\" name=\"mobile\" value=\"$mobile\" maxlength=\"20\"/><br/>";
   echo "<font color=\"#FF0000\">".$error3."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Оператор СС:<br/>\n";
   echo "<input type=\"text\" name=\"opsos\" value=\"$opsos\" maxlength=\"20\"/><br/>";
   echo "<font color=\"#FF0000\">".$error18."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Номер тлф:<br/>\n";
   echo "<input type=\"text\" name=\"num\" value=\"$num\" maxlength=\"20\"/><br/>";
   echo "<font color=\"#FF0000\">".$error13."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Е-Маил:<br/>\n";
   echo "<input type=\"text\" name=\"email\" value=\"$email\" maxlength=\"20\"/><br/>";
   echo "<font color=\"#FF0000\">".$error4."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Номер ICQ:<br/>\n";
   echo "<input type=\"text\" name=\"icq\" value=\"$icq\" maxlength=\"20\"/><br/>";
   echo "<font color=\"#FF0000\">".$error14."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "*О себе:<br/>\n";
   echo "<textarea  type=\"text\" name=\"about\" rows=\"5\" cols=\"30\" maxlength=\"300\"/>".$about."</textarea><br/>";
   echo "<font color=\"#FF0000\">".$error6."".$error16."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////
   echo "Wap сайт:<br/>\n";
   echo "<input type=\"text\" name=\"site\" value=\"http://".$site."\" maxlength=\"30\"/><br/>";
   echo "<font color=\"#FF0000\">".$error5."</font>";
   /////////////////////////////////////////////////////////////////////////////////////////

   echo "<input type=\"hidden\" name=\"action\" value=\"save\"/>\n";
   echo "<input type=\"hidden\" name=\"pass\" value=\"".$_POST['pass']."\"/>\n";
   echo "<input type=\"submit\" value=\"Изменить\"/></form></div><br/>\n";
   echo "<div class=\"d1\">• <a href=\"/kabinet/html\">Личный кабинет</a></div>\n";
   echo "<div class=\"d1\">• <a href=\"/menu/html\">В прихожую</a></div>";
   echo'<div class="d3">';

   echo"$sitefoot";
   list($msec, $sec) = explode(chr(32), microtime());
   echo "[".round(($sec+$msec)-$headtime,5)."] сек.<br/>\n";
   echo'</div>';
   echo "</body></html>";

   exit();
 }

 if($_POST['action'])
 {

  $q = mysql_query("UPDATE `chat_users` SET `password` = '".md5($upass)."', `name` = '".$name."', `sex` = '".$sex."', `birthday` = '$day-$month-$year', `from` = '".$from."', `mobile` = '".$mobile."', `email` = '".$email."', `site` = '".$site."', `about` = '".$about."', `opsos` = '".$opsos."', `icq` = '".$icq."', `nomer` = '".$num."', `nickparu` = '".$nickpary."', `colornick` = '".$colornick."', `version` = '".$ver."' WHERE `id` = '".$id."';");
  $_SESSION['password']= $upass;
  echo "Профиль успешно сохранен!<br/>\n";
  echo "<div class=\"d1\">• <a href=\"/kabinet/html\">Личный кабинет</a></div>\n";
  echo "<div class=\"d1\">• <a href=\"/menu/html\">В прихожую</a><br/>";
  include('banners/kabinet');
  echo'</div>';
 }

echo'<div class="d3">';
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] сек.<br/>\n";
echo'</div>';
echo "</body></html>";
break;
}
?>