Файл: modules/acp/blogs.php
Строк: 88
<?php 
/*
 * @author mides <Mike Osendowski>
 * @link http://midwm.org
 * @copyright 2011-2014
*/
switch ($act) {
    case 'blogs':
        if (access('acp_blogs'))
        {
            $name = isset($_POST['name']) ? check($_POST['name']) : FALSE;
            if ($name)
            {
                if (mb_strlen($name, 'utf-8') <= 25)
                {
                    $exists = DB::run()->querySingle("select `id` from `blogs_categs` where `name` = ?;", array($name));
                    if (!$exists)
                    {
                        DB::run()->query("insert into `blogs_categs` set `name` = ?;", array($name));
                        redirect('/acp/blogs');
                    }
                    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)';
                }
            }
            $query = DB::run()->query("select * from `blogs_categs` order by `name`;");
            $config['newtitle'] = $lang['Blog_Categories'];
            $tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> » '.$lang['Blog_Categories'];
            $tpl['file'] = 'acp_blogs';
            require_once 'core/header.php';
        }
        else
        {
            redirect('/acp');
        }
        break;
    case 'blogs_editcateg':
        if (!access('acp_blogs')) redirect('/acp');
        
        $module = 'blogs';
        $categ = DB::run()->queryFetch("select * from `blogs_categs` where `id` = ?;", array($id));
        if ($categ)
        {
            $name = isset($_POST['name']) ? check($_POST['name']) : FALSE;
            $order = isset($_POST['order']) ? check($_POST['order']) : FALSE;
            if ($name)
            {
                $exists = DB::run()->querySingle("select `id` from `blogs_categs` where `name` = ?;", array($name));
                if (!$exists)
                {
                    DB::run()->query("update `blogs_categs` set `name` = ? where `id` = ?;", array($name, $id));
                    redirect('/acp/blogs');
                }
                else
                {
                    $_SESSION['note'] = $lang['The_category_you_are_trying_to_create_already_exists'];
                }
            }
        }
        else
        {
            redirect('/acp/blogs');
        }
        $config['newtitle'] = $lang['Edit_Category'];
        $tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> » <a href="/acp/blogs">'.$lang['Blog_Categories'].'</a>';
        $tpl['file'] = 'acp_editcateg';
        require_once 'core/header.php';
        break;
    case 'blogs_delcateg':
        if (!access('acp_blogs')) redirect('/acp');
        $data = DB::run()->queryFetch("select * from `blogs_categs` where `id` = ?;", array($id));
        if ($data)
        {
            $confirm = isset($_POST['confirm']) ? 1 : FALSE;
                
            if ($confirm)
            {
                $query = DB::run()->query("select * from `blogs_content` where `categid` = ?;", array($data['id']));
                while ($content = $query->Fetch())
                {
                    $checkMulticateg = DB::run()->querySingle("select count(`id`) from `blogs_content` where `postid` = ?;", array($content['postid']));
                    if ($checkMulticateg == 1)
                    {
                        DB::run()->query("delete from `blogs_posts` where `id` = ?;", array($content['postid']));
                    }
                    DB::run()->query("delete from `blogs_content` where `id` = ?;", array($content['id']));
                }
                DB::run()->query("delete from `blogs_categs` where `id` = ?;", array($id));
                redirect('/acp/blogs');
            }
                
            $config['newtitle'] = $lang['Confirm_deletion'];
            $tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> » <a href="/acp/blogs">'.$lang['Blog_Categories'].'</a>';
            $tpl['file'] = 'confirm';
            require_once 'core/header.php';
        }
        else
        {
            redirect('/acp/blogs');
        }
    break;    
        
}