View file friends.php

File size: 16.71Kb
<?

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($rm)) $takep2="&amp;rm=$rm&amp;ref=$ref";
else $takep2="&amp;ref=$ref";

$us=$row["user"];
$fr = $row["friends"];

switch($mod) {

default:
$us=$row["user"];
if(isset($go)){
@mysql_query ("Delete from friends where usid ='".$nk."' and 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=\"Ок\" title=\"Ok\" ontimer=\"friends.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\">";
if($row["skin"]=="0"){echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}if($row["skin"]=="1"){echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}if($row["skin"]=="2"){echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}if($row["skin"]=="3"){echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.css\"/>";}
echo "<title>Ок</title>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=friends.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>".$friendnick[0]."</b> больше Вам не друг.<br/>";
echo $fsize2;
include_once"foot2.php";
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=\"friendslist\" 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 friends 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 friends where id ='".$id."' order by klu4 desc limit $o,$do");
for ($i=$ot;$i<=$do;$i++){
$arr = mysql_fetch_array($r);
$nk=$arr['usid'];
$friendnick = @mysql_fetch_array(@mysql_query ("Select user from users where id='".$nk."' LIMIT 1;"));
echo ($i).") <a href=\"friends.php?$ses&amp;go=del&amp;nk=$nk&amp;ref=$ref\">[Х]</a>|<a href=\"info.php?$ses&amp;nk=$nk&amp;ref=$ref\">".$friendnick[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=\"friends.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=\"friends.php?$ses&amp;s=$prev&amp;ref=$ref\">&lt;&lt;$ot-$do&lt;&lt;</a><br/>\n";
}
}
echo $divide;
echo "<a href=\"friends.php?$ses&amp;mod=add&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;
include_once"foot2.php";
exit;
break;

case 'add':
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\">";
if($row["skin"]=="0"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}
if($row["skin"]=="1"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}
if($row["skin"]=="2"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}
if($row["skin"]=="3"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.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=\"friends.php?mod=add&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=\"friends.php?mod=add&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=\"friends.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;
include_once"foot2.php";
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=\"friends.php?mod=add&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\">";
if($row["skin"]=="0"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}
if($row["skin"]=="1"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}
if($row["skin"]=="2"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}
if($row["skin"]=="3"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.css\"/>";}
echo "<title>Ок</title>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=friends.php?mod=add&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;
include_once"foot2.php";
exit;
}
$inf = mysql_fetch_array ($select);
$nk = $inf["id"];
@mysql_query ("Select * from friends where usid=".$nk." and id='".$id."'");
if (mysql_affected_rows()!=0){
$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";
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\">";
if($row["skin"]=="0"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}
if($row["skin"]=="1"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}
if($row["skin"]=="2"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}
if($row["skin"]=="3"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.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>".$friendnick[0]."</b> уже давно Ваш друг.<br/>";
echo $fsize2;
include_once"foot2.php";
exit;
break;
}
$addus= $inf["user"];
if (!ctype_digit($nk)) {header("Location: index.php"); die;}
mysql_query ("Insert into friends 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=\"friends.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\">";
if($row["skin"]=="0"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}
if($row["skin"]=="1"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}
if($row["skin"]=="2"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}
if($row["skin"]=="3"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.css\"/>";}
echo "<title>Ок</title>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=friends.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;
include_once"foot2.php";
break;


case'addto':
@mysql_query ("Select * from friends 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\">";
if($row["skin"]=="0"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}
if($row["skin"]=="1"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}
if($row["skin"]=="2"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}
if($row["skin"]=="3"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.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\">";
if($row["skin"]=="0"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}
if($row["skin"]=="1"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}
if($row["skin"]=="2"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}
if($row["skin"]=="3"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.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;
include_once"foot2.php";
exit;
break;
}
$inf = mysql_fetch_array ($select);
$fruser = $inf["user"];
mysql_query ("Insert into friends 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";
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\">";
if($row["skin"]=="0"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}
if($row["skin"]=="1"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}
if($row["skin"]=="2"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}
if($row["skin"]=="3"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.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>".$friendnick[0]."</b> в друзьях!!!\n";
echo $fsize2;
include_once"foot2.php";
exit;
break;
}
?>