<?php
#==============================================================================================#
#                                   Name  :  Imperial CHAT                                     #
#                               Made by  :  MaZaFaKa (___хакер___)                             #
#                                  MODED :  vipsds  (   BOT  )                                 #
#                                  ICQ  :  350502220 (vipsds)                                  #
#                                E-mai :  vipsds@wapnn.org                                     #
# По всем вопросам и дополнительным модам обращайтесь на выше указанные данные                 #
#==============================================================================================#
error_reporting(0);
include('start.php');
if(isset($_POST['ver'])) $_GET['ver'] = $_POST['ver'];

include("config.php");
include("./includes/".$ver."/banned");
$ttl="История";
$bots = file("bots/bots.dat");

$nocache = mt_rand(10000, 99999);

list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;
$s = intval($_GET['s']);

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");

$q = mysql_query("SELECT `id` FROM `chat_banned` WHERE `ip` = '".getenv('REMOTE_ADDR')."' AND `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."';");

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=\"$ttl\"><p align=\"center\">\n";
echo "Вы забанены на этом чате.<br/>\n";
echo"<br/>$wmlfoot";
echo "</p></card></wml>";
exit();
}

//AUTH
$id = intval($_SESSION['id']);
$password = mysql_escape_string($_SESSION['password']);
$q = mysql_query("SELECT `nickname`, `level`, `security`, `fsize`, `translit`, `smiles`, `refresh`, `msgs`, `kick`, `moder`, `reason` 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=\"$ttl\" ontimer=\"index.php?ver=wml\"><timer value=\"15\"/><p align=\"left\">\n";
echo "<small>Ошибка авторизации!<br/>\n";
echo"<br/>$wmlfoot";
echo "</small></p></card></wml>";
exit();
}
else
{
$user = mysql_fetch_array($q);
$nickname = $user['nickname'];
$smiles = $user['smiles'];
$translit  = $user['translit'];
$msgs  = $user['msgs'];
$refresh = $user['refresh'];
$fsize = $user['fsize'];
$security  = $user['security'];
$level = $user['level'];
$kick = $user['kick'];
$moder = $user['moder'];
$reason = $user['reason'];
$refresh = $refresh * 10;
}
//END AUTH

$key = 'public';

if(!isset($_REQUEST['key']))
{
if(preg_match("/[^0-9a-zA-Z_]+/", $_REQUEST['key']))

	{
      header ("Location: /key/wml/invalid");
	  exit;
	}
    else
	{
	  $key = mysql_escape_string(htmlspecialchars($_REQUEST['key']));
	}
}


if($kick > time())
{
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=\"$ttl\" ontimer=\"rules.php?".SID."&amp;ver=wml\"><timer value=\"50\"/><p align=\"left\">\n";
echo "<small>Вы временно заблокированы модератором <u>$moder</u> на <u>".($kick - time())."</u> сек.<br/>\n";
echo "Причина: $reason<br/>\n";
echo"<br/>$wmlfoot";
echo "</small></p></card></wml>";
exit();
}

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

$sql = mysql_query("SELECT `nickname` FROM `chat_users` WHERE `key` = '".$key."' AND `intim` >= ".time());

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 "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"chat\" title=\"$ttl\">\n";
echo "<p align=\"left\">\n";

if($fsize == 0)
{
$open_tag = "<small>";
$close_tag = "</small>";
}
if($fsize == 1)
{
$open_tag = "";
$close_tag = "";
}
if($fsize == 2)
{
$open_tag = "<big>";
$close_tag = "</big>";
}

echo $open_tag;

