Вход Регистрация
Файл: loads/inc/admin_act.php
Строк: 413
<?php

$path 
= (function_exists('iconv')) ? iconv('windows-1251', 'utf-8', $l) : $l;
$path = '/' . preg_replace('#^/+|/+$#i', null, $path) . '/';

if (
access('loads_file_import') && isset($_GET['act']) && $_GET['act'] == 'importcol' && isset($_POST['ok']) && isset($_POST['k_forms']) && $l != null) {

    
$k_forms = intval($_POST['k_forms']);
    for (
$i = 0; $i < $k_forms; $i++) {
        if (isset(
$_POST["file_$i"]) && isset($_POST["name_$i"]) && isset($_POST["opis_$i"])) {
            
$newfile = basename($_POST["file_$i"]);
            if (
is_file($dir_loads . '/' . $newfile)) {
                
$err = "Файл $newfile уже существует";
            } else {
                
$name = preg_replace('#.[^.]*$#i', NULL, $newfile); // имя файла без расширения
                
if (preg_match('#^[^/]*.[^/]*$#', $newfile) && !preg_match('#^.|.name$|.dirname$|.opis$|.99.99.name$|.99.99.jad$|.99.99.proiz$|.1.JPG$|.1.GIF$|.1.PNG$|.1.JPEG$|.2.JPG$|.2.GIF$|.2.PNG$|.2.JPEG$|.3.JPG$|.3.GIF$|.3.PNG$|.3.JPEG$|.name$|.txt$|.opis$|.html?$|.sql$|.ini$|.db$|.dat$#', $newfile) && @copy($_POST["file_$i"], $dir_loads . '/' . $newfile)) {
                    @
chmod($dir_loads . '/' . $newfile, 0777);
                    
$f = @fopen($dir_loads . '/' . $newfile . '.99.99.name', 'w');
                    if (
$_POST["name2"] != NULL) {
                        
$name = preg_replace('#[^]*$#i', NULL, $_POST["name2_$i"]);
                    } else {
                        
$name = preg_replace('#.[^.]*$#i', NULL, $newfile);
                    } 
// имя файла без расширения
                    
@fwrite($f, $name);
                    @
fclose($f);
                    @
chmod($dir_loads . '/' . $newfile . '.99.99.name', 0777);
                    @
mkdir($dir_l . '/' . $newfile, 0777);
                    if (
$_POST["opis_$i"] != NULL) {
                        
$f = @fopen($dir_loads . '/' . $newfile . '.opis', 'w');
                        @
fwrite($f, stripslashes(htmlspecialchars(esc($_POST["opis_$i"]))));
                        @
fclose($f);
                        @
chmod($dir_loads . '/' . $newfile . '.opis', 0777);
                    }


                    @
chmod($dir_loads . '/' . $newfile, 0777);
                    
$f = @fopen($dir_loads . '/' . $newfile . '.name', 'w');

                    if (
$_POST["name_$i"] != NULL) {
                        
$name = preg_replace('#.[^.]*$#i', NULL, $_POST["name_$i"]);
                    } else {
                        
$name = preg_replace('#.[^.]*$#i', NULL, $newfile);
                    }
                    @
fwrite($f, $name);
                    @
fclose($f);
                    @
chmod($dir_loads . '/' . $newfile . '.name', 0777);
                    
msg("Файл "$name" успешно импортирован");
                    
admin_log('Загруз-центр', 'Добавление файлов', "Импортирован файл '$name' в папку '" . dir_name($dir_loads) . "'");
                    
$size = filesize($dir_loads . '/' . $newfile);
                    
mysql_query("INSERT INTO `loads_list` (`name`, `id_user`, `size`,  `path`, `time`) values('" . mysql_real_escape_string($newfile) . "', '$user[id]', '$size', '" . mysql_real_escape_string($path) . "', '" . filectime($dir_loads . '/' . $newfile) . "')");



                    if (isset(
$_POST["scr1_$i"])) {
                        
$file_scr = preg_replace('#^.*/#i', NULL, $_POST["scr1_$i"]);
                        if (
preg_match('#.gif$|.jpe?g$|.png$#i', $file_scr)) {
                            
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                            
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $file_scr));
                            @
copy($_POST["scr1_$i"], $dir_loads . '/' . $newfile . '.1.' . $scr_ras);
                            @
chmod($dir_loads . '/' . $newfile . '.1.' . $scr_ras, 0777);
                        }
                    }
                    if (isset(
$_POST["scr2_$i"])) {
                        
$file_scr = preg_replace('#^.*/#i', NULL, $_POST["scr2_$i"]);
                        if (
preg_match('#.gif$|.jpe?g$|.png$#i', $file_scr)) {
                            
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                            
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $file_scr));
                            @
copy($_POST["scr2_$i"], $dir_loads . '/' . $newfile . '.2.' . $scr_ras);
                            @
chmod($dir_loads . '/' . $newfile . '.2.' . $scr_ras, 0777);
                        }
                    }
                    if (isset(
$_POST["scr3_$i"])) {
                        
$file_scr = preg_replace('#^.*/#i', NULL, $_POST["scr3_$i"]);
                        if (
preg_match('#.gif$|.jpe?g$|.png$#i', $file_scr)) {
                            
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                            
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $file_scr));
                            @
copy($_POST["scr3_$i"], $dir_loads . '/' . $newfile . '.3.' . $scr_ras);
                            @
chmod($dir_loads . '/' . $newfile . '.3.' . $scr_ras, 0777);
                        }
                    }
                } else
                    
