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

if($error){ echo $error;
}else{
/////////////////////////////
mysql_query("UPDATE `profile` SET `online` = 'photo' WHERE `id` = '".$id_session."'");
echo "<div class=\"head\"><b>Фотоальбомы</b></div><div class=\"main\">";  
if ( $kik_session > time()) {
    echo link1;
    echo 'Вы заблокированы. По причине: '.$whykik_session.', администратором/модератором: '.user($whokik_session).'. Осталось ждать: '.t($kik_session-time()).'<br/>';
    navig();
    foot();
    exit();
}
    $photo = num($_GET['photo']);
    $photo_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `photo_photos` WHERE `id` = '".$photo."'"));
    
    $album_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `photo_album` WHERE `id` = '".$photo_info['album']."'"));
    
    if($album_info['private']==1)
    mysql_query ("Select * from friend_list WHERE (user_1 = '".$photo_info['user']."') and (user_2 = '".$id_session."')");
    if(mysql_affected_rows()!=0) 
    
    if(isset($photo_info['id']) OR (mysql_affected_rows()!=0)) {
        
        if($album_info['private']==0) {
    
if(empty($_POST['msg']))
{
    
    echo "<div class=\"link2\"><div align=\"center\"><br/><small>max. 250</small><br/>";
    echo '<form action="coment.php?photo='.num($_GET['photo']).'" method="post" name="form">';

    if($vvod_session==0){
    echo '<input name="msg" type="text" maxlength="250" /><br/>';
    }else{
    echo '<textarea id="tarea" name="msg" cols="30" rows="5"></textarea><br/>';
    }

    echo '<input name="submit" type="submit" class="button" value="Написать" /></form><br/></div>';
    
    $all = mysql_result(mysql_query("SELECT count(*) FROM photo_coment WHERE `photo` = '".num($_GET['photo'])."'"), 0);
if($all>0)
{
$result = mysql_query("SELECT * FROM photo_coment WHERE `photo` = '".num($_GET['photo'])."'");
while($photo = mysql_fetch_assoc($result)){
    
$user_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE `id` = '".$photo['user']."'"));
    
echo "</div><div class=\"link2\"><b>".$user_info['login']."</b> | ".strftime("%d.%m.%y",$photo['date'])."<br/>";
echo "".$photo['msg']."</div>";
}
}else{ echo 'Коментов нет...';}

}else{
    
    
        if ($id_session != $photo_info['user']) {
        $msg = 'Вашу фотографию откоментировали. Перейти к <b><a href="photo/photo.php?photo='.$photo_info['id'].'">фотографии</b></a>. Откоментировал(а): '.user($id_session).'. Дата: '.date2(time()).'';
        mysql_query("INSERT INTO `uvedom` SET  `msg` = '".$msg."', `md` = 'photo_coment', `user_to` = '".$photo_info['user']."', `user_ot` = '".$id_session."', `date` = '".time()."', `status` = '1'");
        }
        
    $msg = html($_POST['msg']);
    mysql_query("INSERT INTO `photo_coment` SET `msg` = '".$msg."', `user` = '".$id_session."', `photo` = '".num($_GET['photo'])."', `date` = '".mktime()."'");
    mysql_query("UPDATE `profile` SET `many` = '".($many_session+1)."' WHERE `id` = '".$id_session."'");
echo link1 . 'Коментарий успешно добавлен.';
}

} else {
echo link1 . 'Коментарии к фото запрещены.';
}

} else {
echo link1 . 'Данного фото не существует.';
}
}
pod_navig();
foot();
?>