<?php

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

if(!isset($go)){

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=\"search\" 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\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>\n";
echo "<title>Поиск</title>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>\n";
echo "<div align=\"center\">\n";
}
if ($ver!="wml")echo "<form method=\"POST\" action=\"search.php?go=view&amp;$ses&amp;ref=$ref\" name=\"auth\">\n";
echo $fsize1;
echo "Ник или ID юзера:<br/>\n"; 
echo $fsize2;
echo "<input name=\"nick\" title=\"nick\"/><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=\"go\">Искать<go href=\"search.php?go=view&amp;$ses&amp;ref=$ref\" 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/>";
}else{
echo "<input type=\"submit\" value=\"Искать\" name=\"enter\"><br/>\n";
}
echo $fsize1;
echo $divide;
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;
}
 
if(@$go == "view"){       
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 id,user,sex,user_ip,user_soft,level,version from users where latuser = '".$latuser."'");
} else {
$select = @mysql_query ("Select id,user,sex,user_ip,user_soft,level,version from users where ruser = '".$ruser."'"); 
}
} else {
$select = @mysql_query ("Select id,user,sex,user_ip,user_soft,level,version from users where id='".$nick."'"); 
}
if (mysql_affected_rows() == 0){
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>";
echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"search.php?$ses&amp;ref=$ref\"><timer value=\"15\"/>";
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\">";
}
echo $fsize1;
echo "Юзер не найден! Ошибка ввода ника или ID";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;	
}
$inf = mysql_fetch_array ($select); 
$usid=$inf["id"];  
$nick = $inf["user"];
$sex = $inf["sex"];
$us_ip = $inf["user_ip"];
$us_soft = $inf["user_soft"];
$level=$inf["level"];
$ign=$inf["ignor"];
$version=$inf["version"];

ob_start();
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=\"results\" title=\"".$nick."\">\n";
echo "<p>\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>".$nick."</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"left\">";
}
echo $fsize1; 
if ($sex=="М")echo "Пользователь <b>".$nick."</b> найден<br/>\n";
else echo "Пользователь <b>".$nick."</b> найдена<br/>\n";
echo $divide;
echo "<a href=\"info.php?$ses&amp;nk=$usid&amp;ref=$ref\">Анкета пользователя</a><br/>\n";
echo $divide;
echo "<a href=\"ignor.php?mod=add&amp;$ses&amp;nk=$usid&amp;ref=$ref\">B Игнор</a><br/>\n";
echo "<a href=\"friends.php?mod=addto&amp;$ses&amp;nk=$usid&amp;ref=$ref\">В друзья</a><br/>\n";
echo $divide;
if(($rm!=9)||($rm!=11)||$row["level"]==7){
if($row["level"]>3)echo "<a href=\"kick.php?$ses&amp;nk=$usid&amp;ref=$ref\">Пнуть</a><br/>\n";
if ($row["level"]>5)echo "<a href=\"bannaip.php?$ses&amp;nk=$usid&amp;ref=$ref\">Банн ip+soft!!!</a><br/>\n";
if ($row["level"]>6){ 
echo "<a href=\"apanel.php?$ses&amp;nk=$usid&amp;go=fullignmake&amp;ref=$ref\">Полный игнор!</a><br/>\n";
echo "<a href=\"bann.php?$ses&amp;nk=$usid&amp;ref=$ref\">Забанить ник</a><br/>\n";
echo "<a href=\"deluser.php?$ses&amp;nk=$usid&amp;ref=$ref\">Удалить ник</a><br/>\n";
echo $divide;
echo "<b><a href=\"apanel.php?go=view&amp;$ses&amp;nick=$usid&amp;ref=$ref\">Апдейт юзера</a></b><br/>\n";
}
}
if($row["level"]>5){   
if(($inf["level"]<7)||($row["level"]>6)){
echo $divide;
echo "<b>IP:</b> $us_ip<br/>\n";
echo "<b>Soft:</b> $us_soft<br/>\n";
if ($version==1) echo "<b>Версия чата:</b> WAP 1.2<br/>\n";
else echo "<b>Версия чата:</b> WAP 2.0<br/>\n";
echo $divide;
}
}
echo "<a href=\"search.php?$ses&amp;ref=$ref\">Искать еще &#8594;</a><br/>\n";  
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">&#8592; Прихожая</a>\n"; 
echo $divide;
$alltraf=$row["alltraf"];
$pagesize=round((ob_get_length()+200)/1024,1);
$alltraf1=$alltraf+$pagesize;
echo "Вес страницы: $pagesize Кб<br/>\n";
echo $fsize2; 
if ($ver=="wml")echo "</p></card></wml>\n";
else echo "</div></body></html>\n";
mysql_query ("Update users set alltraf='".$alltraf1."', lasttraf='".$pagesize."' where id='".$id."'");
mysql_close ($link);
ob_end_flush();
}
?>