Файл: public_html/xxxfoto/inc/komm.php
Строк: 162
<?
if (!isset($user) && !isset($_GET['id_user'])){header("Location: /xxxfoto/?".SID);exit;}
if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id_user']))$ank['id']=intval($_GET['id_user']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"),0)==0){header("Location: /xxxfoto/?".SID);exit;}
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));
$gallery['id']=intval($_GET['id_gallery']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallerea` WHERE `id` = '$gallery[id]' AND `id_user` = '$ank[id]' LIMIT 1"),0)==0){header("Location: /xxxfoto/$ank[id]/?".SID);exit;}
$gallery=mysql_fetch_assoc(mysql_query("SELECT * FROM `gallerea` WHERE `id` = '$gallery[id]' AND `id_user` = '$ank[id]' LIMIT 1"));
$foto['id']=intval($_GET['id_foto']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallerea_foto` WHERE `id` = '$foto[id]' LIMIT 1"),0)==0){header("Location: /xxxfoto/$ank[id]/$gallery[id]/?".SID);exit;}
$foto=mysql_fetch_assoc(mysql_query("SELECT * FROM `gallerea_foto` WHERE `id` = '$foto[id]' LIMIT 1"));
$set['title']=$gallery['name'].' - Комментарии'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
if (isset($_POST['msg']) && isset($user))
{
$msg=$_POST['msg'];
if (isset($_POST['translit']) && $_POST['translit']==1)$msg=translit($msg);
$mat=antimat($msg);
if ($mat)$err[]='В тексте сообщения обнаружен мат: '.$mat;
if (strlen2($msg)>1024){$err='Сообщение слишком длинное';}
elseif (strlen2($msg)<2){$err='Короткое сообщение';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallerea_komm` WHERE `id_foto` = '$foto[id]' AND `id_user` = '$user[id]' AND `msg` = '".mysql_escape_string($msg)."' LIMIT 1"),0)!=0){$err='Ваше сообщение повторяет предыдущее';}
elseif(!isset($err)){
if ($ank['id']!=$user['id'])mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '[img]http://maxmob.net/style/icons/foto14.gif[/img] $user[nick] оставил [url=/xxxfoto/$ank[id]/$gallery[id]/komm/$foto[id]/]комментарий к вашему фото[/url]', '$time')");
mysql_query("INSERT INTO `gallerea_komm` (`id_foto`, `id_user`, `time`, `msg`) values('$foto[id]', '$user[id]', '$time', '".my_esc($msg)."')");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+2)."' WHERE `id` = '$user[id]' LIMIT 1");
$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '$user[id]' AND `lenta_forum` = '1' AND `i` = '1'");
while ($f = mysql_fetch_array($q))
{
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[frend]' LIMIT 1"));
$msg_obsuzh="Принял участие в [url=/xxxfoto/$ank[id]/$gallery[id]/komm/$foto[id]/]обсуждении[/url] фотографииn[url=/xxxfoto/$ank[id]/$gallery[id]/$foto[id]/][img]http://lafes.ru/xxxfoto/foto48/$foto[id].$foto[ras][/img][/url] у обитателя [url=/info.php?id=$ank[id]/][b]$ank[nick][/b][/url]";
mysql_query("INSERT INTO `obsuzh` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$a[id]', '$msg_obsuzh', '$time')");
}
msg('Комментарий к фото принят + 2 LM');
}
}
if(isset($user) && $user['level']>0&& isset($_GET['delete']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `gallerea_komm` WHERE `id`='".intval($_GET['delete'])."' AND `id_foto`='$foto[id]' LIMIT 1"),0)!=0)
{
mysql_query("DELETE FROM `gallerea_komm` WHERE `id`='".intval($_GET['delete'])."' LIMIT 1");
msg('Комментарий успешно удален');
}
err();
echo "<table class='post'>n";
echo '<tr><td class="icon14">';
echo "<a href='/xxxfoto/$ank[id]/$gallery[id]/$foto[id]/'><img class='show_foto' src='/xxxfoto/foto640/$foto[id].$foto[ras]' alt='$foto[name]' width='50' height='50' /></a>n";
echo '</td><td class="anput">';
echo "".online($ank['id'])." <a href='/info.php?id=$ank[id]'><span style="color:$ank[ncolor]">$ank[nick]</span></a><br/>n";
if ($foto['opis']!=null)
echo "<span style="color:$ank[mcolor]">";
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($foto['opis']))))))))."<br />n";
echo "</span>n";
echo "Комментариев <font color='red'>".mysql_result(mysql_query("SELECT COUNT(*) FROM `gallerea_komm` WHERE `id_foto` = '$foto[id]'"),0)."</font>n";
echo '</td></tr>';
echo "</table>n";
if (isset($user))
{
echo "<div class='textmes'>";
echo "<form method='post' name='message' action='?$passgen'>n";
if ($set['web'] && is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php'))
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';
else
echo "<a href='/smiles/index.php'><font color='black'>Смайлы</a></font> | <a href='/xxxfoto/$ank[id]/$gallery[id]/komm/$foto[id]/?page=end'><font color='black'>В начало</font></a><br />n<textarea name="msg"></textarea><br />n";
if ($user['set_translit']==1)echo "<label><input type="checkbox" name="translit" value="1" /> Транслит</label><br />n";
echo "<input value="Добавить комментарий" type="submit" />n";
echo "</form>n";
echo "</div>n";
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `gallerea_komm` WHERE `id_foto` = '$foto[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>n";
if ($k_post==0)
{
echo "Фото еще никто не обсуждал,будь первым!!!<br/>n";
}
$q=mysql_query("SELECT * FROM `gallerea_komm` WHERE `id_foto` = '$foto[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
$ank2=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));
echo " <tr>n";
if($num==1){
echo " <td class='linechat'>n";
$num=0;
}else{
echo " <td class='linechat'>n";
$num=1;}
echo "".online($ank2['id'])." <a href='/info.php?id=$ank2[id]'><span style="color:$ank2[ncolor]">$ank2[nick]</span></a> n";
echo "<br/>n";
echo "<span style="color:$ank2[mcolor]">";
echo output_text($post['msg'])." n";
if (user_access('guest_delete'))echo " [<a href='?delete=$post[id]' title='Удалить комментарий'>x</a>]";
echo "</span>n";
echo "<div style='text-align: right;'><font color='#afb0a3'>".vremja($post['time'])."</font></div>n";
}
echo "</table>n";
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
echo "<div class='rekl'>";
echo "<img src='/style/icons/photo.png' alt='' class='icon'/>n";
echo "<a href='/xxxfoto/$ank[id]/$gallery[id]/$foto[id]/'>К фотографии</a> ($foto[name])<br />n";
echo "<img src='/style/back.gif' alt='' class='icon'/>n";
echo "<a href='/xxxfoto/$ank[id]/$gallery[id]/'>К фотографиям</a> ($ank[nick])<br />n";
echo "<img src='/style/left.gif' alt='' class='icon'/>n";
echo "<a href='/xxxfoto/$ank[id]/'>К фотоальбомам</a> ($ank[nick])<br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
exit;
?>