$err[] = ($i + 1) . ') Невозможно импортировать файл по указанному пути';
            }
        }
    }
}

if (
access('loads_file_upload') && isset($_GET['act']) && $_GET['act'] == 'uploadcol' && isset($_POST['ok']) && isset($_POST['k_forms']) && $l != null) {
    
$k_forms = intval($_POST['k_forms']);
    for (
$i = 0; $i < $k_forms; $i++) {
        if (isset(
$_FILES["file_$i"]) && isset($_POST["name_$i"]) && !preg_match('#^.|.name$|.dirname$|.opis$|.99.99.name$|.99.99.jad$|.99.99.proiz$|.1.JPG$|.1.GIF$|.1.PNG$|.1.JPEG$|.2.JPG$|.2.GIF$|.2.PNG$|.2.JPEG$|.3.JPG$|.3.GIF$|.3.PNG$|.3.JPEG$|.php$|.sql$|.js$|.dat$|.db$#i', $_FILES["file_$i"]['name']) && filesize($_FILES["file_$i"]['tmp_name']) > 0 && isset($_POST["opis_$i"])) {
            
$newfile = basename($_FILES["file_$i"]['name']);
            if (
is_file($dir_loads . '/' . $newfile))
                
$err = "Файл " . $newfile . " уже существует";
            else {
                if (@
copy($_FILES["file_$i"]['tmp_name'], $dir_loads . '/' . $newfile)) {
                    if (@
mkdir($dir_l . '/' . $newfile, 0777)) {
                        
                    }
                    @
chmod($dir_l . '/' . $newfile, 0777);
                    
$f = @fopen($dir_loads . '/' . $newfile . '.99.99.name', 'w');
                    if (
$_POST["name2_$i"] != NULL)
                        
$name = preg_replace('#[^]*$#i', NULL, $_POST["name2_$i"]);
                    else
                        
$name = preg_replace('#.[^.]*$#i', NULL, $newfile); // имя файла без расширения
                    
@fwrite($f, $name);
                    @
fclose($f);
                    @
chmod($dir_loads . '/' . $newfile . '.99.99.name', 0777);
                    if (
$_POST["opis_$i"] != NULL) {
                        
$f = @fopen($dir_loads . '/' . $newfile . '.opis', 'w');
                        @
fwrite($f, stripslashes(htmlspecialchars(esc($_POST["opis_$i"]))));
                        @
fclose($f);
                        @
chmod($dir_loads . '/' . $newfile . '.opis', 0777);
                    }


                    @
chmod($dir_loads . '/' . $newfile, 0777);
                    
$f = @fopen($dir_loads . '/' . $newfile . '.name', 'w');
                    
$name = preg_replace('#.[^.]*$#i', NULL, $newfile); // имя файла без расширения
                    
@fwrite($f, preg_replace('#.[^.]*$#i', NULL, esc($_FILES["file_$i"]['name'])));
                    @
fclose($f);
                    @
chmod($dir_loads . '/' . $newfile . '.name', 0777);
                    
msg("Файл "" . stripslashes(htmlspecialchars(esc($_FILES["file_$i"]['name']))) . "" успешно выгружен");
                    
admin_log('Загруз-центр', 'Добавление файлов', "Выгружен файл '$newfile' в папку '" . dir_name($dir_loads) . "'");
                    
$size = filesize($dir_loads . '/' . $newfile);
                    
mysql_query("INSERT INTO `loads_list` (`name`, `id_user`, `size`,  `path`, `time`) values('" . mysql_real_escape_string($newfile) . "', '$user[id]', '$size', '" . mysql_real_escape_string($path) . "', '" . filectime($dir_loads . '/' . $newfile) . "')");
                }


                if (isset(
$_FILES["scr1_$i"]) && preg_match('#.gif$|.jpe?g$|.png$#i', $_FILES["scr1_$i"]['name']) && filesize($_FILES["scr1_$i"]['tmp_name']) > 0) {
                    
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                    
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $_FILES["scr1_$i"]['name']));
                    @
copy($_FILES["scr1_$i"]['tmp_name'], $dir_loads . '/' . $newfile . '.1.' . $scr_ras);
                    @
chmod($dir_loads . '/' . $newfile . '.1.' . $scr_ras, 0777);
                }
                if (isset(
$_FILES["scr2_$i"]) && preg_match('#.gif$|.jpe?g$|.png$#i', $_FILES["scr2_$i"]['name']) && filesize($_FILES["scr2_$i"]['tmp_name']) > 0) {
                    
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                    
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $_FILES["scr2_$i"]['name']));
                    @
copy($_FILES["scr2_$i"]['tmp_name'], $dir_loads . '/' . $newfile . '.2.' . $scr_ras);
                    @
chmod($dir_loads . '/' . $newfile . '.2.' . $scr_ras, 0777);
                }
                if (isset(
$_FILES["scr3_$i"]) && preg_match('#.gif$|.jpe?g$|.png$#i', $_FILES["scr3_$i"]['name']) && filesize($_FILES["scr3_$i"]['tmp_name']) > 0) {
                    
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                    
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $_FILES["scr3_$i"]['name']));
                    @
