View file ä󿪫¬/modules/foto/share.php

File size: 3.86Kb
<?php

foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
    require_once "../../sys/inc/$inc.php";
}



$set['title']='Поделиться фото';
include_once '../../sys/inc/thead.php';

aut();
only_reg();

#Навигация
echo "<div class='card-header'>";
echo "<a href='/' data-toggle='tooltipecho' data-placement='right' title='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='/info.php?$user[id]'>$user[nick]</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='user.php?id=$user[id]'>";
echo lang('Блог');
echo "</a> <i class='fa fa-angle-right fa-fw'></i> Поделиться фото</div>";
echo "<div class='list-group-item'>";








$fot = $pdo->query("SELECT * FROM `gallery_foto` WHERE `id`='".intval($_GET['id'])."' LIMIT 1");
if($fot->rowCount()==0){
echo "<div class='err'>Такого фото не существует</div>";
}elseif($pdo->query(("SELECT COUNT(`share_id_user`)FROM `notes` WHERE `id_user`='".$user['id']."' AND `share_id`='".intval($_GET['id'])."' AND `share_type`='foto' LIMIT 1"),0)->fetchColumn()==1){
echo "<div class='err'>Вы уже поделились данным фото</div>";
}else{
$foto = $fot->fetch(PDO::FETCH_ASSOC);

if(isset($_POST['share_text'])){ 
$sha = htmlspecialchars($_POST['share_text']);    

if (utf8_strlen($sha)>120){$err='Комментарий не может содержать более 120 символов'; }
if (utf8_strlen($sha)<3){$err='Комментарий содержит менее 3 символов'; }
}



err();



if($foto['id_user']!=$user['id']){
$avtor=get_user($foto['id_user']);
if(isset($_POST['ok']) && isset($_POST['share_text'])){

if (!isset($err))
{  
    
$name = stripslashes(htmlspecialchars($foto['name']));    
$share_text = htmlspecialchars($_POST['share_text']);    
$msg = stripslashes(htmlspecialchars($foto['opis']));

$pdo->query("INSERT INTO `notes`(`id_user`,`name`,`msg`,`share`,`share_text`,`share_id`,`share_id_user`,`share_name`,`time`, `share_type`) values('".$user['id']."','".$name."','".$share_text."','1','".$msg."','".stripslashes(htmlspecialchars($foto['id']))."','".stripslashes(htmlspecialchars($foto['id_user']))."','".stripslashes(htmlspecialchars($foto['name']))."','".stripslashes(htmlspecialchars($time))."', 'foto')");
$id=$pdo->lastInsertId();

/////////////////////////журнал///////////////
if ($avtor['jurnal_blogs_share']==1){

$name2="$user[nick] поделился вашим фото";

$msg2="[url=/modules/foto/$foto[id_user]/$foto[id_gallery]/$foto[id]/] ".utf8_substr($foto['name'],20)." [/url]";

$pdo->query("INSERT INTO `jurnal` (`avtor`, `id_user`, `id_kont`, `msg`, `name`, `type`, `time`) values('$user[id]', '0', '$foto[id_user]', '".htmlspecialchars($msg2)."', '".htmlspecialchars($name2)."', 'notes', '$time')");

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

}



header('Location: /modules/blogs/list.php?id='.$id);
exit;
}
}

?>
<i class='fa fa-book'></i> <? echo " ".$avtor['nick']."";?> : <a href="/modules/foto/<?=stripslashes(htmlspecialchars($foto['id_user']));?>/<?=stripslashes(htmlspecialchars($foto['id_gallery']));?>/<?=stripslashes(htmlspecialchars($foto['id']));?>/">
<span style="color:#06F;"><? echo stripslashes(htmlspecialchars($foto['name'])); ?></span></a><br><br>
<?

echo "<form method='post' name='msg' action='share.php?id=".intval($_GET['id'])."'>";
echo auto_bb("msg", "share_text");
echo "<textarea class='form-control' placeholder=\"Введите комментарий к фото...\" name='share_text'></textarea>";
echo "<br><input class='knopka' type='submit' name='ok' value='Поделиться'><br>";
echo "</form><br><br>";
}else{
echo "<div class='err'>Нельзя делиться своими фото</div>";
}
}


echo "</div>";
include_once '../../sys/inc/tfoot.php';
?>