<?

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

switch($mod) {

default:
$us=$row["user"];
if(isset($go)){
@mysql_query ("Delete from ignor where usid ='".$nk."' and id = '".$id."'");
$ignornick = @mysql_fetch_array(@mysql_query ("Select user from users where id='".$nk."' LIMIT 1;"));
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=\"Ок\" title=\"Ok\" ontimer=\"ignor.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>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=ignor.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>".$ignornick[0]."</b> удален из вашего игнор-листа\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close($link);   
exit;
}  
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=\"ignolist\" title=\"Игнор-лист\">\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=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
$userm = mysql_query ("select count(klu4) as num from ignor where id ='".$id."';");
echo "<b>Ваш Игнор-Лист!</b><br/>";
echo $divide;
$usm = mysql_fetch_array($userm);
$num = $usm["num"]; 
if ($num == 0){
echo "Ваш игнор-лист пуст.<br/>";
}else{
echo "<i>Для удаления ника из игнора нажмите на [X]</i><br/>";
echo $divide; 
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;
echo "Показывает $n-$do из $num<br/>\n";
echo $divide;
$r = mysql_query ("select usid from ignor where id ='".$id."' order by klu4 desc limit $o,$do");
for ($i=$ot;$i<=$do;$i++){
$arr = mysql_fetch_array($r);
$nk=$arr['usid'];
$ignornick = @mysql_fetch_array(@mysql_query ("Select user from users where id='".$nk."' LIMIT 1;"));
echo ($i).") <a href=\"ignor.php?$ses&amp;go=del&amp;nk=$nk&amp;ref=$ref\">[Х]</a>|<a href=\"info.php?$ses&amp;nk=$nk&amp;ref=$ref\">".$ignornick[0]."</a><br/>"; 
}                                     
$next=$s+1;
$prev=$s-1;
if ($num>$do) {
$ot=(($next-1)*10)+1;
$do=$next*10;
if($do>$num)$do=$num;
echo $divide;
echo "<a href=\"ignor.php?$ses&amp;s=$next&amp;ref=$ref\">&gt;&gt;$ot-$do&gt;&gt;</a><br/>\n";
}
if($s>1) {
$ot=(($prev-1)*10)+1;
$do=$prev*10;
echo "<a href=\"ignor.php?$ses&amp;s=$prev&amp;ref=$ref\">&lt;&lt;$ot-$do&lt;&lt;</a><br/>\n";
}
}
echo $divide;
echo "<a href=\"ignor.php?$ses&amp;mod=addto&amp;nk=$nk&amp;ref=$ref\">Добавить в игнор</a><br/>\n";
echo $divide;
echo "<a href =\"cabinet.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;
break;


case 'addto':
if(!isset($nick)){
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=\"add\" title=\"Добавить в игнор\">\n";
echo "<p align=\"center\" mode=\"wrap\">\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=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
echo "<form method=\"POST\" action=\"ignor.php?mod=addto&amp;$ses$takep2\" name=\"auth\">\n";
}
echo $fsize1;
echo "Ник или ID юзера:<br/>\n";
echo $fsize2;
echo "<input name=\"nick\" maxlength=\"20\" title=\"Text\"/><br/>\n";
echo $fsize1;
echo "Транслитерация ника:<br/>\n";
echo $fsize2;
echo "<select name=\"trun\">\n";
echo "<option value=\"0\">Нет</option>\n";
echo "<option value=\"1\">Да</option>\n";
echo "</select><br/>\n";
if ($ver=="wml"){
echo $fsize1;
echo "<anchor title=\"send\">Добавить<go href=\"ignor.php?mod=addto&amp;$ses$takep2\" method=\"post\">\n";
echo "<postfield name=\"nick\" value=\"$(nick)\"/>\n";
echo "<postfield name=\"trun\" value=\"$(trun)\"/>\n";
echo "</go></anchor>\n";
echo $fsize2;
echo "<br/>\n";
}else{
echo "<input type=\"submit\" value=\"Добавить\" name=\"enter\"><br/>\n";
}
echo $fsize1;
echo $divide;
echo "<a href=\"ignor.php?$ses$takep2\">Игнор-лист</a><br/>\n";    
echo "<a href=\"chatmail.php?$ses$takep2\">Ваши письма</a><br/>\n";
if (isset($rm)) echo "<a href=\"chat.php?$ses&amp;rm=$rm$takep\">В чат</a>";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close($link);   
exit;
}    