copy($_FILES["scr3_$i"]['tmp_name'], $dir_loads . '/' . $newfile . '.3.' . $scr_ras);
                    @
chmod($dir_loads . '/' . $newfile . '.3.' . $scr_ras, 0777);
                }
            }
        } else {
            
$err = lang('Невозможно выгрузить файл');
        }
    }
}


if (
access('loads_file_import') && isset($_GET['act']) && $_GET['act'] == 'import' && isset($_POST['ok']) && $l != null) {
    if (isset(
$_POST["file"]) && isset($_POST["name"]) && isset($_POST["opis"])) {
        
$newfile = basename($_POST["file"]);
        if (
is_file($dir_loads . '/' . $newfile)) {
            
$err = "Файл $newfile уже существует";
        } else {
            
$name = preg_replace('#.[^.]*$#i', NULL, $newfile); // имя файла без расширения
            
if (preg_match('#^[^/]*.[^/]*$#', $newfile) && !preg_match('#^.|.name$|.dirname$|.opis$|.99.99.name$|.99.99.jad$|.99.99.proiz$|.1.JPG$|.1.GIF$|.1.PNG$|.1.JPEG$|.2.JPG$|.2.GIF$|.2.PNG$|.2.JPEG$|.3.JPG$|.3.GIF$|.3.PNG$|.3.JPEG$|.php|.name$|.txt$|.opis$|.html?$|.sql$|.ini$|.db$|.dat$#', $newfile) && @copy($_POST["file"], $dir_loads . '/' . $newfile)) {
                @
chmod($dir_loads . '/' . $newfile, 0777);
                
$f = @fopen($dir_loads . '/' . $newfile . '.99.99.name', 'w');
                if (
$_POST["name2"] != NULL)
                    
$name = preg_replace('#[^]*$#i', NULL, $_POST["name2"]);
                else
                    
$name = preg_replace('#.[^.]*$#i', NULL, $newfile); // имя файла без расширения
                
@fwrite($f, $name);
                @
fclose($f);
                @
chmod($dir_loads . '/' . $newfile . '.99.99.name', 0777);
                @
mkdir($dir_l . '/' . $newfile, 0777);
                if (
$_POST["opis"] != NULL) {
                    
$f = @fopen($dir_loads . '/' . $newfile . '.opis', 'w');
                    @
fwrite($f, stripslashes(htmlspecialchars(esc($_POST["opis"]))));
                    @
fclose($f);
                    @
chmod($dir_loads . '/' . $newfile . '.opis', 0777);
                }
                
$f = @fopen($dir_loads . '/' . $newfile . '.name', 'w');
                if (
$_POST["name"] != NULL)
                    
$name = preg_replace('#[^]*$#i', NULL, $_POST["name"]);
                else
                    
$name = preg_replace('#.[^.]*$#i', NULL, $newfile); // имя файла без расширения
                
@fwrite($f, $name);
                @
fclose($f);
                @
chmod($dir_loads . '/' . $newfile . '.name', 0777);
                
msg("Файл $newfile успешно импортирован");
                
admin_log('Загруз-центр', 'Добавление файлов', "Импортирован файл '$name' в папку '" . dir_name($dir_loads) . "'");
                
$size = filesize($dir_loads . '/' . $newfile);
                
mysql_query("INSERT INTO `loads_list` (`name`, `id_user`, `size`,  `path`, `time`) values('" . mysql_real_escape_string($newfile) . "', '$user[id]', '$size', '" . mysql_real_escape_string($path) . "', '" . filectime($dir_loads . '/' . $newfile) . "')");

                if (isset(
$_POST["scr1"])) {
                    
$file_scr = preg_replace('#^.*/#i', NULL, $_POST["scr1"]);
                    if (
preg_match('#.gif$|.jpe?g$|.png$#i', $file_scr)) {
                        
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                        
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $file_scr));
                        @
copy($_POST["scr1"], $dir_loads . '/' . $newfile . '.1.' . $scr_ras);
                        @
chmod($dir_loads . '/' . $newfile . '.1.' . $scr_ras, 0777);
                    }
                }
                if (isset(
$_POST["scr2"])) {
                    
$file_scr = preg_replace('#^.*/#i', NULL, $_POST["scr2"]);
                    if (
preg_match('#.gif$|.jpe?g$|.png$#i', $file_scr)) {
                        
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                        
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $file_scr));
                        @
copy($_POST["scr2"], $dir_loads . '/' . $newfile . '.2.' . $scr_ras);
                        @
chmod($dir_loads . '/' . $newfile . '.2.' . $scr_ras, 0777);
                    }
                }
                if (isset(
$_POST["scr3"])) {
                    
$file_scr = preg_replace('#^.*/#i', NULL, $_POST["scr3"]);
                    if (
preg_match('#.gif$|.jpe?g$|.png$#i', $file_scr)) {
                        
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                        
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $file_scr));
                        @
