<?

header("Cache-Control: no-cache");
if ($ver=="wml")header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else header("Content-Type:text/html; charset=UTF-8");

require("inc.php");
$link = connect_db();
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);
require("version.php");

$us=$row["user"];  

if($row["inv"]!=2){
if(!@$go){
$times = getmicrotime();
mysql_query ("Update users set onl='".$times."', room='letters' where id ='".$id."'");
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"send\" title=\"Написать\">\n";
echo "<p align=\"center\">";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Написать</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
if ((isset($rm))&&($rm!="")) echo "<form method=\"POST\" action=\"send.php?go=pn&amp;$ses&amp;rm=$rm\" name=\"auth\">\n";
else echo "<form method=\"POST\" action=\"send.php?go=pn&amp;$ses\" name=\"auth\">\n";
}
$message = $topic = $towhom = "";
if (isset($im)){
settype($im, 'integer');
$r = mysql_query ("SELECT towhom,topic,message FROM zapiski WHERE klu4 = '".$im."'");
$a = mysql_fetch_array($r);
$towhom = $a ["towhom"];
$topic = $a ["topic"];
$message = $a ["message"];
} else {
if (isset($who)){
$r = mysql_query ("SELECT who,idwho FROM zapiski WHERE klu4 = '".$who."'");
$a = mysql_fetch_array($r);
$idwho = $a ["idwho"];
$info= mysql_fetch_array(mysql_query ("Select user from users where id = '".$idwho."'")); 
$towhom = $info["user"];
}
}
if (isset($tofr))$towhom = $tofr;
if($message!=""){
if(strstr($message,"<img src=\""))
{
$tend = strpos($message,"\"/>");  
$t=strlen($message);
$msgend=substr($message,$tend+3,$t);
$msgtemp=substr($message,0,$tend);
$t1=strpos($msgtemp,"<img src=\"");
$msgfirst=substr($msgtemp,0,$t1);
$t2=strlen($msgtemp);
$t3=strpos($msgtemp,"alt=\"");
$msgaver=substr($msgtemp,$t3+5,$t2);
$message=$msgfirst.$msgaver.$msgend;
}
if(strstr($message,"<a href=\""))
{
$tend = strpos($message,"</a>");  
$t=strlen($message);
$msgend=substr($message,$tend+4,$t);
$tend2 = strpos($message,"\">");  
$msgtemp=substr($message,0,$tend2);
$t1=strpos($msgtemp,"<a href=\"");
$msgfirst=substr($msgtemp,0,$t1);
$t2=strlen($msgtemp);
$t3=strpos($msgtemp,"<a href=\"");
$msgaver=substr($msgtemp,$t3+9,$t2);
$message=$msgfirst.$msgaver.$msgend;
}
}
echo $fsize1;
echo "<i>Для отправки письма ВСЕМ друзьям в поле Ник введите знак *</i><br/>\n";
echo "Ник или ID юзера:<br/>\n";
echo $fsize2;
if ($ver=="wml"){
if (isset($who)) echo "<input name=\"towhom$ref\" maxlength=\"30\" value=\"$towhom\" title=\"komu\"/><br/>\n";
elseif (isset($tofr)) echo "<input name=\"towhom$ref\" maxlength=\"30\" value=\"$tofr\" title=\"komu\"/><br/>\n";
else echo "<input name=\"towhom$ref\" maxlength=\"30\" value=\"$to\" title=\"komu\"/><br/>\n";
echo $fsize1;
echo "Тема:<br/>\n";
echo $fsize2;
echo "<input name=\"topic$ref\" maxlength=\"30\" value=\"$topic\" title=\"topic\"/><br/>\n"; 
echo $fsize1;
echo "Письмо:<br/>\n";
echo $fsize2;
echo "<input name=\"message$ref\" maxlength=\"600\" value=\"$message\" title=\"message\"/><br/>\n";
echo $fsize1;
if ((isset($rm))&&($rm!=""))echo "<anchor title=\"go\">Отправить<go href=\"send.php?go=pn&amp;$ses&amp;rm=$rm\" method=\"post\">\n";
else echo "<anchor title=\"go\">Отправить<go href=\"send.php?go=pn&amp;$ses\" method=\"post\">\n";
echo "<postfield name=\"towhom\" value=\"$(towhom$ref)\"/>\n";  
echo "<postfield name=\"topic\" value=\"$(topic$ref)\"/>\n";  
echo "<postfield name=\"message\" value=\"$(message$ref)\"/>\n";
echo "</go></anchor>\n"; 
echo $fsize2;
echo "<br/>\n";
}else{
if (isset($who)) echo "<input name=\"towhom\" maxlength=\"30\" value=\"$towhom\" title=\"komu\"/><br/>\n";
elseif (isset($tofr)) echo "<input name=\"towhom\" maxlength=\"30\" value=\"$tofr\" title=\"komu\"/><br/>\n";
else echo "<input name=\"towhom\" maxlength=\"30\" value=\"$to\" title=\"komu\"/><br/>\n";
echo $fsize1;
echo "Тема:<br/>\n";
echo $fsize2;
echo "<input name=\"topic\" maxlength=\"30\" value=\"$topic\" title=\"topic\"/><br/>\n"; 
echo $fsize1;
echo "Письмо:<br/>\n";
echo $fsize2;
echo "<input name=\"message\" maxlength=\"600\" value=\"$message\" title=\"message\"/><br/>\n";
echo "<input type=\"submit\" value=\"Отправить\" name=\"enter\"></form>\n";
}
echo $fsize1;
echo $divide;
echo $fsize2;
echo $fsize1;
if ((isset($rm))&&($rm!="")) echo "<a href=\"chat.php?$ses&amp;rm=$rm\">&#8592; В чат</a><br/>\n"; 
echo "<a href=\"chatmail.php?$ses&amp;ref=$ref\">Ваша почта</a><br/>\n";    
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">Прихожая</a><br/>\n"; 
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>"; 
mysql_close ($link);
exit;
}
 
