Файл: test.masteram.us/forum/inc/them.php
Строк: 435
<?
mysql_query("UPDATE `forum_t` SET prosm = prosm +1 WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id` = '$them[id]' LIMIT 1");
if (isset($_GET['act']) && $_GET['act']=='txt')
{
ob_clean();
ob_implicit_flush();
header('Content-Type: text/plain; charset=utf-8', true);
header('Content-Disposition: attachment; filename="'.retranslit($them['name']).'.txt";');
echo "Тема: $them[name] ($forum[name]/$razdel[name])rn";
$q=mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' ORDER BY `time` ASC");
//echo "rn";
while ($post = mysql_fetch_assoc($q))
{
echo "rn";
$ank=get_user($post['id_user']);
echo "$ank[nick] (".date("j M Y в H:i", $post['time']).")rn";
if ($post['cit']!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id` = '$post[cit]'"),0)==1)
{
$cit=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id` = '$post[cit]' LIMIT 1"));
$ank_c=get_user($cit['id_user']);
echo "--Цитата--rn";
echo "<span style="color:$ank_c[ncolor]">$ank_c[nick]</span> (".date("j M Y в H:i", $cit['time'])."):rn";
echo trim(br($cit['msg'],"rn"))."rn";
echo "----------rn";
}
echo trim(br($post['msg'],"rn"))."rn";
}
echo "rnИсточник: http://$_SERVER[SERVER_NAME]/forum/$forum[id]/$razdel[id]/$them[id]/rn";
exit;
}
if (isset($user) && isset($_GET['f_del']) && is_numeric($_GET['f_del']) && isset($_SESSION['file'][$_GET['f_del']]))
{
unlink($_SESSION['file'][$_GET['f_del']]['tmp_name']);
}
if (isset($user) && isset($_GET['zakl']) && $_GET['zakl']==1)
{
mysql_query("INSERT INTO `forum_zakl` (`id_user`, `time`, `id_them`, `time_obn`) values('$user[id]', '$time', '$them[id]', '$time')");
//if (mysql_error()!=NULL)echo mysql_error();
msg('Тема добавлена в закладки');
}
elseif (isset($user) && isset($_GET['zakl']) && $_GET['zakl']==0)
{
mysql_query("DELETE FROM `forum_zakl` WHERE `id_user` = '$user[id]' AND `id_them` = '$them[id]'");
//if (mysql_error()!=NULL)echo mysql_error();
msg('Тема удалена из закладок');
}
if (isset($user) && isset($_GET['act']) && $_GET['act']=='new' && isset($_FILES['file_f']) && ereg('.', $_FILES['file_f']['name']) && isset($_POST['file_s']))
{
copy($_FILES['file_f']['tmp_name'], H.'sys/tmp/'.$user['id'].'_'.md5_file($_FILES['file_f']['tmp_name']).'.forum.tmp');
chmod(H.'sys/tmp/'.$user['id'].'_'.md5_file($_FILES['file_f']['tmp_name']).'.forum.tmp', 0777);
if (isset($_SESSION['file']))$next_f=count($_SESSION['file']);else $next_f=0;
$file=esc(stripcslashes(htmlspecialchars($_FILES['file_f']['name'])));
$_SESSION['file'][$next_f]['name']=eregi_replace('.[^.]*$', NULL, $file); // имя файла без расширения
$_SESSION['file'][$next_f]['ras']=strtolower(eregi_replace('^.*.', NULL, $file));
$_SESSION['file'][$next_f]['tmp_name']=H.'sys/tmp/'.$user['id'].'_'.md5_file($_FILES['file_f']['tmp_name']).'.forum.tmp';
$_SESSION['file'][$next_f]['size']=filesize(H.'sys/tmp/'.$user['id'].'_'.md5_file($_FILES['file_f']['tmp_name']).'.forum.tmp');
$_SESSION['file'][$next_f]['type']=$_FILES['file_f']['type'];
}
if (isset($user) && ($them['close']==0 || $them['close']==1 && user_access('forum_post_close')) && isset($_GET['act']) && $_GET['act']=='new' && isset($_POST['msg']) && !isset($_POST['file_s']))
{
$msg=$_POST['msg'];
//
if (!empty($_POST['bold'])){
$msg = '[b]'.$msg.'[/b]';}
if (!empty($_POST['under'])){
$msg = '[u]'.$msg.'[/u]';}
if (!empty($_POST['sol'])){
$msg = '[sol]'.$msg.'[/sol]';}
if (!empty($_POST['ex'])){
$msg = '[ex]'.$msg.'[/ex]';}
//
if (isset($_POST['translit']) && $_POST['translit']==1)$msg=translit($msg);
if (strlen2($msg)<2)$err='Короткое сообщение';
if (strlen2($msg)>102400)$err='Длина сообщения превышает предел в 102400 символа';
$mat=antimat($msg);
if ($mat)$err[]='В тексте сообщения обнаружен мат: '.$mat;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_user` = '$user[id]' AND `msg` = '".my_esc($msg)."' LIMIT 1"),0)!=0)$err='Ваше сообщение повторяет предыдущее';
if (!isset($err))
{
if (isset($_POST['cit']) && is_numeric($_POST['cit']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id` = '".intval($_POST['cit'])."' AND `id_them` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."'"),0)==1)
$cit=intval($_POST['cit']); else $cit='null';
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+1)."', `akt_rating` = '".($user['akt_rating']+0.001)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `lafes_f` = '".($user['lafes_f']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_them` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."'"),0) >=30)
{
$ank_aut=get_user($them['id_user']);
mysql_query("UPDATE `user` SET `akt_rating` = '".($ank_aut['akt_rating']+0.003)."' WHERE `id` = '$ank_aut[id]' LIMIT 1");
}
mysql_query("UPDATE `forum_zakl` SET `time_obn` = '$time' WHERE `id_them` = '$them[id]'");
mysql_query("INSERT INTO `forum_p` (`id_forum`, `id_razdel`, `id_them`, `id_user`, `msg`, `time`, `cit`) values('$forum[id]', '$razdel[id]', '$them[id]', '$user[id]', '".my_esc($msg)."', '$time', $cit)");
$post_id=mysql_insert_id();
if (isset($_SESSION['file']) && isset($user))
{
for ($i=0; $i<count($_SESSION['file']);$i++)
{
if (isset($_SESSION['file'][$i]) && is_file($_SESSION['file'][$i]['tmp_name']))
{
mysql_query("INSERT INTO `forum_files` (`id_post`, `name`, `ras`, `size`, `type`) values('$post_id', '".$_SESSION['file'][$i]['name']."', '".$_SESSION['file'][$i]['ras']."', '".$_SESSION['file'][$i]['size']."', '".$_SESSION['file'][$i]['type']."')");
$file_id=mysql_insert_id();
copy($_SESSION['file'][$i]['tmp_name'], H.'sys/forum/files/'.$file_id.'.frf');
unlink($_SESSION['file'][$i]['tmp_name']);
}
}
unset($_SESSION['file']);
}
unset($_SESSION['msg']);
mysql_query("UPDATE `forum_r` SET `time` = '$time' WHERE `id` = '$razdel[id]' LIMIT 1");
mysql_query("UPDATE `forum_t` SET `time` = '$time' WHERE `id` = '$them[id]' LIMIT 1");
$post1=mysql_fetch_array(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' ORDER BY `time` ASC LIMIT 1"));
$admin=mysql_fetch_array(mysql_query("SELECT * FROM `forum_t` WHERE `id` = '$them[id]' LIMIT 1"));
if (isset($user) && $user['id']==$admin['id_user']){
}else{
$an=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post1[id_user] LIMIT 1"));
$msgrat1="[b][green]Форум[/green][/b] | В вашей теме [url=/forum/$forum[id]/$razdel[id]/$them[id]/?page=end]$them[name][/url] оставили сообщение.. ";
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$an[id]', '$msgrat1', '$time')");}
msg('Сообщение успешно добавлено +1 монета');
}
}
if ($them['close']==1)
msg('Тема закрыта для обсуждения');
if (isset($user) && $user['balls']>=50 && $user['rating']>=0 && isset($_GET['id_file'])
&&
mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_files` WHERE `id` = '".intval($_GET['id_file'])."'"), 0)==1
&&
mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_files_rating` WHERE `id_user` = '$user[id]' AND `id_file` = '".intval($_GET['id_file'])."'"), 0)==0)
{
if (isset($_GET['rating']) && $_GET['rating']=='down')
{
mysql_query("INSERT INTO `forum_files_rating` (`id_user`, `id_file`, `rating`) values('$user[id]', '".intval($_GET['id_file'])."', '-1')");
msg ('Ваш отрицательный отзыв принят');
}
elseif(isset($_GET['rating']) && $_GET['rating']=='up')
{
mysql_query("INSERT INTO `forum_files_rating` (`id_user`, `id_file`, `rating`) values('$user[id]', '".intval($_GET['id_file'])."', '1')");
msg ('Ваш положительный отзыв принят');
}
}
err();
echo "<div class="menu_razd">n";
$post1=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' ORDER BY `time` ASC LIMIT 1"));
$ank=get_user($post1['id_user']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '$ank[id]' AND `time` > '$time'"), 0)!=0)
echo "<font color='red'>[BAN]</font>n";
echo "".online($ank['id'])." <a href='/info.php?id=$ank[id]' title='Анкета "$ank[nick]"'><span style="color:$ank[ncolor]">$ank[nick]</span></a> n";
$ank1=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
if ($ank['group_access']>1)echo "<img src='/img/online/$ank[pol].png'>n";
///if ($ank['group_access']>1)echo "<img src='/style/adm.png'>n";
if ($ank['status_vip']==1)echo " <img src='/status_vip/img/vip.gif'<br />";
if($ank['akt_rating']>=0 && $ank['akt_rating']<=1.000)echo " ";
if($ank['akt_rating']>=1.001 && $ank['akt_rating']<=2.500)echo " <img src='/style/rating/bronze.gif'></img> ";
if($ank['akt_rating']>=2.501 && $ank['akt_rating']<=5.000)echo " <img src='/style/rating/silver.gif'></img> ";
if($ank['akt_rating']>=5.001 && $ank['akt_rating']<=7.500)echo " <img src='/style/rating/gold.gif'></img> ";
if($ank['akt_rating']>=7.501 && $ank['akt_rating']<=10.000)echo " <img src='/style/rating/lafes_user.gif'></img> ";
if($ank['akt_rating']>=10.001 && $ank['akt_rating']<=200.000)echo " <img src='/rating/konkurs.png'></img> ";
if ($ank['stran']==0)echo "n";
if ($ank['stran']==1)echo "<img src='/style/strana/ru.png'>n";
if ($ank['stran']==2)echo "<img src='/style/strana/ua.png'>n";
if ($ank['stran']==3)echo "<img src='/style/strana/by.png'>n";
if ($ank['stran']==4)echo "<img src='/style/strana/az.png'>n";
if ($ank['stran']==5)echo "<img src='/style/strana/kz.png'>n";
if ($ank['stran']==6)echo "<img src='/style/strana/uz.png'>n";
if ($ank['stran']==7)echo "<img src='/style/strana/england.png'>n";
if ($ank['stran']==8)echo "<img src='/style/strana/de.png'>n";
echo "(".vremja($them['time_create']).")n";
echo "<br/>n";
echo "<img src='/style/icons/blogi.png' alt=''/> $them[name]n";
if (isset($user))
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_zakl` WHERE `id_them` = '$them[id]' AND `id_user` = '$user[id]'"),0)==0)
echo " <a href="/forum/$forum[id]/$razdel[id]/$them[id]/?page=$page&zakl=1" title='Добавить в закладки'><img src='/forum/add_fav.gif' alt=''/></a><br />n";
else
{
mysql_query("UPDATE `forum_zakl` SET `time` = '".time()."' WHERE `id_them` = '$them[id]' AND `id_user` = '$user[id]'");
echo " <a href="/forum/$forum[id]/$razdel[id]/$them[id]/?page=$page&zakl=0" title='Удалить из закладок'><img src='/style/icons/delete.png' alt=''/></a><br />n";
}
}
echo "</div>n";
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[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 ((user_access('forum_post_ed') || isset($user) && $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete'){$lim=NULL;}else $lim=" LIMIT $start, $set[p_str]";
$q=mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' ORDER BY `time` ASC$lim");
if (mysql_num_rows($q)==0) {
echo " <div class='p_t'>n";
echo "Нет сообщений в теме "$them[name]"n";
echo " </div>n";
}
$post_k=$start;
while ($post = mysql_fetch_assoc($q))
{
$ank=get_user($post['id_user']);
$post_k++;
echo " <tr>n";
if ($user['zebra_forum']==0)
{
if($num==1){
echo "<div class='linechat'>";
$num=0;
}else{
echo "<div class='linechat'>";
$num=1;}
}
if ($user['zebra_forum']==1)
{
if($num==1){
echo "<div class='forumdiv'>";
$num=0;
}else{
echo "<div class='forumwup'>";
$num=1;}
}
if ((user_access('forum_post_ed') || isset($user) && $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete')
{
echo "<input type='checkbox' name='post_$post[id]' value='1' />";
}
if ((user_access('forum_post_ed') || isset($user) && $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete')
{
echo "<input type='checkbox' name='post_$post[id]' value='1' />";
}
if ($set['show_num_post']==1)$num_post=$post_k.') '; else $num_post=NULL;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '$ank[id]' AND `time` > '$time'"), 0)!=0)
echo "<font color='red'>[BAN]</font>n";
if (isset($user) && $them['close']==0)
echo "$num_postn";
echo " ".online($ank['id'])." <a href='/info.php?id=$ank[id]' title='Анкета $ank[nick]'><span style="color:$ank[ncolor]">$ank[nick]</span></a> n";
if ($ank['obit']==0)
{
$ank1=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
if ($ank['group_access']>1)echo "<img src='/img/online/$ank[pol].png'>n";
///if ($ank['group_access']>1)echo "<img src='/style/adm.png'>n";
}
if ($ank['vkl_post']==0)
{
echo "<font color='red'>($ank[lafes_f])</font>n";
}
if ($them['close']==0 && isset($user))
echo "[<a href='/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/msg' title='Ответить $ank[nick]'><font color='#3b3738'>Отв</a></font> n";
echo "| <a href='/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/cit' title='Цитировать $ank[nick]'><font color='#3b3738'>Цит</font></a>]n";
echo "<br />n";
if ($post['cit']!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id` = '$post[cit]'"),0)==1)
{
$cit=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id` = '$post[cit]' LIMIT 1"));
$ank_c=get_user($cit['id_user']);
echo "<div class='cit'>n";
echo "Цитата:<br />n";
echo "<span style="color:$ank_c[ncolor]">$ank_c[nick]</span> (".vremja($cit['time'])."):</b><br />n";
echo "<span style="color:$ank_c[mcolor]">n";
echo output_text($cit['msg'])."<br />n";
echo "</span>n";
echo "</div>n";
}
echo "<span style="color:$ank[mcolor]">n";
echo output_text($post['msg'])."<br />n";
echo "</span>n";
include H.'/forum/inc/file.php';
echo " <div style='text-align: right;'><font color='#afb0a3'>".vremja($post['time'])."</font> n";
if (user_access('forum_post_ed') && ($ank['level']<=$user['level'] || $ank['level']==$user['level'] && $ank['id']==$user['id']))
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/edit'>[Изм]</a>n";
elseif (isset($user) && $user['id']==$post['id_user'] && $post['time']>time()-600 && $post_k==$k_post)
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/edit'>[Изм ".($post['time']+600-time())." сек]</a>n";
if (isset($user) && $them['close']==0 && $user['id']==$post['id_user'] && $post['time']>time()-600 && $post_k==$k_post)
echo ' ';
elseif ($them['close']==0 && user_access('forum_post_ed') && ($ank['level']<$user['level'] || $ank['level']==$user['level'] && $ank['id']==$user['id']))
echo ' ';
echo "</div>n";
}
echo "</div>n";
if ((user_access('forum_post_ed') || isset($user) && $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete'){}
elseif ($k_page>1)str("/forum/$forum[id]/$razdel[id]/$them[id]/?",$k_page,$page); // Вывод страниц
if ((user_access('forum_post_ed') || isset($user) && $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete'){}
elseif (isset($user) && ($them['close']==0 || $them['close']==1 && user_access('forum_post_close')))
{
if ($user['set_files']==1)
echo "<form method='post' name='message' enctype='multipart/form-data' action='/forum/$forum[id]/$razdel[id]/$them[id]/new?$passgen'>n";
else
echo "<form method='post' name='message' action='/forum/$forum[id]/$razdel[id]/$them[id]/new?$passgen'>n";
if (isset($_POST['msg']) && isset($_POST['file_s']))$msg2=output_text($_POST['msg'],false,true,false,false,false); else $msg2=NULL;
echo "<div class='textmes'>";
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'>Смайлы</a><br />n";
include_once '../bb.php';
echo "<textarea name="msg">$msg2</textarea><br />n";
/*
if($user['group_access'] > 1){
echo " <label><input type="checkbox" name="bold" value="$user[id]" /> Жр</label>n";
echo " <label><input type="checkbox" name="sol" value="$user[id]" /> Об</label>n";
echo " <label><input type="checkbox" name="ex" value="$user[id]" /> Зч</label>n";
echo "<label><input type="checkbox" name="under" value="$user[id]" /> Пч</label><br />n";}
*/
echo '</div>';
if ($user['set_files']==1){
if (isset($_SESSION['file']))
{
echo "Прикрепленные файлы:<br />n";
for ($i=0; $i<count($_SESSION['file']);$i++)
{
if (isset($_SESSION['file'][$i]) && is_file($_SESSION['file'][$i]['tmp_name']))
{
echo "<img src='/style/themes/$set[set_them]/forum/14/file.png' alt='' />n";
echo $_SESSION['file'][$i]['name'].'.'.$_SESSION['file'][$i]['ras'].' (';
echo size_file($_SESSION['file'][$i]['size']);
echo ") <a href='/forum/$forum[id]/$razdel[id]/$them[id]/d_file$i' title='Удалить из списка'><img src='/style/themes/$set[set_them]/forum/14/del_file.png' alt='' /></a>n";
echo "<br />n";
}
}
}
echo "<input name='file_f' type='file' /><br />n";
echo "<input name='file_s' value='Прикрепить файл' type='submit' /><br />n";
}
echo "<input name='post' value='Добавить сообщение' type='submit' />n";
echo "</form>n";
echo "</div>n";
}
echo "<div class="rekl">n";
echo "<center>";
echo "<img src='/style/icons/013.png' alt=''/>Постов <font color='red'>".mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_them` = '$them[id]'"),0)."</font>n";
$prosm = mysql_result(mysql_query("SELECT `prosm` FROM `forum_t` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id` = '$them[id]'"),0);
echo "<img src='/style/icons/008.png' alt=''/>Просмотров <font color='red'>".$prosm."</font><br />n";
echo "</center>";
echo "</div>n";
echo "<div class="rekl">n";
echo "<img src='/forum/Back.gif' alt=''/>n";
echo "<a href="/forum/$forum[id]/" title='В подфорум'>$forum[name]</a> <n";
echo "<a href="/forum/$forum[id]/$razdel[id]/" title='В раздел'>$razdel[name]</a>n";
echo "</div>n";
?>