<?php
#==============================================================================================#
#                                   Name  :  Imperial CHAT                                     #
#                               Made by  :  MaZaFaKa (___хакер___)                             #
#                                  MODED :  vipsds  (   BOT  )                                 #
#                                  ICQ  :  350502220 (vipsds)                                  #
#                                E-mai :  vipsds@wapnn.org                                     #
# По всем вопросам и дополнительным модам обращайтесь на выше указанные данные                 #
#==============================================================================================#
//ERROR REPORTING LEVEL
error_reporting(0);
include('start.php');
//CONNECTION (MySQL)
include('config.php');
//IS USER BANNED?
include('./includes/'.$ver.'/banned');

//GET BOTS NAMES
$bots = file("bots/bots.dat");
$bots[0] = trim($bots[0]);
$bots[1] = trim($bots[1]);
$bots[2] = trim($bots[2]);
$bots[3] = trim($bots[3]); //SYSTEM

//CONFIGS
$configs = file('system/configs.dat');
$adv = $configs[1];
$computer = $configs[2];

//INTERVALS
$intervals = file('bots/intervals.dat');
$intervals[0] = intval($intervals[0]);
$intervals[1] = intval($intervals[1]);
$intervals[2] = intval($intervals[2]);

//VARIABLE FOR NO-CACHE PROTECTION
$nocache = rand(0, 999999999);

list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;

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

$rid = htmlspecialchars(mysql_escape_string(trim(intval($_GET['rid']))));
//$nocache = htmlspecialchars(mysql_escape_string(trim(intval($_GET['nocache']))));
$options = htmlspecialchars(mysql_escape_string(trim(intval($_POST['options']))));
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 * FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");

if(mysql_affected_rows() == 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();
}
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;
$emotions = $user['emotions'];
$bystrsmile = $user['bystrsmile'];
$buttons = $user['sftky'];
$ip = $user['ip'];
$ua = $user['ua'];
$security = $user['security'];
}
//END AUTH

if(((strpos($ua, "Opera") !== false) or (strpos($ua, "Mozilla") !== false) or (strpos($ua, "MSIE") !== false)  or (strpos($ua, "Netscape") !== false)) && $computer == 1 && $level == 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=\"/menu/wml\"><timer value=\"10\"/><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();
}



$sql = mysql_query("SELECT `topic`, `type` FROM `chat_rooms` WHERE `id` = '".$rid."';");

if(mysql_num_rows($sql) == 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=\"Ошибка\" ontimer=\"/menu/wml\"><timer value=\"10\"/><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();
}
else
{
$topic = mysql_result($sql, 0, 'topic');
$type = mysql_result($sql, 0, 'type');
}

if($level == 0 && $type == 1)
{
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=\"/menu/wml\"><timer value=\"10\"/><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();
}

if($kick > time() && (($rid != $wicked_quiz && $rid != $unlim) or $moder == $bots[3]))
{
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=\"/rules/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";
list($msec, $sec) = explode(chr(32), microtime());
echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo "</small></p></card></wml>";
exit();
}

//ONLINE
$online = time() + 90;
$update = mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = '".$rid."', `ip` = '".getenv('REMOTE_ADDR')."', `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."' WHERE `id` = '".$id."';");
//END ONLINE
if(strpos($buttons, "5") !== false) {
$sql = mysql_query("SELECT COUNT(*) FROM `chat_letters` WHERE `to` = '".$id."' AND `read` = 0 AND `id` = '".$id."';");
$inbox = mysql_result($sql, 0);
}

if($_GET['act']=='')
{
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=\"$topic\" ontimer=\"/room/wml/$rid/$nocache\">";
echo "<timer value=\"$refresh\"/>\n";
echo "<p align=\"left\">";
include "bots/joker.php";

$msg = htmlspecialchars(mysql_escape_string($msg));


if($rid == 1)
{
include "bots/bot.php";
mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 1 WHERE `id` = 3;");
}

if($rid == 3)
{
include "bots/boor.php";
include "bots/second_bot.php";
mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 3 WHERE `id` = 4;");
}

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;
if($security == 1 && ($ip != getenv('REMOTE_ADDR') OR $ua != htmlspecialchars(getenv('HTTP_USER_AGENT'))))
{
echo'Ваш текущий IP и телефон не совпадают с теми, что использовались в последний раз. Предыдущий IP: '.getenv('REMOTE_ADDR').', предыдущий телефон: '.getenv('HTTP_USER_AGENT').'.<br/>';
$online = time() + 60;
mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 0, `ip` = '".getenv('REMOTE_ADDR')."', `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."' WHERE `id` = '".$id."';");
}