copy($_POST["scr3"], $dir_loads . '/' . $newfile . '.3.' . $scr_ras);
                        @
chmod($dir_loads . '/' . $newfile . '.3.' . $scr_ras, 0777);
                    }
                }
                if (isset(
$_POST['dop_file']) && $_POST['dop_file'] == 1) {
                    
header("Refresh: 1; url=?d=$l&act=files_add_im&f=$newfile&page=$page");
                }
            } else {
                
$err = lang('Невозможно импортировать файл по указанному пути');
            }
        }
    }
}

if (
access('loads_file_upload') && isset($_GET['act']) && $_GET['act'] == 'upload' && isset($_POST['ok']) && $l != null) {
    if (isset(
$_FILES["file"]) && isset($_POST["name"]) && !preg_match('#^.|.name$|.dirname$|.opis$|.99.99.name$|.99.99.jad$|.99.99.proiz$|.1.JPG$|.1.GIF$|.1.PNG$|.1.JPEG$|.2.JPG$|.2.GIF$|.2.PNG$|.2.JPEG$|.3.JPG$|.3.GIF$|.3.PNG$|.3.JPEG$|.sql$|.js$|.dat$|.db$#i', $_FILES["file"]['name']) && filesize($_FILES["file"]['tmp_name']) > 0 && isset($_POST["opis"])) {
        
$newfile = esc(stripcslashes(htmlspecialchars($_FILES['file']['name'])));
        if (
is_file($dir_loads . '/' . $newfile))
            
$err = "Файл $newfile уже существует";
        else {
            if (@
copy($_FILES["file"]['tmp_name'], $dir_loads . '/' . $newfile)) {
                if (@
mkdir($dir_l . '/' . $newfile, 0777)) {
                    
                }
                @
chmod($dir_l . '/' . $newfile, 0777);
                
$f = @fopen($dir_loads . '/' . $newfile . '.99.99.name', 'w');
                if (
$_POST["name2"] != NULL)
                    
$name = preg_replace('#[^]*$#i', NULL, $_POST["name2"]);
                else
                    
$name = preg_replace('#.[^.]*$#i', NULL, $newfile); // имя файла без расширения
                
@fwrite($f, $name);
                @
fclose($f);
                @
chmod($dir_loads . '/' . $newfile . '.99.99.name', 0777);

                if (
$_POST["opis"] != NULL) {
                    
$f = @fopen($dir_loads . '/' . $newfile . '.opis', 'w');
                    @
fwrite($f, stripslashes(htmlspecialchars(esc($_POST["opis"]))));
                    @
fclose($f);
                    @
chmod($dir_loads . '/' . $newfile . '.opis', 0777);
                }
                @
chmod($dir_loads . '/' . $newfile, 0777);
                
$f = @fopen($dir_loads . '/' . $newfile . '.name', 'w');
                if (
$_POST["name"] != NULL)
                    
$name = preg_replace('#[^]*$#i', NULL, $_POST["name"]);
                else
                    
$name = preg_replace('#.[^.]*$#i', NULL, $newfile); // имя файла без расширения
                
@fwrite($f, $name);
                @
fclose($f);
                @
chmod($dir_loads . '/' . $newfile . '.name', 0777);
                
msg("Файл $newfile успешно выгружен");
                
admin_log('Загруз-центр', 'Добавление файлов', "Выгружен файл '$newfile' в папку '" . dir_name($dir_loads) . "'");
                
$size = filesize($dir_loads . '/' . $newfile);
                
mysql_query("INSERT INTO `loads_list` (`name`, `id_user`, `size`,  `path`, `time`) values('" . mysql_real_escape_string($newfile) . "', '$user[id]', '$size', '" . mysql_real_escape_string($path) . "', '" . filectime($dir_loads . '/' . $newfile) . "')");
            }


            if (isset(
$_FILES["scr1"]) && preg_match('#.gif$|.jpe?g$|.png$#i', $_FILES["scr1"]['name']) && filesize($_FILES["scr1"]['tmp_name']) > 0) {
                
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $_FILES["scr1"]['name']));
                @
copy($_FILES["scr1"]['tmp_name'], $dir_loads . '/' . $newfile . '.1.' . $scr_ras);
                @
chmod($dir_loads . '/' . $newfile . '.1.' . $scr_ras, 0777);
            }
            if (isset(
$_FILES["scr2"]) && preg_match('#.gif$|.jpe?g$|.png$#i', $_FILES["scr2"]['name']) && filesize($_FILES["scr2"]['tmp_name']) > 0) {
                
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $_FILES["scr2"]['name']));
                @