$c = 0;
if(isset($_POST['msg']))
{
mysql_query("SELECT * FROM `chat` WHERE `aid` = ".$id." AND `seconds` > ".(time() - 20));
if(mysql_affected_rows() > 3)
{
$reason = "Вы были автоматически забанены системой за флуд (многократное повторение сообщений).";
mysql_query("UPDATE `chat_users` SET `kick` = ".(time() + 180).", `moder` = '".$bots[3]."', `reason` = '".$reason."';");
}

$msg = trim($_POST['msg']);

if(isset($_POST['uid']))
{
$sql = mysql_query("SELECT `nickname` FROM `chat_users` WHERE `id` = ".intval($_POST['uid']));
$nick = mysql_result($sql, 0);
}
else
{
$nick = "";
}

$msg = addslashes($msg);

	if($_POST['translit'] == "true")
	{
	$msg = str_replace("\"", "ъ", $msg);
	$msg = str_replace("'", "ь", $msg);

	$lat = array("CH", "ch", "SC", "sc", "YE", "ye", "YU", "yu", "YA", "ya", "YO", "yo");
	$rus = array("Ч", "ч", "Щ", "щ", "Э", "э", "Ю", "ю", "Я", "я", "Ё", "ё");
	$msg = str_replace($lat, $rus, $msg);

	$lat = array("A", "a", "B", "b", "C", "c", "D", "d", "E", "e", "F", "f", "G", "g", "H", "h", "I", "i", "J", "j", "K", "k", "L", "l", "M", "m", "N", "n", "O", "o", "P", "p", "R", "r", "S", "s", "T", "t", "U", "u", "V", "v", "H", "h", "Z", "z", "W", "w", "X", "x", "Y", "y");
	$rus = array("А", "а", "Б", "б", "Ц", "ц", "Д", "д", "Е", "е", "Ф", "ф", "Г", "г", "Х", "х", "И", "и", "Ж", "ж", "К", "к", "Л", "л", "М", "м", "Н", "н", "О", "о", "П", "п", "Р", "р", "С", "с", "Т", "т", "У", "у", "В", "в", "Х", "х", "З", "з", "Ш", "ш", "Ы", "ы", "Й", "й");
	$msg = str_replace($lat, $rus, $msg);
	}

$msg = htmlspecialchars($msg);


$msg = iconv_substr($msg, 0, 1024, 'utf-8');
$msg = str_replace('$', '$$', $msg);

$msg = eregi_replace("((http://))((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z;]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:;\?\.-]*)*)", "<a href=\"\\0\">\\3</a>", $msg);

if($level == 4)
{
$msg = preg_replace("|\*\((.*)\)\*|isU", '<b>$1</b>', $msg);
}

$sql = mysql_query("SELECT `msg` FROM `chat_intim` WHERE `key` = '".$key."' AND `aid` = ".$id." ORDER BY `id` DESC LIMIT 1;");
$last_msg = mysql_escape_string(mysql_result($sql, 0));

	if($last_msg != $msg && !empty($msg))
	{
	$to = (int)$_POST['to'];
	$sql = mysql_query("INSERT INTO `chat_intim` VALUES(0, '".$id."', '".$nickname."', '".$msg."', '".$key."', '".$to."', '".date("H:i")."',".time().",".intval($_POST['uid']).");");
		/*
		if(mysql_insert_id() > 4000000000)
		{
		mysql_query("TRUNCATE TABLE `chat`;");
		$message = "Комнаты интима были очищены системой. Данная операция была важна для снятия нагрузки с базы данных.";
		$sql = mysql_query("SELECT `id` FROM `chat_intim`;");
			while($room_id = mysql_fetch_array($sql))
			{
			mysql_query("INSERT INTO `chat` VALUES(0, '5', '".$bots[3]."', '".$message."', '".$key."', '0', '".date("H:i")."',".time().",".intval($_POST['uid']).");");
			}
		}
		if(!$sql)
		{
		$sql = mysql_query("INSERT INTO `chat` VALUES(0, '".$id."', '".$nickname."', '".$msg."', '".$rid."', '".$to."', '".date("H:i")."', ".time().",".intval($_POST['uid']).");");
		}
		*/
	mysql_query("UPDATE `chat_users` SET `posts` = `posts` + 1 WHERE `id` = ".$id);
	}
}

$sql = mysql_query("SELECT COUNT(*) FROM `chat_intim` WHERE `key` = '".$key."';");
$all = mysql_result($sql, 0);

$s = intval($_GET['s']);
if($s < 0) $s = 0;
if($s > $all) $s = 0;

$sql = mysql_query("SELECT * FROM `chat_intim` WHERE `key` = '".$key."' ORDER BY `id` DESC LIMIT $s, $msgs;");

