Файл: vsime.com/system/start/friends.php
Строк: 165
<?
if (isset($start_page))
{
if (isset($settings))$limit = 10;
else $limit = $post['limit'];
// считаем друзей
$array_res = array();
$count = array();
$query_res = mysqli_query($dbi, "SELECT * FROM `friends` WHERE (`id_user` = '$user[id]' OR `id_ank` = '$user[id]') AND `ok` = '1'");
while ($post_res = mysqli_fetch_array($query_res))
{
if ($user['id'] != $post_res['id_user'])$ank_res = profile($post_res['id_user']); else $ank_res = profile($post_res['id_ank']);
$array_res[] = $ank_res['id'];
}
$count['friends'] = count($array_res);
$where = implode("' OR `id` = '", $array_res);
if ($count['friends'] != 0)$count['friends_online'] = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `user` WHERE (`id` = '$where') AND `date_last` > '".($time-600)."'")); else $count['friends_online'] = 0;
if ($limit > 0)
{
echo "<div class='blbot'>n";
if (isset($settings))
{
echo "<span class='right'>n";
echo "<a href='?act=start&up=$post[id]&mdp=$mdp'>$config[code_up]</a> <a href='?act=start&down=$post[id]&mdp=$mdp'>$config[code_down]</a> <a href='?act=start&delete=$post[id]'>$config[code_delete]</a> <a href='?act=start&edit=$post[id]'>$config[code_edit]</a>n";
echo "</span>n";
}
echo "<a href='/friends/?act=user&id=1&sort=2'>Друзья онлайн</a> ($count[friends_online] из $count[friends]):<br />n";
if (!$count['friends_online'])
{
if (isset($settings))
{
$count_t = mysqli_result("SELECT COUNT(*) FROM `start_user` WHERE `id_start` = '$post[id]'");
if ($count_t > 0)echo "<span style='font-size: 11px;'>Стоит у ".sklon_text($count_t, array('человека','человек','человек'))."<br />n";
}
}
echo "</div>n";
$where = implode("' OR `id` = '", $array_res);
if ($count['friends_online'])
{
$count_results_friends = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `user` WHERE (`id` = '$where') AND `date_last` > '".($time-600)."'"));
echo "<div class='list'>n";
$query_friends = mysqli_query($dbi, "SELECT * FROM `user` WHERE (`id` = '$where') AND `date_last` > '".($time-600)."' ORDER BY `date_last` ASC LIMIT $limit");
while ($post_friends = mysqli_fetch_array($query_friends))
{
echo profile_icon($post_friends['id']).profile_nick($post_friends['id'], 1).profile_medal($post_friends['id']);
echo "<br />n";
}
if (isset($settings))
{
$count = mysqli_result("SELECT COUNT(*) FROM `start_user` WHERE `id_start` = '$post[id]'");
if ($count > 0)echo "<span style='font-size: 11px;'>Стоит у ".sklon_text($count, array('человека','человек','человек'))."<br />n";
}
echo "</div>n";
}
} else {
echo "<div class='list'>n";
if (isset($settings))
{
echo "<span class='right'>n";
echo "<a href='?act=start&up=$post[id]&mdp=$mdp'>$config[code_up]</a> <a href='?act=start&down=$post[id]&mdp=$mdp'>$config[code_down]</a> <a href='?act=start&delete=$post[id]'>$config[code_delete]</a> <a href='?act=start&edit=$post[id]'>$config[code_edit]</a>n";
echo "</span>n";
}
echo "<img src='/i/site/friends.png' /> <a href='/friends/?act=user&id=1&sort=2'>Друзья онлайн</a> ($count[friends_online] из $count[friends])<br />n";
if (isset($settings))
{
$count = mysqli_result("SELECT COUNT(*) FROM `start_user` WHERE `id_start` = '$post[id]'");
if ($count > 0)echo "<span style='font-size: 11px;'>Стоит у ".sklon_text($count, array('человека','человек','человек'))."<br />n";
}
echo "</div>n";
}
} elseif (isset($submited)) {
if (isset($_POST["lim_$post[id]"]))
{
$limit_friends = intval($_POST["lim_$post[id]"]);
if (in_array($limit_friends, array(0,1,2,3,4,5,6,7,8,9,10)))$limit_friends = $limit_friends; else $limit_friends = 1;
mysqli_query($dbi, "UPDATE `start_user` SET `limit` = '$limit_friends' WHERE `id` = '$post[id]'");
}
} elseif (isset($settings_user)) {
echo "<div class='$div'>n";
if ($div=='list')
{
echo "<span class='right'>n";
echo "<a href='?act=settings&add=$post[id]&mdp=$mdp'>$config[code_add]</a>n";
echo "</span>n";
}
echo "<img src='/i/site/friends.png' /> Друзья онлайн<br />n";
echo "<div>n";
echo "Показывает список из пяти ваших друзей, которые сейчас на сайте, а так же дни рождения. Количество можно менять в настройках.n";
echo "</div>n";
echo "</div>n";
} elseif (isset($add)) {
mysqli_query($dbi, "INSERT INTO `start_user` SET `id_user` = '$user[id]', `id_start` = '$start[id]', `pos` = '$pos', `limit` = '5'");
} else {
echo "<div class='list'>n";
echo "<span class='right'>n";
echo "<a href='?act=settings&up=$post[id]&mdp=$mdp'>$config[code_up]</a> <a href='?act=settings&down=$post[id]&mdp=$mdp'>$config[code_down]</a> <a href='?act=settings&delete=$post[id]&mdp=$mdp'>$config[code_delete]</a>n";
echo "</span>n";
echo "<img src='/i/site/friends.png' /> Друзья онлайн<br />n";
echo "<div>n";
echo "Сколько друзей показывать на стартовой странице? <input name='lim_$post[id]' value='$post[limit]' size='2' /><br />n";
echo "<span class='grey small'>Укажите число от 0 до 10 (0 - не показывать ни одного друга).</span>n";
echo "</div>n";
echo "</div>n";
}
?>