echo "• <a href=\"/room/wml/$rid/add/$nocache\">Сказать</a><br/>\n";
echo "• <a href=\"/room/wml/$rid/$nocache\">Обновить</a><br/>\n";
if(isset($_POST['msg']))
{
mysql_query("SELECT * FROM `chat".$rid."` 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."' WHERE `id` = '".$id."';");
}

$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 = stripslashes($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 = iconv('utf-8', 'windows-1251', $msg);
$msg = substr($msg, 0, 1000);
$msg = iconv('windows-1251', 'utf-8', $msg);
$msg = str_replace("$", "$$", $msg);

$emotions = intval($_POST['emotions']);

switch($emotions)
{
case 1:
$msg = "[Радостно] $msg";
break;

case 2:
$msg = "[Печально] $msg";
break;

case 3:
$msg = "[Удивленно] $msg";
break;

case 4:
$msg = "[Ласково] $msg";
break;

case 5:
$msg = "[Смущенно] $msg";
break;

case 6:
$msg = "[Кокетливо] $msg";
break;

case 7:
$msg = "[Обиженно] $msg";
break;

case 8:
$msg = "[Настойчиво] $msg";
break;

case 9:
$msg = "[Шепотом] $msg";
break;

case 10:
$msg = "[Задумчиво] $msg";
break;

case 11:
$msg = "[Злобно] $msg";
break;
}

$bystrsmile = intval($_POST['bystrsmile']);

switch($bystrsmile)
{
case 1:
$msg = "$msg .улыбка.";
break;

case 2:
$msg = "$msg .кащей.";
break;

case 3:
$msg = "$msg .фшоке.";
break;

case 4:
$msg = "$msg .влюблен.";
break;

case 5:
$msg = "$msg .злой.";
break;

case 6:
$msg = "$msg .еда.";
break;
}

if($level > 0)
	{
	$attributs = $_POST['attributs'];
	$post_fsize = (int)$_POST['fsize'];

	if(substr_count($attributs, "underline") != 0) $msg = "<u>$msg</u>";

		if($level > 2)
		{
		if(substr_count($attributs, "bold") != 0) $msg = "<b>$msg</b>";
		}

		if($level > 3)
		{
		if(substr_count($attributs, "italic") != 0) $msg = "<i>$msg</i>";
		if($post_fsize == 0) $msg = "<small>$msg</small>";
		if($post_fsize == 2) $msg = "<big>$msg</big>";
		}
	}

//ubiranie reklamy
if($adv == 1 && $level < 4)
{
$msg = eregi_replace("((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z;]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:;\?\.-]*)*)", "OSWAP THE BEST", $msg);
$msg = str_replace("com","", $msg);
$msg = str_replace("ru","", $msg);
$msg = str_replace("su","", $msg);
$msg = str_replace("net","", $msg);
$msg = str_replace("kz","", $msg);
$msg = str_replace("cn","", $msg);
$msg = str_replace("mobi","", $msg);
$msg = str_replace("info","", $msg);
$msg = str_replace("ua","", $msg);
$msg = str_replace("wen","", $msg);
$msg = str_replace("kmx","", $msg);
$msg = str_replace("ayola","", $msg);
$msg = str_replace("ucoz","", $msg);
$msg = str_replace("chat","", $msg);
$msg = str_replace("wap","", $msg);
$msg = str_replace("www","", $msg);
$msg = str_replace("http://","", $msg);
$msg = str_replace("COM","", $msg);
$msg = str_replace("RU","", $msg);
$msg = str_replace("SU","", $msg);
$msg = str_replace("NET","", $msg);
$msg = str_replace("KZ","", $msg);
$msg = str_replace("CN","", $msg);
$msg = str_replace("MOBI","", $msg);
$msg = str_replace("INFO","", $msg);
$msg = str_replace("UA","", $msg);
$msg = str_replace("WEN","", $msg);
$msg = str_replace("KMX","", $msg);
$msg = str_replace("AYOLA","", $msg);
$msg = str_replace("UCOZ","", $msg);
$msg = str_replace("CHAT","", $msg);
$msg = str_replace("WAP","", $msg);
$msg = str_replace("WWW","", $msg);
$msg = str_replace("HTTP://","", $msg);
}



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

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

$sql = mysql_query("SELECT COUNT(*) FROM `chat".$rid."`;");
$all = mysql_result($sql, 0);

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

$ignor = "";


$sql = mysql_query("SELECT * FROM `chat_ignor` WHERE `id` = '".$id."';");
while($ignor_arr = mysql_fetch_array($sql))
{
$ignor .= " `aid` != '".$ignor_arr['uid']."' AND ";
}

print "<fieldset>";

//////////////////////////////////////////////// новое письмо
$query = mysql_query("SELECT COUNT(*) FROM `chat_letters` WHERE `id` = '".$id."' AND `to` = '".$id."' AND `read` = 0;");
$newto = mysql_result($query, 0);

if($newto != 0)
echo "<a href=\"/letters/wml/inbox\">Вам письмо ($newto)</a><br/>\n";
////////////////////////////////////////////////





  //////////////////////////////////////////////////////////////////////////////////////// функция [x]
   $qd = mysql_query("SELECT * FROM `chat_users` WHERE `id` = '".$_SESSION['id']."';");
   $lvvv = mysql_fetch_array($qd);

     if ($lvvv['level'] >= 3)
     {
        if ($_GET['z']== "del")
        {
        if(@mysql_query("delete from `chat".$rid."` where `id`='".mysql_escape_string($_GET['msg'])."' ")) print "Удаленно...<br/>";
        else print "Не удаленно...";
        }
     }

   //////////////////////////////////////////////////////////////////////////////////////////
if($id != 1  AND $id != 6) $sql = mysql_query("SELECT * FROM `chat".$rid."` WHERE ".$ignor." (`to` = 0 OR `to` = '".$id."' OR `aid` = '".$id."') ORDER BY `id` DESC LIMIT $s, $msgs;");
else $sql = mysql_query("SELECT * FROM `chat".$rid."` WHERE ".$ignor." `aid` != 0 ORDER BY `id` DESC LIMIT $s, $msgs;");
while($post = mysql_fetch_array($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']);
}


if ($lvvv['level'] >= 3)
{
echo "[<a href=\"/room/wml/$rid/del/".$post['id']."/$nocache\">x</a>]";
}
   $txt = mysql_query("SELECT `type` FROM `chat_rooms` WHERE `id` = '".$rid."';");
 $type = mysql_result($txt, 0, 'type');
 if($type == 5)
{
	echo "<u>[".$post['time']."]</u> <b>[ИНКОГНИТО]</b> >\n";
	}
else {
    echo "<u>[".$post['time']."]</u> <a href=\"/info/wml/$rid/$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";
}
 print "</fieldset>";

echo "• <a href=\"/history/wml/$rid/$nocache\">История</a><br/>\n";
echo "• <a href=\"/online/wml\">Кто где?</a><br/>\n";
echo '• <a href="/menu/wml/'.$nocache.'">Прихожая</a><br/>';
include('banners/room');

}
echo $close_tag;


if($_GET['act']=='add')
{

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=\"Сказать\">";
echo "<p>";



print "<fieldset>";
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";
}

if($level > 0)
{
echo "Аттрибуты:<br/>\n";
echo "<select name=\"attributs$nocache\" multiple=\"true\">\n";
if($level > 2) echo "<option value=\"bold\">Жирный</option>\n";
echo "<option value=\"underline\">Подчеркнутый</option>\n";
if($level == 4)echo "<option value=\"italic\">Курсив</option>\n";
echo "</select><br/>\n";
}

if($level >= 4)
{
echo "Размер:<br/>\n";
echo "<select name=\"fsize$nocache\" value=\"1\">\n";
echo "<option value=\"0\">Маленький</option>\n";
echo "<option value=\"1\">Нормальный</option>\n";
echo "<option value=\"2\">Большой</option>\n";
echo "</select><br/>\n";
}

if($emotions == 1)
{
echo "Эмоции:<br/>\n";
echo "<select name=\"emotions$nocache\" value=\"0\">\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";
echo "<option value=\"11\">Злобно</option>\n";
echo "</select><br/>\n";
}
if($bystrsmile == 1)
{
echo "Смайл:<br/>\n";
echo "<select name=\"bystrsmile\">\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 "</select><br/>\n";
}
echo "<anchor>Сказать<go href=\"/room/wml/$rid/$nocache\" method=\"post\">\n";
echo "<postfield name=\"msg\" value=\"$(msg$nocache)\"/>\n";
if($translit == 1)
{
echo "<postfield name=\"translit\" value=\"$(translit$nocache)\"/>\n";
}
if($level > 0)
{
echo "<postfield name=\"attributs\" value=\"$(attributs$nocache)\"/>\n";
}
if($level >= 4)
{
echo "<postfield name=\"fsize\" value=\"$(fsize$nocache)\"/>\n";
}
if($emotions == 1)
{
echo "<postfield name=\"emotions\" value=\"$(emotions$nocache)\"/>\n";
}
if($bystrsmile == 1)
{
echo "<postfield name=\"bystrsmile\" value=\"$(bystrsmile)\"/>\n";
}
echo "</go></anchor><br/>\n";
print "</fieldset>";
echo "• <a href=\"/room/wml/$rid/$nocache\">В чат</a><br/>\n";
list($msec, $sec) = explode(chr(32), microtime());
echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<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 * 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">';
include('banners/room');
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo'</div>';
echo "</body></html>";
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'];
$ip = $user['ip'];
$ua = $user['ua'];
$security = $user['security'];
$level = $user['level'];
$kick = $user['kick'];
$moder = $user['moder'];
$reason = $user['reason'];
}
//END AUTH

if(((strpos($ua, "Opera") !== false) or (strpos($ua, "Mozilla") !== false) or (strpos($ua, "MSIE") !== false)  or (strpos($ua, "Netscape") !== false)) && $computer == 1 && $level == 0)
{
echo "$css";
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">Ошибка</div>';
echo "<div class=\"d5\">Доступ с компьютера запрещен.</div>\n";
echo'<div class="d3">';
include('banners/room');
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo'</div>';
echo "</body></html>";
exit();
}

$rid = htmlspecialchars(mysql_escape_string(trim(intval($_GET['rid']))));

$sql = mysql_query("SELECT `topic`, `type` FROM `chat_rooms` WHERE `id` = '".$rid."';");

if(mysql_num_rows($sql) == 0)
{
echo "$css";
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">Ошибка</div>';
echo "<div class=\"d5\">Такой комнаты не существует.</div>\n";
echo'<div class="d3">';
include('banners/room');
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo'</div>';
echo "</body></html>";
exit();
}
else
{
$topic = mysql_result($sql, 0, 'topic');
$type = mysql_result($sql, 0, 'type');
}

if($level == 0 && $type == 1)
{
echo "$css";
echo'<title>'.$ttl.'</title>';
echo'<div class="d3">Ошибка</div>';
echo "<div class=\"d5\">Доступ запрещен.</div>\n";
echo'<div class="d3">';
include('banners/room');
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($kick > time() && ($rid != $wicked_quiz && $rid != $unlim))
{
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">';
include('banners/room');
echo"$sitefoot";
list($msec, $sec) = explode(chr(32), microtime());
echo "[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo'</div>';
echo "</body></html>";
exit();
}

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

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


echo "$css";
echo'<title>'.$topic.'</title>';
echo'<div class="d3">'.$topic.'</div>';
echo "<meta http-equiv=\"refresh\" content=\"$refresh;url=/room/html/$rid/$nocache\"/>\n";
if($security == 1 && ($ip != getenv('REMOTE_ADDR') OR $ua != htmlspecialchars(getenv('HTTP_USER_AGENT'))))
{
echo'</div>';
echo'<div class="d2">';
echo'Ваш текущий IP и телефон не совпадают с теми, что использовались в последний раз. Предыдущий IP: '.getenv('REMOTE_ADDR').', предыдущий телефон: '.getenv('HTTP_USER_AGENT').'.';
echo'</div>';
$online = time() + 60;
mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 0, `ip` = '".getenv('REMOTE_ADDR')."', `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."' WHERE `id` = '".$id."';");
}
include "bots/joker.php";

if($rid == 1)
{
include "bots/bot.php";
mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 1 WHERE `id` = 2;");
}

if($rid == 3)
{
include "bots/boor.php";
include "bots/second_bot.php";
mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 3 WHERE `id` = 4;");
}
echo'<div class="d1">';
echo "• <a href=\"/add/html/$rid/$nocache\">Сказать</a><br/>\n";
echo "• <a href=\"/room/html/$rid/$nocache\">Обновить</a><br/>\n";
echo'</div>';
if(isset($_POST['msg']))
{
mysql_query("SELECT * FROM `chat".$rid."` 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."' WHERE `id` = '".$id."';");
}

$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 = htmlspecialchars(mysql_escape_string($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 = iconv('utf-8', 'windows-1251', $msg);
$msg = substr($msg, 0, 1000);
$msg = iconv('windows-1251', 'utf-8', $msg);
$msg = str_replace("$", "$$", $msg);

$emotions = intval($_POST['emotions']);

switch($emotions)
{
case 1:
$msg = "[Радостно] $msg";
break;

case 2:
$msg = "[Печально] $msg";
break;

case 3:
$msg = "[Удивленно] $msg";
break;

case 4:
$msg = "[Ласково] $msg";
break;

case 5:
$msg = "[Смущенно] $msg";
break;

case 6:
$msg = "[Кокетливо] $msg";
break;

case 7:
$msg = "[Обиженно] $msg";
break;

case 8:
$msg = "[Настойчиво] $msg";
break;

case 9:
$msg = "[Шепотом] $msg";
break;

case 10:
$msg = "[Задумчиво] $msg";
break;

case 11:
$msg = "[Злобно] $msg";
break;
}

$bystrsmile = intval($_POST['bystrsmile']);

switch($bystrsmile)
{
case 1:
$msg = "$msg .улыбка.";
break;

case 2:
$msg = "$msg .кащей.";
break;

case 3:
$msg = "$msg .фшоке.";
break;

case 4:
$msg = "$msg .влюблен.";
break;

case 5:
$msg = "$msg .злой.";
break;

case 6:
$msg = "$msg .еда.";
break;
}

if($level > 0)
	{
	$attributs = $_POST['attributs'];
	$post_fsize = (int)$_POST['fsize'];

	if(substr_count($attributs, "underline") != 0) $msg = "<u>$msg</u>";

		if($level > 2)
		{
		if(substr_count($attributs, "bold") != 0) $msg = "<b>$msg</b>";
		}

		if($level > 3)
		{
		if(substr_count($attributs, "italic") != 0) $msg = "<i>$msg</i>";
		if($post_fsize == 0) $msg = "<small>$msg</small>";
		if($post_fsize == 2) $msg = "<big>$msg</big>";
		}
	}
	////////////////////////
	if($options == 1)
	{
	$msg = "<font color=red>$msg</font>";
    }
	if($options == 2)
	{
	$msg = "<font color=blue>$msg</font>";
    }
	if($options == 3)
	{
	$msg = "<font color=#008000>$msg</font>";
    }
	if($options == 4)
	{
	$msg = "<font color=gray>$msg</font>";
    }
	if($options == 5)
	{
	$msg = "<font color=#FFA500>$msg</font>";
    }
	if($options == 6)
	{
	$msg = "<font color=#0066FF>$msg</font>";
    }
	if($options == 7)
	{
	$msg = "<font color=#228B22>$msg</font>";
    }
	if($options == 8)
	{
	$msg = "<font color=#D02090>$msg</font>";
    }
	if($options == 9)
	{
	$msg = "<font color=#B03060>$msg</font>";
    }
	if($options == 10)
	{
	$msg = "<font color=#8A2BE2>$msg</font>";
    }

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

if($adv == 1 && $level < 4)
{
$msg = eregi_replace("((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z;]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:;\?\.-]*)*)", "OSWAP THE BEST", $msg);
$msg = str_replace("com","", $msg);
$msg = str_replace("ru","", $msg);
$msg = str_replace("su","", $msg);
$msg = str_replace("net","", $msg);
$msg = str_replace("kz","", $msg);
$msg = str_replace("cn","", $msg);
$msg = str_replace("mobi","", $msg);
$msg = str_replace("info","", $msg);
$msg = str_replace("ua","", $msg);
$msg = str_replace("wen","", $msg);
$msg = str_replace("kmx","", $msg);
$msg = str_replace("ayola","", $msg);
$msg = str_replace("ucoz","", $msg);
$msg = str_replace("chat","", $msg);
$msg = str_replace("wap","", $msg);
$msg = str_replace("www","", $msg);
$msg = str_replace("http://","", $msg);
$msg = str_replace("COM","", $msg);
$msg = str_replace("RU","", $msg);
$msg = str_replace("SU","", $msg);
$msg = str_replace("NET","", $msg);
$msg = str_replace("KZ","", $msg);
$msg = str_replace("CN","", $msg);
$msg = str_replace("MOBI","", $msg);
$msg = str_replace("INFO","", $msg);
$msg = str_replace("UA","", $msg);
$msg = str_replace("WEN","", $msg);
$msg = str_replace("KMX","", $msg);
$msg = str_replace("AYOLA","", $msg);
$msg = str_replace("UCOZ","", $msg);
$msg = str_replace("CHAT","", $msg);
$msg = str_replace("WAP","", $msg);
$msg = str_replace("WWW","", $msg);
$msg = str_replace("HTTP://","", $msg);
}

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

$msg = mysql_escape_string($msg);

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

$sql = mysql_query("SELECT COUNT(*) FROM `chat".$rid."`;");
$all = mysql_result($sql, 0);

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

$ignor = "";

$sql = mysql_query("SELECT * FROM `chat_ignor` WHERE `id` = '".$id."';");
while($ignor_arr = mysql_fetch_array($sql))
{
$ignor .= " `aid` != '".$ignor_arr['uid']."' AND ";
}


//////////////////////////////////////////////// новое письмо
$query = mysql_query("SELECT COUNT(*) FROM `chat_letters` WHERE `id` = '".$id."' AND `to` = '".$id."' AND `read` = 0;");
$newto = mysql_result($query, 0);

if($newto != 0)
echo "<a href=\"/letters/html/inbox\">Вам письмо ($newto)</a><br/>\n";
////////////////////////////////////////////////



  //////////////////////////////////////////////////////////////////////////////////////// функция [x]
   $qd = mysql_query("SELECT * FROM `chat_users` WHERE `id` = '".$_SESSION['id']."';");
   $lvvv = mysql_fetch_array($qd);

     if ($lvvv['level'] >= 3)
     {
        if ($_GET['z']== "del")
        {
        if(@mysql_query("delete from `chat".$rid."` where `id`='".mysql_escape_string($_GET['msg'])."' ")) print "Удаленно...<br/>";
        else print "Не удаленно...";
        }
     }

   //////////////////////////////////////////////////////////////////////////////////////////
if($id != 1 AND $id != 6) $sql = mysql_query("SELECT * FROM `chat".$rid."` WHERE ".$ignor." (`to` = 0 OR `to` = '".$id."' OR `aid` = '".$id."') ORDER BY `id` DESC LIMIT $s, $msgs;");
else $sql = mysql_query("SELECT * FROM `chat".$rid."` WHERE ".$ignor." `aid` != 0 ORDER BY `id` DESC LIMIT $s, $msgs;");

$c = 0;

while($post = mysql_fetch_array($sql))
{
if($c == 0)
{
$div = "";
$close = "";
$c = 1;
}
else
{
$div = "";
$close = "";
$c = 0;
}


/////NICKNAMECOLOR
$q = mysql_query("SELECT * FROM `chat_users` WHERE `id` = '".$post['aid']."';");
$lvv = mysql_fetch_array($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']);
  }

 $txt = mysql_query("SELECT `type` FROM `chat_rooms` WHERE `id` = '".$rid."';");
 $type = mysql_result($txt, 0, 'type');
  if ($lvvv['level'] >= 3)
  {
  echo "[<a href=\"/room/html/$rid/del/".$post['id']."/$nocache\">x</a>]";
  }
     if($type == 5)
  {
  echo "<u>[".$post['time']."]</u> <b>[ИНКОГНИТО]</b> </a> ";
  } else {

echo "<u>[".$post['time']."]</u> <a href=\"/info/html/$rid/$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=\"/history/html/$rid/$nocache\">История</a><br/>\n";
echo "• <a href=\"/online/html\">Кто где?</a><br/>\n";
echo '• <a href="/menu/html/'.$nocache.'">Прихажая</a><br/>';
include('banners/room');
echo '</div>';
echo'<div class="d3">';
list($msec, $sec) = explode(chr(32), microtime());
echo "Speed ".round(($sec+$msec)-$headtime,5)." sec<br/>\n";
echo'</div>';
echo "</body></html>";
break;
}
?>