<?
include 'config.php';
include 'func.php';
head();
aut();
ban();

####################Запись онлайна##################
mysql_query("UPDATE `profile` SET `online` = 'simp' WHERE `id` = '".$id_session."'");
####################################################
$id = num($_GET['id']);
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE `id` = '".$id."'"));

if ( isset($_POST['submit']) ) {
    echo head . 'Симпатия' . div; 
    $simp = num($_POST['simp']);
    
    
    
    if ( empty($user['id']) ) $err = 'Анкета пользователя не найдена';
    if ( $user['id'] == $id_session ) $err = 'Хотите подмигнуть себе?';
    
    if ( isset($err) ) {
        echo link1 . $err . div;
    } else {
        $result = mysql_query("INSERT INTO `simp` SET  `simp` = '".$simp."', `to_user` = '".$id."', `ot_user` = '".$id_session."', `date` = '".time()."'");
        mysql_query("UPDATE `profile` SET `akt_rating` = '".($user['akt_rating']+0.1)."' WHERE `id` = '$user[id]' LIMIT 1");
        if ( $result != NULL ) {
        echo link1 . 'Вы успешно '.simp($simp).'' . div;
        $msg = simp2($simp);
        mysql_query("INSERT INTO `uvedom` SET  `msg` = '".$msg."', `md` = 'simp', `user_to` = '".$id."', `user_ot` = '".$id_session."', `date` = '".time()."', `status` = '1'");

        }else{
        echo link1 . 'Возникла ошибка' . div;
        }
        
    }
    
}

if ( $_GET['mod'] == 'list') {
echo head . 'Симпатия' . div;    
for ( $i = 1; $i<=19; $i++ ) {
        
        
$all = mysql_result(mysql_query("SELECT count(*) FROM `simp`WHERE `to_user` = '".num($_GET['id'])."' AND `simp` = '".num($i)."'"), 0);        
echo '  <a href="simp.php?flirt='.$i.'&user='.num($_GET['id']).'">'.simp($i).'</a> ['.$all.']<br/ >';
        
}

}

if ( $_GET['flirt'] ) {
echo head . simp($_GET['flirt']) . div;      
    $simp = num($_GET['flirt']);
    $user = num($_GET['user']);
$all = mysql_result(mysql_query("SELECT count(*) FROM `simp` WHERE `to_user` = '".$user."' AND `simp` = '".$simp."'"), 0);  

if ( $all > 0 ) {  
$result = mysql_query("SELECT * FROM simp WHERE `simp` = '".$simp."' AND `to_user` = '".$user."'");
while($simp = mysql_fetch_assoc($result)){
    
    echo "<div class='link2'>Пользователя ".user($simp['to_user'])." ".simp($simp['simp']).". От: <b>".user($simp['ot_user'])." . Дата: <b>".date2($simp['date'])."</b></div>";

}

} else {
    
    echo link1 . 'Действий еще не было' . div;
    
}
    
}
  
  
echo div;  
navig();
foot();
////////////////////////

?>