Файл: forum/inc/razdel.php
Строк: 108
<?
if (user_access('forum_razd_edit')){
if (isset($_GET['act']) && isset($_GET['ok']) && $_GET['act']=='set' && isset($_POST['name']))
{
$name=htmlspecialchars($_POST['name']);
$opis=$_POST['opis'];
if (strlen2($name)<3)$err='Слишком короткое название';
if (strlen2($name)>32)$err='Слишком длинное название';
if(strlen2($opis)>150)$err='Слишком длинное описание';
$name=my_esc($name);
if (!isset($err)){
$razd=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_r` WHERE `id` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1"));
admin_log('Форум','Разделы',"Переименование раздела '$razd[name]' в '$name'");
mysql_query("UPDATE `forum_r` SET `name` = '$name',`opis`='".my_esc($opis)."' WHERE `id` = '$razdel[id]' LIMIT 1");
$razdel=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_r` WHERE `id` = '$razdel[id]' LIMIT 1"));
msg('Изменения успешно приняты');
}
}
}
$razd=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_r` WHERE `id` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1"));
if (user_access('forum_razd_edit')){
if (isset($_GET['act']) && isset($_GET['ok']) && $_GET['act']=='mesto' && isset($_POST['forum']) && is_numeric($_POST['forum'])
&& mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_f` WHERE `id` = '".intval($_POST['forum'])."'"),0)==1)
{
$forum_new['id']=intval($_POST['forum']);
$forum_old=$forum;
mysql_query("UPDATE `forum_p` SET `id_forum` = '$forum_new[id]' WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]'");
mysql_query("UPDATE `forum_t` SET `id_forum` = '$forum_new[id]' WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]'");
mysql_query("UPDATE `forum_r` SET `id_forum` = '$forum_new[id]' WHERE `id_forum` = '$forum[id]' AND `id` = '$razdel[id]'");
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_f` WHERE `id` = '$forum_new[id]' LIMIT 1"));
admin_log('Форум','Разделы',"Перенос раздела '$razd[name]' из подфорума '$forum_old[name]' в '$forum[name]'");
msg('Раздел успешно перенесен');
}
}
if (user_access('forum_razd_del')){
if (isset($_GET['act']) && isset($_GET['ok']) && $_GET['act']=='delete')
{
mysql_query("DELETE FROM `forum_r` WHERE `id` = '$razdel[id]'");
mysql_query("DELETE FROM `forum_t` WHERE `id_razdel` = '$razdel[id]'");
mysql_query("DELETE FROM `forum_p` WHERE `id_razdel` = '$razdel[id]'");
msg('Раздел успешно удален');
err();
aut();
echo "<a href="/forum/$forum[id]/">В Подфорум</a><br />n";
echo "<a href="/forum/">В форум</a><br />n";
include_once '../sys/inc/tfoot.php';
}
}
err();
aut();
if (isset($user) && (!isset($_SESSION['time_c_t_forum']) || $_SESSION['time_c_t_forum']<$time-600 || $user['level']>0))
{
echo '<div class="foot">';
echo '<img src="/style/icons/lj.gif"> <a href="/forum/' . $forum['id'] . '/' . $razdel['id'] . '/?act=new" title="Создать новую тему">Новая тема</a><br />';
echo '</div>';
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `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">';
$q=mysql_query("SELECT * FROM `forum_t` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' ORDER BY `up` DESC,`time` DESC LIMIT $start, $set[p_str]");
if (mysql_num_rows($q)==0)
{
echo '<div class="mess">';
echo 'Нет тем в разделе "' . text($razdel['name']);
echo '</div>';
}
while ($them = mysql_fetch_assoc($q))
{
/*-----------зебра-----------*/
if ($num == 0)
{
echo '<div class="nav1">';
$num = 1;
}
elseif ($num == 1)
{
echo '<div class="nav2">';
$num = 0;
}
/*---------------------------*/
if($them['up']==1)echo "<img src='/style/themes/default/forum/14/them_10.png'> ";
echo '<a href="/forum/' . $forum['id'] . '/' . $razdel['id'] . '/' . $them['id'] . '/">' . text($them['name']) . '</a>
<a href="/forum/' . $forum['id'] . '/' . $razdel['id'] . '/' . $them['id'] . '/?page=' . $pageEnd . '"></a> (' . 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) . ')';
if($them['close']==1)echo " <img src='/style/themes/default/forum/14/them_11.png'> ";
$ank = get_user($them['id_user']);
echo '<br/><a href="/info.php?id=' . $ank['id'] . '">' . $ank['nick'] . '</a><font color=#666> (' . vremja($them['time_create']) . ')</font><br />';
$post2 = 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` DESC LIMIT 1"));
$ank2 = get_user($post2['id_user']);
if ($ank2['id'])echo 'Посл.: <a href="/info.php?id=' . $ank2['id'] . '">' . $ank2['nick'] . '</a> (' . vremja($post2['time']) . ')<br />';
echo '</div>';
}
echo '</table>';
if ($k_page>1)str("/forum/$forum[id]/$razdel[id]/?",$k_page,$page); // Вывод страниц
if (user_access('forum_razd_edit') || user_access('forum_razd_create') || user_access('forum_razd_del')){
if (isset($_GET['act']) && $_GET['act']=='mesto')
{
echo "<form method="post" action="/forum/$forum[id]/$razdel[id]/?act=mesto&ok">n";
echo "Подфорум:<br />n";
echo "<select name="forum">n";
$q2 = mysql_query("SELECT * FROM `forum_f` ORDER BY `pos` ASC");
while ($forums = mysql_fetch_assoc($q2))
{
if ($forum['id']==$forums['id'])$check=' selected="selected"';else $check=NULL;
echo "<option$check value="$forums[id]">" . text($forums['name']) . "</option>n";
}
echo "</select><br />n";
echo "<input value="Переместить" type="submit" /><br />n";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/'>Отмена</a><br />n";
echo "</form>n";
}if (isset($_GET['act']) && $_GET['act']=='set')
{
echo "<form method="post" action="/forum/$forum[id]/$razdel[id]/?act=set&ok">n";
echo "Название раздела:<br />n";
echo "<input name='name' type='text' maxlength='32' value='" . text($razdel['name']) . "' /><br />n";
echo "Описание раздела:<br/>n";
echo "<textarea name='opis'>".text($razdel['opis'])."</textarea>n";
echo "<input value="Изменить" type="submit" /><br />n";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/'>Отмена</a><br />n";
echo "</form>n";
}
if (isset($_GET['act']) && $_GET['act']=='del')
{
echo "<div class="err">n";
echo "Подтвердите удаление раздела<br />n";
echo "<a href="/forum/$forum[id]/$razdel[id]/?act=delete&ok">Да</a> <a href="/forum/$forum[id]/$razdel[id]/">Нет</a><br />n";
echo "</div>n";
}
echo "<div class="foot">n";
echo "<img src='/style/icons/str.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/?act=mesto'>Переместить раздел</a><br />n";
echo "<img src='/style/icons/str.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/?act=del'>Удалить раздел</a><br />n";
echo "<img src='/style/icons/str.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/?act=set'>Параметры раздела</a><br />n";
echo "</div>n";
}
?>