<?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 `privilegii` 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

$privilegii = mysql_result($q, 0);

if($privilegii <2)
{
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=\"Оппаньки\" ontimer=\"/wml\"><timer value=\"15\"/><p align=\"left\">\n";
echo "<small>Нормалег пацанчеги! У вас ЁПТЬ уровень привилегий Маненький!<br/>\n";
echo"$wmlfoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo "</small></p></card></wml>";
exit();
}



$user = mysql_fetch_array($qinf);
$nicknames = $user['nickname'];
$name = $user['name'];

$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'])
 {



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



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



  if(strlen($status) > 20)$error .= $error10 .= "Слишком длинное имя разрешенно только 10 букв.<br/>\n";



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

 }
 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=\"status$ref\" value=\"$status\" maxlength=\"20\"/><br/>\n";
   echo "".$error10."";
   /////////////////////////////////////////////////////////////////////////////////////////

  echo "<br/><anchor>Изменить<go href=\"status.php?".SID."&amp;ref=$ref&amp;ver=wml\" method=\"post\">\n";
  echo "<postfield name=\"upass\" value=\"$(upass$ref)\"/>
  <postfield name=\"status\" value=\"$(status$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 `status` = '".$status."' 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 `privilegii` 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


$privilegii = mysql_result($q, 0);

if($privilegii < 2)
{
echo "$css";
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">Оппаньки</div>';
echo "<div class=\"d5\">Нормалег пацанчеги! У вас ЁПТЬ уровень привилегий Маненький!</div>\n";
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();
}


$user = mysql_fetch_array($qinf);
$nicknames = $user['nickname'];

$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'])));


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


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

  if(strlen($status) > 20)$error .= $error10 .= "Слишком длинный статус только 10 букв.<br/>\n";

       }
 else
 {
 $error='open';
 }





 if($error)
 {


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

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

    }


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

   echo "<form method=\"post\" action=\"status.php?".SID."&amp;ref=$ref&amp;ver=html\">\n";
   echo "*Статус:<br/>\n";
   echo "<input type=\"text\" name=\"status\" value=\"$status\" maxlength=\"20\"/><br/>\n";
   echo "<font color=\"#FF0000\">".$error10."</font>";


   echo "<input type=\"hidden\" name=\"action\" value=\"save\"/>\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  `status` = '".$status."' 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;
}
?>