<?
include 'config.php';
include 'func.php';
head();
aut();
ban();
////////////////////////////////////////
mysql_query("UPDATE `profile` SET `online` = 'guest' WHERE `id` = '".$id_session."'");

echo head . 'Мою анкету посетили:' . div;

if($_GET['delete']){
    mysql_query("DELETE FROM `guest` WHERE `user_2` = '".$id_session."'");
    echo link2 . 'Список гостей успешно очищен' . div;
}


$result = mysql_query("UPDATE `guest` SET `status` = '0' WHERE `user_2` = '".$id_session."'");

$all = mysql_result(mysql_query("SELECT count(*) FROM `guest` WHERE `user_2` = '".$id_session."'"), 0);
if($all>0)
{
    if($all){
$onpage = 5;
$allpage = ceil($all/$onpage);
$this_page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ;
if($this_page < 1 || $this_page > $allpage)$this_page = 1;
$start = $this_page*$onpage - $onpage;

$result = mysql_query("SELECT * FROM `guest` WHERE `user_2` = '".$id_session."' ORDER BY `id` DESC limit ".$start.",".$onpage."");
while($a = mysql_fetch_assoc($result)){
    $user_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE `id` = '".$a['user_1']."'"));
    
    if($user_info['upload_ava']){
    $ava = '<a href="profile.php?id='.$user_info['id'].'"><img src="resize.php?img=upload_ava/'.$user_info['upload_ava'].'&width=60&height=60" alt=""/></a>';
    } else {
    $ava = '<a href="profile.php?id='.$user_info['id'].'"><img src="resize.php?img=noava.png&width=60&height=60" alt=""/></a>';
    }
    if ($user_info['sex'] == 0) $sex = '<b><a href="profile.php?id='.$user_info['id'].'">'.$user_info['login'].'</a></b> посетила ';
    else
    $sex = '<b><a href="profile.php?id='.$user_info['id'].'">'.$user_info['login'].'</a></b> посетил ';
    echo link2 . $ava . '<br/>' . $sex . date2($a['date']) . div;;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"guest.php?p={p}",1,1);
echo div;
}
} else { 
    echo link2 . 'Гостей нет' . div;
    }

/////////////////////////////////////////

navig();
foot();
?>