<?php

$ank['id'] = $user['id'];
if (isset($_GET['id'])) {
    $ank['id'] = intval($_GET['id']);
}
$q = $db->query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1");
if ($db->num_rows($q) == 0) {
    header("Location: index.php?" . SID);
    exit;
}

$ank = $db->get_array($q);

$k_post = $db->super_query("SELECT COUNT(*) as count FROM `friends` WHERE `user` = '$ank[id]' AND `i` = '1'");
$k_post = $k_post['count'];

if ($k_post == 0) {
    
}

$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

if (IS_WEB) {
    $q = $db->query("SELECT * FROM `friends` WHERE `user` = '$ank[id]' AND `i` = '1' ORDER BY rand() DESC LIMIT 6");
} else {
    $q = $db->query("SELECT * FROM `friends` WHERE `user` = '$ank[id]' AND `i` = '1' ORDER BY rand() DESC LIMIT 5");
}
if ($k_post == 0) {
    
} else {
    echo "<div class='list-group-item-null' style='margin-top: 2px;margin-left: 2px;margin-right: 2px;'><table class=''><tr>";
}
while ($f = $db->get_array($q)) {
    $a = $db->get_array($db->query("SELECT * FROM `user` WHERE `id` = '$f[friends]' LIMIT 1"));
    echo "<td>";
    if (IS_WEB) {
        echo "<div class='photos'>";
        echo "<span class='photos_blok'><center>$a[nick]</center></span>";
        echo " <a href='/id$a[id]'>";
        avatar($a['id'], '100', 'border-radius: 2px;');
        echo "</a>";
        echo "</div>";
    } else {
        echo "<div class='photos1'>";
        echo "<span class='photos_blok1'><center>$a[nick]</center></span>";
        echo " <a href='/id$a[id]'>";
        avatar($a['id'], '50', 'border-radius: 2px;');
        echo "</a>";
        echo "</div>";
    }
    echo "</td>";
}
if ($k_post == 0) {
    
} else {
    echo "</tr></table></div>";
}