Файл: world-faces.ru/world-faces.ru/forum/inc/them.php
Строк: 185
<?
if (isset($user) && isset($_GET['zakl']) && $_GET['zakl']==1)
{
mysql_query("INSERT INTO `forum_zakl` (`id_user`, `time`, `id_them`) values('$user[id]', '$time', '$them[id]')");
if (mysql_error()!=NULL)$errlog[]= 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)$errlog[]= mysql_error();
msg('Тема удалена из закладок');
}
if (isset($user) && ($them['close']==0 && isset($access['for_p_cr']) || $them['close']==1 && isset($access['for_p_cr2'])) && isset($_GET['act']) && $_GET['act']=='new' && isset($_POST['msg']) && isset($_POST['post']))
{
$msg=$_POST['msg'];
if (isset($_POST['msg']))
$msg=$_POST['msg'];
if (isset($_POST['translit']) && $_POST['translit']==1)$msg=translit($msg);
if (strlen2($msg)<2)$err='Короткое сообщение';
if (strlen2($msg)>5024)$err='Длина сообщения превышает предел в 5024 символа';
$msg=mysql_real_escape_string($msg);
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` = '$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)."' WHERE `id` = '$user[id]' LIMIT 1");
if (mysql_error()!=NULL)$errlog[]= mysql_error();
mysql_query("UPDATE `forum_zakl` SET `time_obn` = '$time' WHERE `id_them` = '$them[id]'");
if (mysql_error()!=NULL)$errlog[]= mysql_error();
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]', '$msg', '$time', $cit)");
mysql_query("UPDATE `forum_rdm` SET `time` = '".time()."' WHERE `t_id`='$them[id]' AND `user_id` = '$user[id]'");
if (mysql_error()!=NULL)$errlog[]= mysql_error();
$post_id=mysql_insert_id();
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()."',`p_id_user`='".abs((int)$user['id'])."' WHERE `id` = '$them[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `forum_p` = `forum_p`+1 WHERE `id` = '$user[id]' LIMIT 1");
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.'forum/down/'.$user['id'].'_'.md5_file($_FILES['file_f']['tmp_name']).'.forum.tmp';
$_SESSION['file'][$next_f]['size']=filesize(H.'forum/down'.$user['id'].'_'.md5_file($_FILES['file_f']['tmp_name']).'.forum.tmp');
$_SESSION['file'][$next_f]['type']=$_FILES['file_f']['type'];
}
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']);
}
msg('Сообщение успешно добавлено');
}
}
$req = mysql_query("SELECT * FROM `forum_rdm` WHERE `t_id`='$them[id]' AND `user_id`='$user[id]' LIMIT 1;");
$res = mysql_fetch_assoc($req);
if ($res > 0) {
if ($them['time'] > $res['time'])
mysql_query("UPDATE `forum_rdm` SET `time` = '".time()."' WHERE `t_id`='$them[id]' AND `user_id` = '$user[id]'");
} else {
// Ставим метку о прочтении
mysql_query("INSERT INTO `forum_rdm` SET `t_id` = '$them[id]', `user_id` = '$user[id]', `time` = '".time()."'");
}
if ($them['close']==1)
msg('Тема закрыта для обсуждения');
err();
if (isset($_GET['mark']))
{
$search=ereg_replace("( ){2,}"," ",$_GET['mark']);
$search=ereg_replace("^( ){1,}|( ){1,}$","",$search);
$search_a=explode(' ', $search);
for($i=0;$i<count($search_a);$i++)
{
$search_a[$i]='#'.preg_quote(esc(trim(stripcslashes(htmlspecialchars($search_a[$i]))))).'#uim';
}
}
$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'];
if (isset($user) && ($ank2['level']<$user['level'] || $user['level']==4 || $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='red'>n";
echo "Нет сообщений в теме "$them[name]"n";
echo " </div>n";
}
$post_k=$start;
while ($post = mysql_fetch_array($q))
{
if (isset($user) && ($ank2['level']<$user['level'] || $user['level']==4 || $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete')
echo "</div>n";
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
$post_k++;
if($num==1){
echo "<div class='adm2'>";
$num=0;
}else{
echo "<div class='adm'>";
$num=1;}
if (isset($access['for_t_ed']) && ($ank2['level']<$user['level'] || $user['level']==4 || $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete')
{
echo "<input type='checkbox' name="post_$post[id]" value="1" />";
}
else
echo " ".online($ank['id'])."n";
if ($set['show_num_post']==1)$num_post=$post_k.') '; else $num_post=NULL;
if (isset($user) && $them['close']==0 && isset($access['for_p_cr']))
echo "<b>$num_post<a href='/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/msg' title='Ответить $ank[nick]'><span style="color:$ank[ncolor]">$ank[nick]</span></a></b>n";
else
echo "<b>$num_post<a href='/info.php?id=$ank[id]' title='Анкета $ank[nick]'><span style="color:$ank[ncolor]">$ank[nick]</span></a><br></b>n";
echo "<span class="ank_n">(<b>".vremja($post['time'])."</b>)</span><br/>n";
echo "</div>n";
echo'<div class="rowup">';
if ($post['cit']!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id` = '$post[cit]'"),0)==1)
{
$cit=mysql_fetch_array(mysql_query("SELECT * FROM `forum_p` WHERE `id` = '$post[cit]' LIMIT 1"));
$ank_c=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $cit[id_user] LIMIT 1"));
echo "<div class='cit'>n";
echo "<b>$ank_c[nick] (".vremja($cit['time'])."):</b><br />n";
echo esc(trim(br(bbcode(links(stripcslashes(htmlspecialchars($cit['msg'])))))))."<br />Цитирую:<br/>n";
echo "</div>n";
}
echo "<span style="color:$ank[color]">n";
if (isset($_GET['mark']))
echo esc(preg_replace($search_a, '<span class="search_cit">\0</span>', trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg'])))))))))."<br />n";
else
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg']))))))))."<br />n";
echo "</span>n";
if (isset($access['for_p_ed']) || $user['level']==2 || ($ank['id']==$user['id'] && $user['level']>$ank['level']))
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 ($them['close']==0 && isset($access['for_p_cr']) && $user['id']==$post['id_user'] && $post['time']>time()-600 && $post_k==$k_post)
echo ' | ';
elseif ($them['close']==0 && isset($access['for_p_cr']) && (isset($access['for_p_ed']) || $user['level']==4 || ($ank['id']==$user['id'] && $user['level']>$ank['level'])))
echo ' | ';
else
echo "<br />n";
if ($them['close']==0 && isset($access['for_p_cr']))
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/cit' title='Цитировать $ank[nick]'>“Цитировать”</a><br />n";
echo "</div>";
if (isset($user) && ($ank2['level']<$user['level'] || $user['level']==4 || $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete')
echo "</div>n";
}
if (isset($user) && ($ank2['level']<$user['level'] || $user['level']==4 || $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 (isset($user) && ($ank2['level']<$user['level'] || $user['level']==4 || $ank2['id']==$user['id']) && isset($_GET['act']) && $_GET['act']=='post_delete'){}
elseif (isset($user) && ($them['close']==0 && isset($access['for_p_cr']) || $them['close']==1 && isset($access['for_p_cr2'])))
{
if ($user['set_files']==1)
echo "<form method='post' name='message' enctype='multipart/form-data' action='/forum/$forum[id]/$razdel[id]/$them[id]/new'>n";
else
echo "<form method='post' name='message' action='/forum/$forum[id]/$razdel[id]/$them[id]/new'>n";
if (isset($_POST['msg']) && isset($_POST['file_s']))$msg2=esc(stripcslashes(htmlspecialchars($_POST['msg']))); else $msg2=NULL;
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 "Сообщение:<br />n<textarea class='enter' cols='20' rows='3' name='msg' maxlength='1024'>$msg2</textarea><br />n";
if ($user['set_translit']==1)echo "<label><input type="checkbox" name="translit" value="1" /> Транслит<br />n";
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' /><br />n";
echo "</form>n";
echo "<div class="menu">n";
echo "<a href="/smiles">Смайлы</a><br />n";
echo "</div>n";
}
?>