$message = check($message);
$topic = check($topic);
      
if ($towhom=="*"){
if ($row["translit"]==1) $topic = trun_to_rus($topic);          
      $fr = $row["friends"];
      $time = time();
      $data = date("H:i(d-M)"); 
      $msg = $message;

require("smile.php");
$minpos = 1200; $nm = 1200;
for ($j=0;$j<=count($smiles)-1;$j++){   
$tmpp = strpos($msg,$smiles[$j]);
if (($tmpp < $minpos)&&($tmpp !== false)){ 
$minpos = $tmpp; $nm = $j;};
                     };         
if ($minpos !=1200){
if ($row["translit"]!=1){
$st1 = substr($msg,0,$minpos+strlen($smiles[$nm]));
$st2 = substr($msg,$minpos+strlen($smiles[$nm]),strlen($msg)-strlen($st1));
$st1 = str_replace($smiles[$nm],$replaces[$nm],$st1);           
$msg = $st1.$st2;
} else {
$st1 = substr($msg,0,$minpos);
$st2 = substr($msg,$minpos, strlen($smiles[$nm]));
$st3 = substr($msg,$minpos+strlen($smiles[$nm]),strlen($msg)-strlen($st1)-strlen($st2));
$st1 = trun_to_rus($st1);
$st2 = $replaces[$nm];
$st3 = trun_to_rus($st3);
$msg = $st1.$st2.$st3;
}
} 
else if ($row["translit"]==1) $msg = trun_to_rus($msg);          
Unset($smiles);
unset($replaces);   

if($row["level"]>6)$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);
    
$message = $msg;  

