Вход Регистрация
Файл: modules/acp/downloads.php
Строк: 228
<?php

$module 
'downloads';
require_once 
'core/recursion.php';

switch (
$act) {    
    case 
'downloads';
        if (!
access('acp_downloads')) redirect('/acp');
    
        
$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'])
            {
                
$foldername str_to_en($name);
                
                
$exists DB::run()->querySingle("select `id` from `downloads_categs` where `parentid` = ? and (`name` = ? or `foldername` = ?);", array($parentid$name$foldername));
                if (!
$exists)
                {    
                    
$parent DB::run()->queryFetch("select `foldername` from `downloads_categs` where `id` = ?;", array($parentid));
                    
$path $parentid showfpath(getfpath($parentid)).$parent['foldername'].'/' FALSE;
                    
                    if (@
mkdir('uploads/downloads/'.$path.$foldername))
                    {
                        
$latestCateg DB::run()->queryFetch("select `order` from `downloads_categs` where `parentid` = ? order by `order` desc limit 1;", array($parentid));
                        
$order $latestCateg['order'] ? $latestCateg['order'] + 1;
                        
DB::run()->query("insert into `downloads_categs` set `parentid` = ?, `name` = ?, `foldername` = ?, `order` = ?;", array($parentid$name$foldername$order));
                        
redirect('/acp/downloads');
                    }
                    else
                    {
                        
$_SESSION['note'] = $lang['Error_creating_folder'];
                    }
                    
                }
                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 `downloads_categs` where `parentid` = 0 order by `order`;");
    
        
$config['newtitle'] = $lang['Downloads_Categories'];
        
$tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> &raquo; '.$lang['Downloads_Categories'];
        
$tpl['file'] = 'acp_downloads';
        require_once 
'core/header.php';
    break;
    
    case 
'downloads_editcateg':
        if (!
access('acp_downloads')) redirect('/acp');
    
        
$categ DB::run()->queryFetch("select * from `downloads_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 (
$parentid 0)
            {
                
$parent DB::run()->queryFetch("select * from `downloads_categs` where `id` = ?;", array($parentid));
                if (!
$parent['id']) $parentid 0;
            }
            
            
//if (!$parentid) $parentid = $categ['parentid'];
            
            
if ($name)
            {
                if (
mb_strlen($name$charset) <= $config['categsnamelen'])
                {        
                    
$foldername str_to_en($name);
                            
                    
$exists DB::run()->querySingle("select `id` from `downloads_categs` where `parentid` = ? and (`name` = ? or `foldername` = ?);", array($parentid$name$foldername));
                    if (!
$exists)
                    {
                        
$currentpath fpath($categ['id']).$categ['foldername'].'/';
                        
$newpath fpath($parentid).$parent['foldername'].'/'.$foldername.'/';
                        
                        if (@
rename('uploads/downloads/'.$currentpath'uploads/downloads/'.$newpath))
                        {
                            
DB::run()->query("update `downloads_categs` set `parentid` = ?, `name` = ?, `foldername` = ? where `id` = ?;", array($parentid$name$foldername$id));
                            
redirect('/acp/downloads');
                            
                        }
                        else
                        {
                            
$_SESSION['note'] = $lang['Unable_to_rename_or_move_folder'];
                        }    
                    }
                    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)';
                }
            }
                
            
$module 'downloads';
            require_once 
'core/recursion.php';
                
            
$config['newtitle'] = $lang['Edit_Category'];
            
$tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> &raquo; <a href="/acp/downloads">'.$lang['Downloads_Categories'].'</a> &raquo; '.$lang['Edit_Category'];
            
$tpl['file'] = 'acp_editcateg';
            require_once 
'core/header.php';
            
            
            
        }
        else
        {
            
redirect('/acp/downloads');
        }
    break;
    
    case 
'downloads_sortcateg':
        if (!
access('acp_downloads')) redirect('/acp');
        
        
$categ DB::run()->queryFetch("select * from `downloads_categs` where `id` = ?;", array($id));
        if (
$categ)
        {
            
$sort = isset($_GET['sort']) ? check($_GET['sort']) : FALSE;
            switch (
$sort)
            {
                case 
'up/':
                    
DB::run()->query("update `downloads_categs` set `order` = ? where `parentid` = ? and  `order` = ?;", array($categ['order'], $categ['parentid'], $categ['order'] - 1));
                    
DB::run()->query("update `downloads_categs` set `order` = ? where `id` = ?;", array($categ['order'] - 1$categ['id']));
                break;
    
                default:
                    
DB::run()->query("update `downloads_categs` set `order` = ? where `parentid` = ? and  `order` = ?;", array($categ['order'], $categ['parentid'], $categ['order'] + 1));
                    
DB::run()->query("update `downloads_categs` set `order` = ? where `id` = ?;", array($categ['order'] + 1$categ['id']));
                break;
    
            }
            
$redirect $categ['parentid'] ? '/acp/downloads/viewcateg'.$categ['parentid'] : '/acp/downloads';
            
redirect($redirect);
        }
        else
        {
            
redirect('/acp/downloads');
        }
    break;
    
    case 
'downloads_delcateg':
        
$categ DB::run()->queryFetch("select * from `".$module."_categs` where `id` = ?;", array($id));
        if (
$categ)
        {
            
$confirm = isset($_POST['confirm']) ? FALSE;
            if (
$confirm)
            {
                
$module 'downloads';
                
                
$totalSubCategs DB::run()->querySingle("select count(`id`) from `".$module."_categs` where `parentid` = ?;", array($categ['id']));
                if (!
$totalSubCategs)
                {
                    
$totalPosts DB::run()->querySingle("select count(`id`) from `".$module."_posts` where `categid` = ?;", array($categ['id']));
                    if (!
$totalPosts)
                    {
                        require_once 
'core/recursion.php';
                        
                        
$path fpath($categ['id']).$categ['foldername'].'/';
                        
                        if (@
rmdir('uploads/'.$module.'/'.$path) or !file_exists('uploads/'.$module.'/'.$path)) 
                        {
                            
DB::run()->query("delete from `".$module."_categs` where `id` = ?;", array($categ['id']));
                        }
                        else
                        {
                            
$_SESSION['note2'] = $lang['Unable_to_delete_folder'];
                        }
                    }
                    else
                    {
                        
$_SESSION['note2'] = $lang['Delete_all_files_and_subcategories_inside_category'];
                    }
                }
                else
                {
                    
$_SESSION['note2'] = $lang['Delete_all_files_and_subcategories_inside_category'];
                }
                
redirect('/acp/downloads');
            }
        
                        
            
$config['newtitle'] = $lang['Delete_Category'];
            
$tpl['title'] = '<a href="/acp">'.$lang['ACP'].'</a> &raquo; <a href="/acp/downloads">'.$lang['Downloads_Categories'].'</a> &raquo; '.$lang['Delete_Category'];
            
$tpl['file'] = 'confirm';
            require_once 
'core/header.php';
        }
        else
        {
            
redirect('/acp/downloads');
        }
    break;
    
    
    

}
Онлайн: 0
Реклама