while($post = mysql_fetch_assoc($sql))
{
//text
$q = mysql_query("SELECT * FROM `chat_users` WHERE `id` = ".$post['aid']);
$lvv = mysql_fetch_array($q);
//SMILES
include "includes/smiles_array/all.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
include "includes/smiles_array/bystrye.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
if($lvv['posts'] > 0)
{
include "includes/smiles_array/polzovatel.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
if($lvv['level'] > 3 or $lvv['posts'] >= 3000)
{
include "includes/smiles_array/chatter.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
if($lvv['level'] > 3 or $lvv['posts'] >= 8000)
{
include "includes/smiles_array/smiles_person.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
if($lvv['level'] != 0)
{
include "includes/smiles_array/moder.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
if($lvv['level'] > 3)
{
include "includes/smiles_array/admin.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
//


$post['msg'] = str_replace("<font color=red>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=blue>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=#008000>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=gray>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=#FFA500>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=#0066FF>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=#228B22>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=#D02090>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=#B03060>"," ",$post['msg']);
$post['msg'] = str_replace("<font color=#8A2BE2>"," ",$post['msg']);
$post['msg'] = str_replace("</font>"," ",$post['msg']);

if($lvv['level'] != 0)
{
include "includes/text_array/moder_tegi.php";
$post['msg'] = preg_replace($search, $replace, $post['msg']);
}


echo "<u>[".$post['time']."]</u> <a href=\"/infoi/wml/$key/$nocache/".$post['aid']."/\">".$lvv['nickname']."</a> >\n";
$post['msg'] = stripslashes($post['msg']);
if($smiles == 0) $post['msg'] = preg_replace("|<img[^>]+>|isU", "*smile*", $post['msg']);
$post['msg'] = str_replace("<usersid>", SID, $post['msg']);
//Tonickname
$qm = mysql_query("SELECT `nickname` FROM `chat_users` WHERE `id` ='".$post['tonick']."';");
$tonick = mysql_result($qm, 0);
if($nickname == $tonick)
{
$tonick = "<b>$tonick</b>";
}
if($post['tonick'] != 0)
{
echo $tonick.", \n";
}
if($post['to'] != 0)
{
echo "<b>[P!]\n</b>";
}
echo $post['msg']."<br/>\n";
}
echo"<br/>";
echo "• <a href=\"/intim/wml/$key/$nocache\">В чат</a><br/>\n";
echo "• <a href=\"/online/wml\">Кто где</a><br/>\n";
echo "• <a href=\"/menu/wml/$nocache\">В прихожую</a><br/>\n";

echo $close_tag;

echo"<br/>$wmlfoot";
echo "</p></card><card id=\"add\" title=\"Сказать\"><p align=\"left\">";
echo "Сообщение:<br/>\n";
echo "<input type=\"text\" name=\"msg$nocache\" maxlength=\"300\" value=\"\"/><br/>\n";
if($translit == 1)
{
echo "Транслитировать:<br/>\n";
echo "<select name=\"translit$nocache\" value=\"true\">\n";
echo "<option value=\"true\">Да</option>\n";
echo "<option value=\"false\">Нет</option>\n";
echo "</select><br/>\n";
}

echo "<anchor>Сказать<go href=\"/intim/wml/$key/$nocache\" method=\"post\">\n";
echo "<postfield name=\"msg\" value=\"$(msg$nocache)\"/>\n";
echo "<postfield name=\"translit\" value=\"$(translit$nocache)\"/>\n";
echo "<postfield name=\"attributs\" value=\"$(attributs$nocache)\"/>\n";
echo "<postfield name=\"fsize\" value=\"$(fsize$nocache)\"/>\n";
echo "<postfield name=\"key\" value=\"".$key."\"/>\n";
echo "</go></anchor><br/>\n";
echo"<br/>";
echo "• <a href=\"/intim/wml/$key/$nocache\">В чат</a><br/>\n";
echo"<br/>$wmlfoot";
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 * FROM `chat_users` WHERE `id` = ".$id." AND `password` = '".md5($password)."';");

if(mysql_affected_rows() == 0)
{
echo "$css";
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">Ошибка</div>';
echo "<div class=\"d5\">Ошибка авторизации!</div>\n";
echo'<div class="d3">';
echo"$sitefoot";
echo'</div>';
echo "</body></html>";
exit();
}
else
{
$user = mysql_fetch_assoc($q);
$nickname = $user['nickname'];
$smiles = $user['smiles'];
$translit  = $user['translit'];
$msgs  = $user['msgs'];
$refresh = $user['refresh'];
$fsize = $user['fsize'];
$security  = $user['security'];
$level = $user['level'];
$kick = $user['kick'];
$moder = $user['moder'];
$reason = $user['reason'];
$fsize = $user['fsize'];
}
//END AUTH

$key = 'public';

if(!isset($_REQUEST['key']))
{
if(preg_match("/[^0-9a-zA-Z_]+/", $_REQUEST['key']))

	{
      header ("Location: /key/wml/invalid");
	  exit;
	}
    else
	{
	  $key = mysql_escape_string(htmlspecialchars($_REQUEST['key']));
	}
}



if($level < 1 && $type != 0)
{
echo $css;
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">Ошибка</div>';
echo "Доступ запрещен.<br/>\n";
echo'<div class="d3">';
echo $sitefoot;
echo'</div>';
echo "</body></html>";
exit();
}

if($kick > time())
{
echo $css;
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">Ошибка</div>';
echo'<div class="d5">';
echo "Вы забаненны модератором <u>$moder</u> на <u>".($kick - time())."</u> сек.<br/>\n";
echo "Причина: $reason</div>\n";
echo'<div class="d3">';
echo $sitefoot;
echo'</div>';
echo "</body></html>";
exit();
}

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

$sql = mysql_query("SELECT `nickname` FROM `chat_users` WHERE `key` = '".$key."' AND `intim` >= ".time());

if($fsize == 0)
{
$fsize = "small";
}
if($fsize == 1)
{
$fsize = "normal";
}
if($fsize == 2)
{
$fsize = "large";
}

echo $css;
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">'.$ttl.'</div>';

$c = 0;
if(isset($_POST['msg']))
{
mysql_query("SELECT * FROM `chat` WHERE `aid` = ".$id." AND `seconds` > ".(time() - 20));
if(mysql_affected_rows() > 3)
{
$reason = "Вы были автоматически забанены системой за флуд (многократное повторение сообщений).";
mysql_query("UPDATE `chat_users` SET `kick` = ".(time() + 180).", `moder` = '".$bots[3]."', `reason` = '".$reason."';");
}

$msg = trim($_POST['msg']);

if(isset($_POST['uid']))
{
$sql = mysql_query("SELECT `nickname` FROM `chat_users` WHERE `id` = ".intval($_POST['uid']));
$nick = mysql_result($sql, 0);
}
else
{
$nick = "";
}

$msg = addslashes($msg);

	if($_POST['translit'] == "true")
	{
	$msg = str_replace("\"\"", "Ъ", $msg);
	$msg = str_replace("\"", "ъ", $msg);
	$msg = str_replace("''", "Ь", $msg);
	$msg = str_replace("'", "ь", $msg);

	$lat = array("CH", "ch", "SC", "sc", "YE", "ye", "YU", "yu", "YA", "ya", "YO", "yo");
	$rus = array("Ч", "ч", "Щ", "щ", "Э", "э", "Ю", "ю", "Я", "я", "Ё", "ё");
	$msg = str_replace($lat, $rus, $msg);

	$lat = array("A", "a", "B", "b", "C", "c", "D", "d", "E", "e", "F", "f", "G", "g", "H", "h", "I", "i", "J", "j", "K", "k", "L", "l", "M", "m", "N", "n", "O", "o", "P", "p", "R", "r", "S", "s", "T", "t", "U", "u", "V", "v", "H", "h", "Z", "z", "W", "w", "X", "x", "Y", "y");
	$rus = array("А", "а", "Б", "б", "Ц", "ц", "Д", "д", "Е", "е", "Ф", "ф", "Г", "г", "Х", "х", "И", "и", "Ж", "ж", "К", "к", "Л", "л", "М", "м", "Н", "н", "О", "о", "П", "п", "Р", "р", "С", "с", "Т", "т", "У", "у", "В", "в", "Х", "х", "З", "з", "Ш", "ш", "Ы", "ы", "Й", "й");
	$msg = str_replace($lat, $rus, $msg);
	}

$msg = htmlspecialchars($msg);
$msg = iconv_substr($msg, 0, 1024, 'utf-8');
$msg = str_replace('$', '$$', $msg);

$msg = eregi_replace("((http://))((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z;]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:;\?\.-]*)*)", "<a href=\"\\0\">\\3</a>", $msg);

if($level == 4)
{
$msg = preg_replace("|\*\((.*)\)\*|isU", '<b>$1</b>', $msg);
}

$sql = mysql_query("SELECT `msg` FROM `chat_intim` WHERE `key` = '".$key."' AND `aid` = ".$id." ORDER BY `id` DESC LIMIT 1;");
$last_msg = mysql_escape_string(mysql_result($sql, 0));

	if($last_msg != $msg && !empty($msg))
	{
	if(isset($_POST[tto]))
{
$to = $_POST['to'];
}
else
{
$to = 0;
}
	$sql = mysql_query("INSERT INTO `chat_intim` VALUES(0, '".$id."', '".$nickname."', '".$msg."', '".$key."', '".$to."', '".date("H:i")."',".time().",".intval($_POST['uid']).");");
		/*if(mysql_insert_id() > 4000000000)
		{
		mysql_query("TRUNCATE TABLE `chat`;");
		$message = "Комнаты интима были очищены системой. Данная операция была важна для снятия нагрузки с базы данных.";
		$sql = mysql_query("SELECT `id` FROM `chat_intim`;");
			while($room_id = mysql_fetch_array($sql))
			{
			mysql_query("INSERT INTO `chat` VALUES(0, '5', '".$bots[3]."', '".$message."', '".$key."', '0', '".date("H:i")."',".time().",".intval($_POST['uid']).");");
			}
		}
		if(!$sql)
		{
		$sql = mysql_query("INSERT INTO `chat` VALUES(0, '".$id."', '".$nickname."', '".$msg."', '".$rid."', '".$to."', '".date("H:i")."', ".time().",".intval($_POST['uid']).");");
		}
		*/
	mysql_query("UPDATE `chat_users` SET `posts` = `posts` + 1 WHERE `id` = ".$id);
	}
}
$sql = mysql_query("SELECT COUNT(*) FROM `chat_intim` WHERE `key` = '".$key."';");
$all = mysql_result($sql, 0);

$s = intval($_GET['s']);

if($s < 0) $s = 0;
if($s > $all) $s = 0;

$sql = mysql_query("SELECT * FROM `chat_intim` WHERE `key` = '".$key."' ORDER BY `id` DESC LIMIT $s, $msgs;");

$c = 0;

while($post = mysql_fetch_assoc($sql))
{
if($c == 0)
{
$div = "<div class=\"form\">\n";
$close = "</div>\n";
$c = 1;
}
else
{
$div = "";
$close = "";
$c = 0;
}
/////NICKNAMECOLOR
$q = mysql_query("SELECT * FROM `chat_users` WHERE `id` = ".$post['aid']);
$lvv = mysql_fetch_assoc($q);
/////////////////////////Nickcolor
if($lvv['colornick'])
{
$lvv['nickname']="<font color=\"#".$lvv['colornick']."\">".$lvv['nickname']."</font>";
}

//SMILES
include "includes/smiles_array/all.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
include "includes/smiles_array/bystrye.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
if($lvv['posts'] > 0)
{
include "includes/smiles_array/polzovatel.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
if($lvv['level'] > 3 or $lvv['posts'] >= 3000)
{
include "includes/smiles_array/chatter.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
if($lvv['level'] > 3 or $lvv['posts'] >= 8000)
{
include "includes/smiles_array/smiles_person.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
if($lvv['level'] != 0)
{
include "includes/smiles_array/moder.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
if($lvv['level'] > 3)
{
include "includes/smiles_array/admin.php";
$post['msg'] = preg_replace($smiles_array, $smile, $post['msg'], 2);
}
//




 if($lvv['id'] == 15)
 {
 $lvv['nickname']=$lvv['nickname'];
 }


 if($lvv['nickname'] == $nickname)
 {
 $post['tonick']=$post['tonick'];
 }



  if($lvv['level'] != 9)
  {
  include "includes/text_array/moder_tegi.php";
  $post['msg'] = preg_replace($search, $replace, $post['msg']);
  }


echo "<u>[".$post['time']."]</u> <a href=\"/infoi/html/$key/$nocache/".$post['aid']."\">".$lvv['nickname']."</a> ";


$post['msg'] = str_replace('$$', '$', $post['msg']);
$post['msg'] = stripslashes($post['msg']);
if($smiles == 0) $post['msg'] = preg_replace("|<img[^>]+>|isU", "*smile*", $post['msg']);
$post['msg'] = str_replace("<usersid>", SID, $post['msg']);
//Tonickname
$qm = mysql_query("SELECT `nickname` FROM `chat_users` WHERE `id` ='".$post[tonick]."';");
$tonick = mysql_result($qm, 0);
if($nickname == $tonick)
{
$tonick = "<b>$tonick</b>";
}
if($post[tonick] != 0)
{
echo $tonick.", \n";
}
if($post['to'] != 0)
{
echo "<b>[P!]\n</b>";
}
echo $post['msg']."<br/>\n";
}
echo'<div class="d1">';

echo "• <a href=\"/intim/html/".$key."\">В чат</a><br/>\n";
echo "• <a href=\"/online/html\">Кто где</a><br/>\n";
echo "• <a href=\"/menu/html/$nocache\">В прихожую</a><br/>\n";
echo'</div>';
echo'<div class="d3">';
echo $sitefoot;
echo'</div>';
echo "</body></html>";
break;
}
?>