$userm = mysql_query ("select count(klu4) as num from friends where id ='".$id."';");
$usm = mysql_fetch_array($userm);
$num = $usm["num"];
if(!isset($s))$s=0;
$mx=round(($num/10)+0.45);
if($s>$mx)$s=$mx;
if($s==0)$s=1;
$ot=(($s-1)*10)+1;
$do=$s*10;
if($do>$num)$do=$num;
$o=$ot-1;
$n=$ot;
if($do==0)$n=$o;
$r = mysql_query ("select usid from friends where id ='".$id."' order by klu4 desc limit $o,$do");
for ($i=$ot;$i<=$do;$i++){
$arr = mysql_fetch_array($r);
$idtowhom=$arr['usid'];
$ignornick = @mysql_fetch_array(@mysql_query ("Select user from users where id='".$idtowhom."' LIMIT 1;"));
$kol = rand(0,99999999);
mysql_query("Insert into zapiski set klu4='".$kol."', who ='".$us."', idwho ='".$id."', message = '".$message."', towhom = '".$ignornick[0]."', idtowhom = '".$idtowhom."', time = '".$time."', readd = '0', topic = '".$topic."', date='".$data."'");
mysql_query ("Update users set onl='".$time."', room='letters' where id ='".$id."'");
if (mysql_error() != false)continue;
$alls=$alls."$ignornick[0], ";
}          
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
if ((isset($rm))&&($rm!="")) echo "<card id=\"done\" title=\"Письмо отправлено\" ontimer=\"chat.php?$ses&amp;rm=$rm\"><timer value=\"15\"/>\n";
else echo "<card id=\"done\" title=\"Письмо отправлено\" ontimer=\"chatmail.php?$ses\"><timer value=\"15\"/>\n";
echo "<p align =\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Письмо отправлено</title>";
if ((isset($rm))&&($rm!="")) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chat.php?$ses&amp;rm=$rm\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chatmail.php?$ses&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "Ваше письмо успешно отправлено следующим пользователям: $alls";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>"; 
mysql_close ($link);
}else{
if (!ctype_digit($towhom)) {	        
$towhom=trim($towhom);
if($towhom=="")$towhom=0;
$latuser=strtolower($towhom);
$ruser = rus_to_k($towhom);
if($ruser==$towhom){
$latuser = mysql_escape_string($latuser);
$r = mysql_query ("Select id,avtootvet,user,sex,room,onl from users where latuser = '".$latuser."'"); 
} else {
$ruser = mysql_escape_string($ruser);
$r = mysql_query ("select id,avtootvet,user,sex,room,onl from users where ruser = '".$ruser."'");
}
} else {
$towhom = mysql_escape_string($towhom);
$r = mysql_query ("select id,avtootvet,user,sex,room,onl from users where id = '".$towhom."'");
}
if (mysql_affected_rows() == 0) {
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
if ((isset($rm))&&($rm!="")) echo "<card id=\"error\" title=\"error\" ontimer=\"send.php?$ses&amp;ref=$ref&amp;rm=$rm\"><timer value=\"10\"/>\n";
else echo "<card id=\"error\" title=\"error\" ontimer=\"send.php?$ses&amp;ref=$ref\"><timer value=\"10\"/>\n";
echo "<p align=\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Ошибка</title>";
if ((isset($rm))&&($rm!="")) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=send.php?$ses&amp;rm=$rm&amp;ref=$ref\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=send.php?$ses&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "Ошибка ввода или пользователь не существует.";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>"; 
mysql_close ($link);
exit;
}
$a = mysql_fetch_array($r);
$login=$a["user"];
$sex=$a["sex"];
$usid=$a["id"];
@mysql_query ("Select * from ignor where usid='".$id."' and id='".$usid."'");
if (mysql_affected_rows() == true){
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
if ((isset($rm))&&($rm!="")) echo "<card id=\"error\" title=\"error\" ontimer=\"send.php?$ses&amp;rm=$rm&amp;ref=$ref\"><timer value=\"10\"/>\n";
else echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"send.php?$ses&amp;ref=$ref\"><timer value=\"10\"/>\n";
echo "<p align=\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Ошибка</title>";
if ((isset($rm))&&($rm!="")) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=send.php?$ses&amp;rm=$rm&amp;ref=$ref\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=send.php?$ses&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
if ($sex=="М") echo "<b>".$login."</b> отправил Вас в игнор.<br/>\n";
else  echo "<b>".$login."</b> отправила Вас в игнор.<br/>\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>"; 
mysql_close ($link);
exit;
}else{     
if ($row["translit"]==1) $topic = trun_to_rus($topic);
$time = time();
$data = date("H:i(d-M)"); 
$msg = $message;
if ($row["level"]<5) require("antirekl.php");
require("smile.php");
$minpos = 1200; $nm = 1200;
for ($j=0;$j<=count($smiles)-1;$j++){   
$tmpp = strpos($msg,$smiles[$j]);
if (($tmpp < $minpos)&&($tmpp !== false)){ 
$minpos = $tmpp; $nm = $j;};};         
if ($minpos !=1200){
if ($row["translit"]==0){
$st1 = substr($msg,0,$minpos+strlen($smiles[$nm]));
$st2 = substr($msg,$minpos+strlen($smiles[$nm]),strlen($msg)-strlen($st1));
$st1 = str_replace($smiles[$nm],$replaces[$nm],$st1);           
$msg = $st1.$st2;
} else {
$st1 = substr($msg,0,$minpos);
$st2 = substr($msg,$minpos, strlen($smiles[$nm]));
$st3 = substr($msg,$minpos+strlen($smiles[$nm]),strlen($msg)-strlen($st1)-strlen($st2));
$st1 = trun_to_rus($st1);
$st2 = $replaces[$nm];
$st3 = trun_to_rus($st3);
$msg = $st1.$st2.$st3;
}
} 
else if ($row["translit"]==1) $msg = trun_to_rus($msg);          
Unset($smiles);
unset($replaces);   

if ($row["translit"]==0) $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);   
      $message = $msg;     
      $idtowhom=$a["id"];
      $avtootvet=$a["avtootvet"];
	  $room=$a["room"];
	  $onl=$a["onl"];
	  $usid=$a["id"];
	  $kol = rand(0,99999999);
      $time = time();
      $data = date("d M Y [H:i]"); 
      $times = getmicrotime();

mysql_query("Select readd from zapiski WHERE (who='".$us."')and(idwho ='".$id."')and(message = '".$message."')and(towhom = '".$login."')and(idtowhom = '".$idtowhom."')and(topic = '".$topic."')");
if (mysql_affected_rows()===0){    
mysql_query("Insert into zapiski set klu4='".$kol."', who ='".$us."', idwho ='".$id."', message = '".$message."', towhom = '".$login."', idtowhom = '".$idtowhom."', time = '".$times."', readd = '0', topic = '".$topic."', date='".$data."'");
}

if (mysql_error() == false){
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
if ((isset($rm))&&($rm!="")) echo "<card id=\"done\" title=\"Отправлено\" ontimer=\"chat.php?$ses&amp;rm=$rm\"><timer value=\"60\"/>\n";
else echo "<card id=\"done\" title=\"Done!\" ontimer=\"chatmail.php?$ses\"><timer value=\"300\"/>\n";
echo "<p align =\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Отправлено</title>";
if ((isset($rm))&&($rm!="")) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"6; URL=chat.php?$ses&rm=$rm\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chatmail.php?$ses&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "Ваше сообщение для <b>".$login."</b> успешно отправлено!<br/>\n";
echo $fsize2;
if (($onl+300>time())&&($room!="")){
if ($room=="letters"){
echo $fsize1;
echo $divide;
echo "В данный момент я нахожусь в <a href=\"chatmail.php?$ses&amp;rm=$room&amp;ref=$ref\">записках</a><br/>\n";
echo $fsize2;
} else if ($room=="holl"){
echo $fsize1;
echo $divide;
echo "В данный момент я нахожусь в <a href=\"enter.php?$ses&amp;ref=$ref\">прихожей</a><br/>\n";
echo $fsize2;
}else{
$roomselect = @mysql_query ("Select name from rooms where rm=$room");
$rooms = @mysql_fetch_array($roomselect);
$roomname=$rooms["name"];
echo $fsize1;
echo $divide;
if($room=="maf") echo "В данный момент я нахожусь в игре: Мафия<br/>\n";
else echo "В данный момент я нахожусь в комнате: $roomname<br/>\n";
if($room==9)echo "<a href=\"anlim.php?$ses&amp;rm=$room&amp;ref=$ref\">Войти в комнату</a><br/>\n";
else if($room==11)echo "<a href=\"klaznet.php?$ses&amp;rm=$room&amp;ref=$ref\">Войти в комнату</a><br/>\n";
else echo "<a href=\"chat.php?$ses&amp;rm=$room&amp;ref=$ref\">Войти в комнату</a><br/>\n";
echo "или<br/>\n";
echo "<a href=\"inside.php?$ses&amp;rm=$room&amp;nk=$usid\">Написать мне в чате</a><br/>\n";
echo $fsize2;
}
}else{
if($avtootvet!=""){
echo $fsize1;
echo $divide;
echo "Автоответчик: $avtootvet<br/>\n";
echo $fsize2;
}
}
echo $fsize1;
echo $divide;
echo "<a href=\"chatmail.php?$ses&amp;ref=$ref\">Ваша почта</a><br/>\n";    
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">Прихожая</a><br/>\n"; 
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>"; 
}else{ 
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
if ((isset($rm))&&($rm!="")) echo "<card id=\"error\" title=\"error\" ontimer=\"send.php?$ses&rm=$rm&amp;ref=$ref\"><timer value=\"20\"/>\n";
else echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"send.php?$ses&amp;ref=$ref\"><timer value=\"20\"/>\n";
echo "<p align=\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Ошибка</title>";
if ((isset($rm))&&($rm!="")) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=send.php?$ses&rm=$rm\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=send.php?$ses&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "Ошибка при отправке письма! Попробуйте еще раз.<br/>\n";
echo $fsize2;
echo "ERROR ".mysql_error()." ";
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>"; 
}
mysql_close ($link);
}     
}
}else{
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"enter.php?$ses&amp;ref=$ref\"><timer value=\"50\"/>\n";
echo "<p align=\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Ошибка</title>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"5; URL=enter.php?$ses&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "Вы не можете писать письма так как находитесь в Полном Игноре.<br/>\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>"; 
mysql_close ($link);
}
?>