copy($_FILES["scr2"]['tmp_name'], $dir_loads . '/' . $newfile . '.2.' . $scr_ras);
                @
chmod($dir_loads . '/' . $newfile . '.2.' . $scr_ras, 0777);
            }
            if (isset(
$_FILES["scr3"]) && preg_match('#.gif$|.jpe?g$|.png$#i', $_FILES["scr3"]['name']) && filesize($_FILES["scr3"]['tmp_name']) > 0) {
                
$ras = strtolower(preg_replace('#^.*.#i', NULL, $newfile));
                
$scr_ras = strtoupper(preg_replace('#^.*.#i', NULL, $_FILES["scr3"]['name']));
                @
copy($_FILES["scr3"]['tmp_name'], $dir_loads . '/' . $newfile . '.3.' . $scr_ras);
                @
chmod($dir_loads . '/' . $newfile . '.3.' . $scr_ras, 0777);
            }
        }
        if (isset(
$_POST['dop_file']) && $_POST['dop_file'] == 1) {
            
header("Refresh: 1; url=?d=$l&act=files_add_up&f=$newfile");
        }
    } else {
        
$err = lang('Невозможно выгрузить файл');
    }
}




if (
access('loads_dir_delete') && isset($_GET['act']) && $_GET['act'] == 'delete_ok' && isset($_GET['ok']) && $l != NULL) {

    if (@
delete_dir($dir_loads)) {
        
$l = preg_replace("#^../sys/loads/files#", NULL, $dir_loads);
        
$path = (function_exists('iconv')) ? iconv('windows-1251', 'utf-8', $l) : $l;
        
$path = preg_replace('#^/*|/*$#i', '/', $path);
        
$dir_loads = preg_replace('#/[^/]*$#', NULL, $dir_loads);
        
$l = preg_replace("#^../sys/loads/files#", NULL, $dir_loads);

        if (@
delete_dir($dir_l)) {
            
$l = preg_replace("#^../sys/loads/files_dop#", NULL, $dir_l);
            
$path = (function_exists('iconv')) ? iconv('windows-1251', 'utf-8', $l) : $l;
            
$path = preg_replace('#^/*|/*$#i', '/', $path);
            
$dir_l = preg_replace('#/[^/]*$#', NULL, $dir_l);
            
$l = preg_replace("#^../sys/loads/files_dop#", NULL, $dir_l);
        }

        
admin_log('Загруз-центр', 'Папки', "Удаление папки '$l'");
        
mysql_query("DELETE FROM `loads_list` WHERE `path` LIKE '" . mysql_real_escape_string($path) . "%'");
        
msg('Папка успешно удалена');
    } else {
        
$err = lang('Невозможно удалить папку');
    }
}



