<?
include 'config.php';
include 'func.php';
head();
aut();
ban();
####################Запись онлайна##################
mysql_query("UPDATE `profile` SET `online` = 'uvedom' WHERE `id` = '".$id_session."'");
####################################################
if ( $_GET['mod'] == 'fradd') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'friend' AND  `user_to` = '".$id_session."'"), 0);
    
    echo head . 'Вас добавили в друзья: ' . $all . ' человек' . div;            

    mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'friend'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'friend' 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_ot']."'"));
        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 = ' ее '; else $sex = ' его ';
        echo link2;
        echo $ava . '<br/>';
        echo '<b>'.date2($a['date']).':</b> ' . $a['msg'] . '<br/><br/>';
        mysql_query ("Select * from friends WHERE (user_1 = '".$id_session."') and (user_2 = '".$user_info['id']."')");
        if(mysql_affected_rows() == 0)
            echo '<a href="profile.php?id='.$user_info['id'].'">Перейти в анкету <b>'.$user_info['login'].'</b></a> | <a href="friends.php?mod=add&user='.$user_info['id'].'">Добавить'.$sex.'в друзья</a><br/>';
        else
            echo '<a href="profile.php?id='.$user_info['id'].'">Перейти в анкету <b>'.$user_info['login'].'</b></a>';
        echo div;
    //echo link2 . "".$a['msg']." [Дата: ".strftime("%d.%m.%y",$a['date'])."] [Время: ".t2($a['date'])."]. Перейти в анкету ".user($a['user_ot'])."" . div;
    }
    echo link1 . '<b>Страницы:</b> ';
    navigation($allpage,"uvedom.php?mod=fradd&p={p}",1,1);
    echo div;
    }
}



if ( $_GET['mod'] == 'flirt') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'simp' AND `user_to` = '".$id_session."'"), 0);
    
    echo head . 'Вам подмигнули: ' . $all . ' человек' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'simp'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'simp' 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_ot']."'"));
            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 = ' ею '; else $sex = ' ним ';
        echo link2;
        echo $ava . '<br/>';
echo "<b>".date2($a['date']).": </b> ".$a['msg']."<br/><br/>";
echo '<a href="profile.php?id='.$user_info['id'].'">Перейти в анкету <b>'.$user_info['login'].'</b></a> | <a href="simp2.php?id='.$user_info['id'].'">Совершить действие над '.$sex.'</a><br/>';
echo div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=flirt&p={p}",1,1);
echo div;
}


}


if ( $_GET['mod'] == 'black') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'black' AND  `user_to` = '".$id_session."'"), 0);
    
    echo head . 'Вас добавили в черный список: ' . $all . ' человек' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'black'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'black' 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']."'"));

echo link2 . "".$a['msg']." [Дата: ".strftime("%d.%m.%y",$a['date'])."] [Время: ".t2($a['date'])."]. Перейти в анкету ".user($a['user_ot'])."" . div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=black&p={p}",1,1);
echo div;
}


}


if ( $_GET['mod'] == 'present') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'present' AND  `user_to` = '".$id_session."'"), 0);
    
    echo head . 'Вам отправили подарок: ' . $all . ' шт' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'present'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'present' 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_ot']."'"));
    
    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 = ' ей '; else $sex = ' ему ';
        echo link2;
        echo $ava . '<br/>';
echo "<b>".date2($a['date']).": </b> ".$a['msg']."<br/><br/>";
echo '<a href="profile.php?id='.$user_info['id'].'">Перейти в анкету <b>'.$user_info['login'].'</b></a> | <a href="present.php?user='.$user_info['login'].'">Подарить'.$sex.'подарок</a><br/>';
echo div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=present&p={p}",1,1);
echo div;
}


}



if ( $_GET['mod'] == 'golos') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'golos' AND `user_to` = '".$id_session."'"), 0);
    
    echo head . 'За вашу анкету проголосовали: ' . $all . ' человек' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'golos'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'golos' 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_ot']."'"));
    
    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 = ' ее '; else $sex = ' его ';
        echo link2;
        echo $ava . '<br/>';
echo "<b>".date2($a['date']).": </b> ".$a['msg']."<br/><br/>";


echo '<a href="profile.php?id='.$user_info['id'].'">Перейти в анкету <b>'.$user_info['login'].'</b></a> | <a href="rating.php?user='.$user_info['id'].'">Оценить'.$sex.'</a><br/>';
echo div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=golos&p={p}",1,1);
echo div;
}


}
      

if ( $_GET['mod'] == 'microblog') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'microblog' AND  `user_to` = '".$id_session."'"), 0);
    
    echo head . 'Ваш микроблог откоментировали' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'microblog'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'microblog' 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']."'"));
echo link2 . "".$a['msg']."" . div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=microblog&p={p}",1,1);
echo div;
}


}

if ( $_GET['mod'] == 'forum_privat') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'forum_privat' AND  `user_to` = '".$id_session."'"), 0);
    
    echo head . 'В вашей теме ответили' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'forum_privat'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'forum_privat' 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']."'"));
echo link2 . "".$a['msg']."" . div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=forumprivat&p={p}",1,1);
echo div;
}


}

if ( $_GET['mod'] == 'photo_coment') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'photo_coment' AND  `user_to` = '".$id_session."'"), 0);
    
    echo head . 'Вашу фотографию откоментировали' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'photo_coment'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'photo_coment' 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']."'"));
echo link2 . "".$a['msg']."" . div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=photo_coment&p={p}",1,1);
echo div;
}


}


if ( $_GET['mod'] == 'photo_reyt') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'photo_reyt' AND  `user_to` = '".$id_session."'"), 0);
    
    echo head . 'Вашу фотографию оценили' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'photo_reyt'");

    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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'photo_reyt' 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']."'"));
echo link2 . "".$a['msg']."" . div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=photo_reyt&p={p}",1,1);
echo div;
}


}

if ( $_GET['mod'] == 'blog') {
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM `uvedom` WHERE `md` = 'blog' AND  `user_to` = '".$id_session."'"), 0);
    
    echo head . 'Ваш блог откоментировали' . div;            

mysql_query("UPDATE `uvedom` SET `status` = '0' WHERE `user_to` = '".$id_session."' AND `md` = 'blog'");

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 `uvedom` WHERE `user_to` = '".$id_session."' AND `md` = 'blog' 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']."'"));
echo link2 . "".$a['msg']."" . div;
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"uvedom.php?mod=blog&p={p}",1,1);
echo div;
}


}


if ( $_GET['mod'] == 'clean') {
echo head . 'Чистка уведомлений' . div . katalog;   
if (mysql_query("DELETE FROM `uvedom` WHERE `user_to` = '".$id_session."'")) {
    echo 'История уведомлений очищена';
    mysql_query("DELETE FROM `flirt_lenta` WHERE `id_opponent` = '".$id_session."'");
    mysql_query("DELETE FROM `guest` WHERE `user_2` = '".$id_session."'");
} else {
    echo 'Возникла ошибка';
}

}

navig();
foot();
?>