Файл: mylaf.ru/mods/forum/index.php
Строк: 151
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
if(isset($_GET['add']) && isset($user) && $user['level']>2){
$set['title']="Новый раздел";
include_once '../sys/inc/thead.php';
title();
aut();
if(isset($_POST['ok']) && isset($_GET['ok'])){
$name=my_esc($_POST['name']);
$opis=my_esc($_POST['opis']);
if (strlen2($name)<3)$err="Короткое название раздела.";
if (strlen2($name)>30)$err="Длинное название раздела.";
if (strlen2($opis)>500)$err="Длинное описание раздела.";
if (!isset($err)){
$post=mysql_result(mysql_query("SELECT MAX(`post`) FROM `forum`"), 0)+1;
mysql_query("INSERT INTO `forum` SET `name` = '$name', `opis` = '$opis', `post` = '$post'");
msg("Раздел успешно создан.");
}
}
err();
echo "<form method='post' action='?add&ok'>";
echo "Название раздела:<br/>";
echo "<input type='text' name='name' value=''><br/>";
echo "Описание раздела:<br/>";
echo "<textarea name='opis'></textarea><br/>";
echo "<input type='submit' name='ok' value='Добавить'><br/></form>";
echo "<a href='?'><div class='foot'><img src='/style/icons/str2.gif'/> Вернутся назад</div></a>";
include_once '../sys/inc/tfoot.php';
}
elseif(isset($_GET['edit']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `id` = '".intval($_GET['edit'])."'"),0)!=0 && isset($user) && $user['level']>2){
$edit=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '".intval($_GET['edit'])."'"));
if ($edit['id']==0)header("location:/index.php?");
$set[title]="Редактивирование раздела";
include_once '../sys/inc/thead.php';
title();
aut();
if(isset($_POST['ok']) && isset($_GET['ok'])){
$name=my_esc($_POST['name']);
$opis=my_esc($_POST['opis']);
if (strlen2($name)<3)$err="Короткое название раздела.";
if (strlen2($name)>30)$err="Длинное название раздела.";
if (strlen2($opis)>500)$err="Длинное описание раздела.";
if (!isset($err)){
mysql_query("UPDATE `forum` SET `name` = '$name', `opis` = '$opis' WHERE `id` = '$edit[id]'");
msg("Изменения успешно сохранены!");
}
}
err();
echo "<form method='post' action='?edit=$edit[id]&ok'>";
echo "Название раздела:<br/>";
echo "<input type='text' name='name' value='".htmlspecialchars($edit['name'])."'><br/>";
echo "Описание раздела:<br/>";
echo "<textarea name='opis'>".htmlspecialchars($edit[msg])."</textarea><br/>";
echo "<input type='submit' name='ok' value='Сохранить'><br/></form>";
echo "<a href='?'><div class='foot'><img src='/style/icons/str2.gif'/> Вернутся назад</div></a>";
include_once '../sys/inc/tfoot.php';
}
elseif(isset($_GET['delete']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `id` = '".intval($_GET['delete'])."'"),0)!=0 && isset($user) && $user['level']>2){
$delete=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '".intval($_GET['delete'])."'"));
if ($delete['id']==0)header("location:/index.php?");
$set['title']="Удаление - ".htmlspecialchars($delete['name'])."";
include_once '../sys/inc/thead.php';
title();
aut();
if(isset($_POST['ok']) && isset($_GET['ok'])){
mysql_query("DELETE FROM `forum` WHERE `id` = '$delete[id]'");
mysql_query("DELETE FROM `forum_razdel` WHERE `idforum` = '$delete[id]'");
mysql_query("DELETE FROM `forum_them` WHERE `idrazdel` = '$delete[id]'");
mysql_query("DELETE FROM `forum_kom` WHERE `id_them` = '$delete[id]'");
header("location:?");
}
elseif(isset($_POST['no']) && isset($_GET['ok']))header("Location:?id=$delete[id]");
echo "<form method='post' action='?delete=$delete[id]&ok'>";
echo "Подтвердите удаление раздела.<br/>";
echo "<input type='submit' name='ok' value='Удалить' style='width:30%'>";
echo "<input type='submit' name='no' value='Отменить' style='width:30%'>";
echo "</form>";
include_once '../sys/inc/tfoot.php';
}
$set['title']="Форум";
include_once '../sys/inc/thead.php';
title();
aut();
if (isset($_GET['up']) && isset($user) && $user['level']>2){
$up=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum` WHERE `id` = '".intval($_GET['up'])."' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `post` < '$up[post]' LIMIT 1"),0)!=0){
mysql_query("UPDATE `forum` SET `post` = '".($up['post'])."' WHERE `post` = '".($up['post']-1)."' LIMIT 1");
mysql_query("UPDATE `forum` SET `post` = '".($up['post']-1)."' WHERE `id` = '".intval($_GET['up'])."' LIMIT 1");
}
}
elseif (isset($_GET['down']) && isset($user) && $user['level']>2){
$down=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum` WHERE `id` = '".intval($_GET['down'])."' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `post` > '$down[post]' LIMIT 1"),0)!=0){
mysql_query("UPDATE `forum` SET `post` = '".($down['post'])."' WHERE `post` = '".($down['post']+1)."' LIMIT 1");
mysql_query("UPDATE `forum` SET `post` = '".($down['post']+1)."' WHERE `id` = '".intval($_GET['down'])."' LIMIT 1");
}
}
echo "<div style='border:1px solid skyblue;background:whitesmoke;display:block;padding:4px;text-align:center;border-radius:4px;'>Последние темы:</div>";
$t=mysql_query("SELECT * FROM `forum_them` ORDER BY `time` DESC LIMIT 3");
if ($t==0)echo "<div class='nav2'>Тем пока нету.</div>";
while($them=mysql_fetch_array($t)){
echo "<a href='them.php?id=$them[id]'><div style='border-bottom:1px dashed skyblue;background:whitesmoke;padding:4px;border-radius:4px;'><img src='img/them.png' alt='!'> ".htmlspecialchars($them['title'])." ";
echo "<span class='nav1'> ".mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_kom` WHERE `id_them` = '$them[id]'"),0)." </span> ".vremja($them['timecr'])."<br/>n";
echo "</div></a>";
}
echo "<div style='border:1px solid skyblue;background:whitesmoke;display:block;padding:4px;text-align:center;border-radius:4px;'>Разделы форума:</div>";
$q=mysql_query("SELECT * FROM `forum` ORDER BY `post` ASC");
if(mysql_num_rows($q)==0)echo "Список разделов пуст";
$i=1;
while($post=mysql_fetch_array($q)){
echo "<a href='razdel.php?id=$post[id]'><div class='nav2'><img src='img/r.png' alt='!'> ".htmlspecialchars($post['name'])."<br/>".htmlspecialchars($post['opis'])."";
if(isset($_GET['moderate']) && isset($user) && $user['level']>2)echo "<br><a href='?moderate&up=$post[id]'><img src='img/up.png' alt='up'></a><a href='?moderate&down=$post[id]'><img src='img/down.png' alt='down'></a><a href='?edit=$post[id]'><img src='img/set.png' alt='set'></a><a href='?delete=$post[id]'><img src='img/del.png' alt='del'></a>";
echo "</div></a>";
$i++;
}
if(isset($user) && $user['level']>2)echo "<a href='?add'><div class='foot'><img src='img/add.png' alt='add'> Добавить раздел</div></a><a href='?".(!isset($_GET['moderate'])?"moderate":null)."'><div class='foot'><img src='img/set.png' alt='set'> Управление</a></div>";
include_once '../sys/inc/tfoot.php';
?>