if (
access('loads_dir_mesto') && isset($_GET['act']) && $_GET['act'] == 'mesto' && isset($_GET['ok']) && isset($_POST['path']) && $l != NULL) {
    if (
$_POST['path'] == NULL) {
        
$err = lang("Не выбран корневой путь");
    } else {
        
$new_dir = urldecode($_POST['path']) . '/' . preg_replace('#^.*/#', NULL, $dir_loads);
        
$new_dirr = urldecode($_POST['pathh']) . '/' . preg_replace('#^.*/#', NULL, $dir_l);

        if (@
rename($dir_loads, $new_dir)) {
            
$dir_loads = $new_dir;
            
$l = preg_replace("#^../sys/loads/files/#", NULL, $dir_loads);

            if (@
rename($dir_l, $new_dirr)) {
                
$dir_l = $new_dirr;
                
$l = preg_replace("#^../sys/loads/files_dop/#", NULL, $dir_l);
            }
            
msg('Папка успешно перемещена');
            
admin_log('Загруз-центр', 'Папки', "Перемещение папки '$l'");

            
$path2 = (function_exists('iconv')) ? iconv('windows-1251', 'utf-8', $l) : $l;
            
$path2 = '/' . preg_replace('#^/+|/+$#i', null, $path2) . '/';
            
$q = mysql_query("SELECT `path` FROM `loads_list` WHERE `path` LIKE '" . mysql_real_escape_string($path) . "%'");
            while (
$path_1 = mysql_fetch_assoc($q)) {
                
mysql_query("UPDATE `loads_list` SET `path` = '" . mysql_real_escape_string(str_replace($path, $path2, $path_1['path'])) . "' WHERE `path` = '" . mysql_real_escape_string($path_1['path']) . "'");
            }
        } else {
            
$err = lang("Невозможно переместить папку");
        }
    }
    @
unlink($dir_loads . '/.k_files');
}

