Файл: html/friends.php
Строк: 112
<?php
require_once ('system/dbc.php');
require_once ('system/func.php');
auth(); // Закроем от неавторизированых
$result = $mc->query("SELECT *,COUNT(0) FROM `friends` WHERE `id_user2` = '" . $user['id'] . "' AND `red`='1'");
$drs = $result->fetch_array(MYSQLI_ASSOC);
if ($drs['COUNT(0)'] != 0 && !isset($_GET['yes']) && !isset($_GET['no'])) {
$result1 = $mc->query("SELECT * FROM `users` WHERE `id` = '" . $drs['id_user'] . "'");
$use = $result1->fetch_array(MYSQLI_ASSOC);
message_yn($use['name'] . " Хочет добавить вас в друзья", "/friends.php?yes", "/friends.php?no", "Да", "Нет");
//волшебный комментарии
?><script>showContent('/main.php');</script><?php
}
if (isset($drs) && isset($_GET['yes'])) {
$provercaFriends = $mc->query("SELECT COUNT(0) FROM `friends` WHERE ((`id_user`= '" . $user['id'] . "' AND `id_user2`= '" . $drs['id_user'] . "') OR (`id_user`= '" . $drs['id_user'] . "' AND `id_user2`= '" . $user['id'] . "')) AND `red`=0")->fetch_array(MYSQLI_ASSOC);
if ($provercaFriends['COUNT(0)'] == 0) {
$mc->query("UPDATE `friends` SET `red` = '0' WHERE `id_user` = '" . $drs['id_user'] . "' AND `id_user2` = '" . $user['id'] . "' ");
} else {
$mc->query("DELETE FROM `friends` WHERE ((`id_user` = '" . $drs['id_user'] . "' AND `id_user2` = '" . $user['id'] . "') OR (`id_user` = '" . $user['id'] . "' AND `id_user2` = '" . $drs['id_user'] . "')) AND `red`='1'");
}
?><script>showContent('friends.php');</script><?php
}
if (isset($drs) && isset($_GET['no'])) {
$mc->query("DELETE FROM `friends` WHERE `id_user` = '" . $drs['id_user'] . "' AND `id_user2` = '" . $user['id'] . "'");
?><script>showContent('friends.php');</script><?php
}
if (isset($_GET['addfriends'])) {
$mc->query("INSERT INTO `friends` (`id_user`,`id_user2`,`red`) VALUES ('" . $user['id'] . "','" . $_GET['addfriends'] . "','1')");
message("Заявка отправлена!");
}
if (isset($_GET['dellfriends'])) {
$mc->query("DELETE FROM `friends` WHERE (`id_user` = '" . $user['id'] . "' AND `id_user2` = '" . $_GET['dellfriends'] . "') OR (`id_user` = '" . $_GET['dellfriends'] . "' AND `id_user2` = '" . $user['id'] . "')");
message("Игрок удалён!");
}?>
<center>-Друзья-</center>
<table class="table_block2" >
<tr>
<td class="block01" style="width: 2%"></td>
<td class="block02" style="width: 96%"></td>
<td class="block03" style="width: 2%"></td>
</tr>
<tr>
<td class="block04"></td>
<td class="block05"><?php
$friendsAll1 = $mc->query("SELECT * FROM `friends` WHERE (`id_user` = '" . $user['id'] . "' OR `id_user2`= '" . $user['id'] . "') AND `red`=0");
while ($friendsAll = $friendsAll1->fetch_array(MYSQLI_ASSOC)) {
if ($friendsAll['id_user'] != $user['id']) {
$friendsName = $mc->query("SELECT `name`,`level`,`side`,`online` FROM `users` WHERE `id` = '" . $friendsAll['id_user'] . "'")->fetch_array(MYSQLI_ASSOC);
$friendsId = $friendsAll['id_user'];
$icon = $friendsName['side'] == 0 || $friendsName['side'] == 1 ? '<img width="19px" height="19px" src="/img/icon/icoevil.png" alt="">' : '<img width="19px" height="19px" src="/img/icon/icogood.png" alt="">';
$online;
if($friendsName['online'] > time()-60){
$online = "green";
}else{
$online = "black";
}
}
if ($friendsAll['id_user2'] != $user['id']) {
$friendsName = $mc->query("SELECT `name`,`level`,`side`,`online` FROM `users` WHERE `id` = '" . $friendsAll['id_user2'] . "'")->fetch_array(MYSQLI_ASSOC);
$friendsId = $friendsAll['id_user2'];
$icon = $friendsName['side'] == 0 || $friendsName['side'] == 1 ? '<img width="19px" height="19px" src="/img/icon/icoevil.png" alt="">' : '<img width="19px" height="19px" src="/img/icon/icogood.png" alt="">';
$online;
if($friendsName['online'] > time()-60){
$online = "green";
}else{
$online = "black";
}
}?>
<table cellspacing="4" style="width:100%">
<td style="width:30px;text-align: center">
<?=$icon;?>
</td>
<td style="max-width:100%">
<a><u style='cursor: default;' onclick=showContent('/profile/<?=$friendsId;?>')>
<font style="font-size:19px; color:<?=$online;?>;"><ins><?=$friendsName['name'];?></u></a></ins></font>
</td>
<td style="width:40px; text-align: center">
<?= $friendsName['level'];?>
</td>
</table>
<?php
}?>
</td>
<td class="block06"></td>
</tr>
<tr>
<td class="block07"></td>
<td class="block08"></td>
<td class="block09"></td>
</tr>
</table><?php
$footval = 'friends';
include 'system/foot/foot.php';
?>