if (!ctype_digit($nick)) {
if($trun==1)$nick=trun_to_rus($nick);
$nick=trim($nick);    
if($nick=="")$nick=0;
$latuser=strtolower($nick);
$ruser = rus_to_k($nick);
if($ruser==$nick){
$select = mysql_query ("Select user,id from users where latuser = '".$latuser."'"); 
}else{
$select = mysql_query ("select user,id from users where ruser = '".$ruser."'");
}
} else {
$select = mysql_query ("select user,id from users where id = '".$nick."'");
}
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";
echo "<card id=\"error\" title=\"error\" ontimer=\"ignor.php?mod=addto&amp;$ses$takep2\"><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>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=ignor.php?mod=addto&amp;$ses$takep2\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "Ник <b>".$nick."</b> невозможно добавить в игнор-лист так как пользователя с таким ником не существует\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
}
$inf = mysql_fetch_array ($select); 
$nk = $inf["id"];
@mysql_query ("Select * from ignor where usid=".$nk." and id='".$id."'");
if (mysql_affected_rows()!=0){
$ignornick = @mysql_fetch_array(@mysql_query ("Select user from users where id='".$nk."' LIMIT 1;"));
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)) echo "<card id=\"error\" title=\"error\" ontimer=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\"><timer value=\"10\" />\n";
else echo "<card id=\"error\" title=\"error\" ontimer=\"enter.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)) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; 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 "<b>".$ignornick[0]."</b> уже давно в игноре.<br/>";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
break;
}
$addus= $inf["user"];
if (!ctype_digit($nk)) {header("Location: index.php"); die;}
mysql_query ("Insert into ignor set usid='".$nk."', id='".$id."'");
$friendnick = @mysql_fetch_array(@mysql_query ("Select user from users where id='".$nk."' LIMIT 1;"));
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=\"ok\" title=\"Ok\" ontimer=\"ignor.php?$ses$takep2\"><timer value=\"5\"/>\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=\"Refresh\" CONTENT=\"2; URL=ignor.php?$ses$takep2\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "<b>".$addus."</b> добавлен в игнор-лист\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
break;

case'add':
@mysql_query ("Select * from ignor where usid=".$nk." and id='".$id."'");
if (mysql_affected_rows()!=0){
$ignornick = @mysql_fetch_array(@mysql_query ("Select user from users where id='".$nk."' LIMIT 1;"));
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)) echo "<card id=\"error\" title=\"error\" ontimer=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\"><timer value=\"10\" />\n";
else echo "<card id=\"error\" title=\"error\" ontimer=\"enter.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)) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; 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 "<b>".$ignornick[0]."</b> уже давно в игноре.<br/>";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
break;
}
$select = @mysql_query ("Select * from users where id='".$nk."'");
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))echo "<card id=\"error\" title=\"error\" ontimer=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\"><timer value=\"10\" />\n";
else echo "<card id=\"error\" title=\"error\" ontimer=\"enter.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)) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; 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 "Нет такого юзера\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
break;
}
$inf = mysql_fetch_array ($select); 
$iguser = $inf["user"];
$level = $inf["level"];
$levelselect = @mysql_query ("Select name from levels where level='".$level."'");
$levels = @mysql_fetch_array($levelselect);
$lev = $levels["name"];
if (($nk==$id)||($level>3)){
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)) echo "<card id=\"ignor\" title=\"Ok\" ontimer=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\"><timer value=\"5\"/>\n";
else echo "<card id=\"ignor\" title=\"Ok\" ontimer=\"enter.php?$ses&amp;ref=$ref\"><timer value=\"5\"/>\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)) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; 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;
if ($nk==$id) echo "Вы собираетесь кинуть себя в игнор? Глупо.<br/>\n";
if ($level>3) echo "<b>".$lev."</b> не может пополнить ВАШ игнор.<br/>\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
break;
}else{       
mysql_query ("Insert into ignor set usid='".$nk."', id='".$id."'");
$ignornick = @mysql_fetch_array(@mysql_query ("Select user from users where id='".$nk."' LIMIT 1;"));
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)) echo "<card id=\"ignor\" title=\"Ok\" ontimer=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\"><timer value=\"5\"/>\n";
else echo "<card id=\"ignor\" title=\"Ok\" ontimer=\"enter.php?$ses&amp;ref=$ref\"><timer value=\"5\"/>\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)) echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">";
else echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; 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 "<b>".$ignornick[0]."</b> в игноре!!!\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
break;
}
}
?>