if (
access('loads_dir_rename') && isset($_GET['act']) && $_GET['act'] == 'rename' && isset($_GET['ok']) && isset($_POST['name']) && $l != NULL) {
    if (
$_POST['name'] == NULL) {
        
$err = lang("Введите название папки");
    } elseif (!
preg_match("#^([A-zА-я0-9-_() ])+$#ui", $_POST['name'])) {
        
$err[] = lang('В названии присутствуют запрещенные символы');
    } elseif (
preg_match("#(^ )|( $)#ui", $_POST['name'])) {
        
$err[] = lang('В названии запрещено использовать пробел в начале и конце');
    } else {
        
$newdir_serv = retranslit(esc($_POST['name'], 1));

        
$new_dir = preg_replace('#/[^/]*$#', NULL, $dir_loads) . '/' . $newdir_serv;
        
$new_dirr = preg_replace('#/[^/]*$#', NULL, $dir_l) . '/' . $newdir_serv;
        if (@
rename($dir_loads, $new_dir))
            if (@
rename($dir_l, $new_dirr)) {
                @
chmod($dir_loads, 0777);
                
$dir_loads = $new_dir;
                
$dir_l = $new_dirr;
                
$l = preg_replace("#^../sys/loads/files/#", NULL, $dir_loads);
                
$newdir_loads = esc($_POST['name'], 1);
                
$newdir_loads = preg_replace('#^(([0-9]{1,3}))_(.*)#', '\2', $newdir_loads);
                
$path2 = (function_exists('iconv')) ? iconv('windows-1251', 'utf-8', $l) : $l;
                
$path2 = '/' . preg_replace('#^/+|/+$#i', null, $path2) . '/';
                
admin_log('Загруз-центр', 'Папки', "Переименование папки $newdir_loads в " . esc($_POST['name'], 1));
                
$q = mysql_query("SELECT `path` FROM `loads_list` WHERE `path` LIKE '" . mysql_real_escape_string($path) . "%'");
                while (
$path_1 = mysql_fetch_assoc($q)) {
                    
mysql_query("UPDATE `loads_list` SET `path` = '" . mysql_real_escape_string(str_replace($path, $path2, $path_1['path'])) . "' WHERE `path` = '" . mysql_real_escape_string($path_1['path']) . "'");
                }

                
$q = mysql_query("SELECT `path` FROM `loads_komm` WHERE `path` LIKE '" . mysql_real_escape_string($path) . "%'");
                while (
$path_1 = mysql_fetch_assoc($q)) {
                    
mysql_query("UPDATE `loads_komm` SET `path` = '" . mysql_real_escape_string(str_replace($path, $path2, $path_1['path'])) . "' WHERE `path` = '" . mysql_real_escape_string($path_1['path']) . "'");
                }

                
$q = mysql_query("SELECT `path` FROM `loads_rating` WHERE `path` LIKE '" . mysql_real_escape_string($path) . "%'");
                while (
$path_1 = mysql_fetch_assoc($q)) {
                    
mysql_query("UPDATE `loads_rating` SET `path` = '" . mysql_real_escape_string(str_replace($path, $path2, $path_1['path'])) . "' WHERE `path` = '" . mysql_real_escape_string($path_1['path']) . "'");
                }
                
$q = mysql_query("SELECT `path` FROM `loads_dop` WHERE `path` LIKE '" . mysql_real_escape_string($path) . "%'");
                while (
$path_1 = mysql_fetch_assoc($q)) {
                    
mysql_query("UPDATE `loads_dop` SET `path` = '" . mysql_real_escape_string(str_replace($path, $path2, $path_1['path'])) . "' WHERE `path` = '" . mysql_real_escape_string($path_1['path']) . "'");
                }

                if (
$f = @fopen($dir_loads . '/.dirname', 'w')) {
                    @
fwrite($f, $newdir_loads);
                    
fclose($f);
                    @
chmod($dir_loads . '/.dirname', 0777);

                    
$_SESSION['message'] = lang('Изменения сохранены');
                } else {
                    
$err = lang("Невозможно задать название папки");
                }
            } else {
                
$err = lang("Невозможно переименовать");
            }
    }
}

if (
access('loads_dir_create') && isset($_GET['act']) && $_GET['act'] == 'mkdir' && isset($_GET['ok']) && isset($_POST['name'])) {

    if (
$_POST['name'] == NULL) {
        
$err = lang("Введите название папки");
    } elseif (!
preg_match("#^([A-zА-я0-9-_() ])+$#ui", $_POST['name'])) {
        
$err[] = lang('В названии присутствуют запрещенные символы');
    } elseif (
preg_match("#(^ )|( $)#ui", $_POST['name'])) {
        
$err[] = lang('В названии запрещено использовать пробел в начале и конце');
    } else {
        
$newdir_serv = retranslit(esc($_POST['name'], 1));

        if (@
mkdir(H . "sys/loads/files_dop/" . $l . '/' . $newdir_serv, 0777))
            ;
        if (@
mkdir($dir_loads . '/' . $newdir_serv, 0777)) {
            @
chmod($dir_loads . '/' . $newdir_serv, 0777);

            
$_SESSION['message'] = lang('Папка успешно создана');
            
$newdir_loads = esc($_POST['name'], 1);
            
$newdir_loads = preg_replace('#^(([0-9]{1,3}))_(.*)#', '\2', $newdir_loads);
            if (
$f = @fopen($dir_loads . '/' . $newdir_serv . '/.dirname', 'w')) {
                @
fwrite($f, $newdir_loads);
                
fclose($f);
                @
chmod($dir_loads . '/' . $newdir_serv . '/.dirname', 0777);

                
admin_log('Загруз-центр', 'Папки', "Создание папки '$newdir_loads' в папке '" . dir_name($dir_loads) . "'");
            } else {
                
$err = lang("Невозможно задать название папки");
            }
        } else {
            
$err = lang("Невозможно создать папку");
        }
    }
}
?>
Онлайн: 2
Реклама