Файл: modules/acp/forum.php
Строк: 165
<?php
$module = 'forum';
require_once 'core/recursion.php';
switch ($act) {
case 'forum';
if (access('acp_forum'))
{
$name = isset($_POST['name']) ? check($_POST['name']) : FALSE;
$parentid = isset($_POST['parentid']) ? abs(intval($_POST['parentid'])) : 0;
if ($name)
{
if (mb_strlen($name, $charset) <= $config['categsnamelen'])
{
$exists = DB::run()->querySingle("select `id` from `forum_categs` where `parentid` = ? and `name` = ?;", array($parentid, $name));
if (!$exists)
{
$latestCateg = DB::run()->queryFetch("select `order` from `forum_categs` where `parentid` = ? order by `order` desc limit 1;", array($parentid));
$order = $latestCateg['order'] ? $latestCateg['order'] + 1 : 1;
DB::run()->query("insert into `forum_categs` set `parentid` = ?, `name` = ?, `order` = ?;", array($parentid, $name, $order));
redirect('/acp/forum');
}
else
{
$_SESSION['note'] = $lang['The_category_you_are_trying_to_create_already_exists'];
}
}
else
{
$_SESSION['note'] = $lang['The_name_exceeds_the_maximum_number_of_characters_allowed'].' (25)';
}
}
$config['newtitle'] = $lang['Forum_Categories'];
$tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> » '.$lang['Forum_Categories'];
$tpl['file'] = 'acp_forum';
require_once 'core/header.php';
}
else
{
redirect('/acp');
}
break;
case 'forum_editcateg':
if (!access('acp_forum')) redirect('/acp');
$categ = DB::run()->queryFetch("select * from `forum_categs` where `id` = ?;", array($id));
if ($categ)
{
$name = isset($_POST['name']) ? check($_POST['name']) : FALSE;
$parentid = isset($_POST['parentid']) ? abs(intval($_POST['parentid'])) : 0;
if ($name)
{
if ($parentid != $categ['id'])
{
$exists = DB::run()->querySingle("select `id` from `forum_categs` where `parentid` = ? and `name` = ?;", array($parentid, $name));
if (!$exists)
{
DB::run()->query("update `forum_categs` set `parentid` = ?, `name` = ? where `id` = ?;", array($parentid, $name, $id));
$redirect = $categ['parentid'] ? '/viewcateg'.$categ['parentid'] : FALSE;
redirect('/acp/forum'.$redirect);
}
else
{
$_SESSION['note'] = $lang['The_category_you_are_trying_to_create_already_exists'];
}
}
else
{
$_SESSION['note'] = $lang['Unable_to_rename_or_move_folder'];
}
}
$module = 'forum';
require_once 'core/recursion.php';
$config['newtitle'] = $lang['Edit_Category'];
$tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> » <a href="/acp/forum">'.$lang['Forum_Categories'].'</a> '.showPath(getPath($categ['id']), '/acp').' » '.$lang['Edit_Category'];
$tpl['file'] = 'acp_editcateg';
require_once 'core/header.php';
}
else
{
redirect('/acp/forum');
}
break;
case 'forum_sortcateg':
$categ = DB::run()->queryFetch("select * from `forum_categs` where `id` = ?;", array($id));
if ($categ)
{
$sort = isset($_GET['sort']) ? check($_GET['sort']) : FALSE;
switch ($sort)
{
case 'up':
DB::run()->query("update `forum_categs` set `order` = ? where `parentid` = ? and `order` = ?;", array($categ['order'], $categ['parentid'], $categ['order'] - 1));
DB::run()->query("update `forum_categs` set `order` = ? where `id` = ?;", array($categ['order'] - 1, $categ['id']));
break;
default:
DB::run()->query("update `forum_categs` set `order` = ? where `parentid` = ? and `order` = ?;", array($categ['order'], $categ['parentid'], $categ['order'] + 1));
DB::run()->query("update `forum_categs` set `order` = ? where `id` = ?;", array($categ['order'] + 1, $categ['id']));
break;
}
}
redirect('/acp/forum');
break;
case 'forum_viewcateg':
if (!access('acp_forum')) redirect('/acp');
$module = 'forum';
require_once 'core/recursion.php';
$categ = DB::run()->queryFetch("select * from `forum_categs` where `id` = ?;", array($id));
if ($categ)
{
$name = isset($_POST['name']) ? check($_POST['name']) : FALSE;
if ($name)
{
$exists = DB::run()->querySingle("select count(`id`) from `forum_categs` where `parentid` = ? and `name` = ?;", array($categ['id'], $name));
if (!$exists)
{
$latestCateg = DB::run()->queryFetch("select `order` from `forum_categs` where `parentid` = ? order by `id` desc;", array($categ['id']));
$order = $latestCateg['order'] ? $latestCateg['order'] + 1 : 1;
DB::run()->query("insert into `forum_categs` set `parentid` = ?, `name` = ?, `order` = ?;", array($categ['id'], $name, $order));
redirect('/acp/forum/viewcateg'.$categ['id']);
}
else
{
$_SESSION['note'] = $lang['The_category_you_are_trying_to_create_already_exists'];
}
}
$totalSubCateg = DB::run()->querySingle("select count(`id`) from `forum_categs` where `parentid` = ?;", array($categ['id']));
if ($totalSubCateg)
{
$query = DB::run()->query("select * from `forum_categs` where `parentid` = ? ORDER BY `order`", array($categ['id']));
}
$totalThreads = DB::run()->querySingle("select count(`id`) from `forum_threads` where `categid` = ?;", array($categ['id']));
$config['newtitle'] = $categ['name'];
$tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> » <a href="/acp/forum">'.$lang['Forum_Categories'].'</a> '.showPath(getPath($categ['id']), '/acp').' » '.$categ['name'];
$tpl['file'] = 'acp_forum_viewcateg';
require_once 'core/header.php';
}
else
{
redirect('/acp/forum');
}
break;
case 'forum_delcateg':
if (!access('acp_forum')) redirect('/acp');
$categ = DB::run()->queryFetch("select * from `forum_categs` where `id` = ?;", array($id));
if ($categ)
{
$confirm = isset($_POST['confirm']) ? 1 : FALSE;
if ($confirm)
{
$totalSubcategs = DB::run()->querySingle("select count(`id`) from `forum_categs` where `parentid` = ?;", array($categ['id']));
if (!$totalSubcategs)
{
$queryThreads = DB::run()->query("select `id` from `forum_threads` where `categid` = ?;", array($categ['id']));
while ($thread = $queryThreads->Fetch())
{
DB::run()->query("delete from `forum_posts` where `threadid` = ?;", array($thread['id']));
DB::run()->query("delete from `forum_threads_visits` where `threadid` = ?;", array($thread['id']));
DB::run()->query("delete from `forum_threads` where `id` = ?;", array($thread['id']));
}
DB::run()->query("delete from `forum_categs` where `id` = ?;", array($categ['id']));
}
else
{
$_SESSION['note2'] = $lang['Delete_all_subcategories_inside_category'];
}
redirect('/acp/forum');
}
$config['newtitle'] = $lang['Forum'];
$tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> » <a href="/acp/forum">'.$lang['Forum_Categories'].'</a> » '.$lang['Confirm_deletion'];
$tpl['file'] = 'confirm';
require_once 'core/header.php';
}
else
{
redirect('/acp/downloads');
}
break;
}