Вход Регистрация
Файл: crons/backup.php
Строк: 505
<?php

$archivename 
= "";
$stoppath = "";
$rassh = "";
$maxsize = "";

$site_root = $path;
$this_script = $_SERVER["SCRIPT_FILENAME"];
$this_script_dir = dirname($this_script);

$cwd = getcwd();
$cwd = preg_replace('/\+|/+/', '/', $cwd);

$wspl1 = chr(119).chr(105).chr(115).chr(112).chr(108);
$wspl2 = chr(119).chr(105).chr(36).chr(112).chr(108);

$wsfn1 = chr(119).chr(105).chr(115).chr(102).chr(110);
$wsfn2 = chr(119).chr(105).chr(36).chr(102).chr(110);

if(
$stoppath == "")
    
$exludethisdir=false; // - не эти каталоги TRUE/FALSE
else
    
$exludethisdir=true; // - не эти каталоги TRUE/FALSE

$exludethisdirmode = $stoppath;

if(
$rassh == "")
    
$onlythisext=false; // - только с расширением TRUE/FALSE
else
    
$onlythisext=true; 
$onlythisextmode = $rassh;

if(
$maxsize == "")
    
$onlyfilesize=false; // - не более байт TRUE/FALSE
else
    
$onlyfilesize=true;
$onlyfilesizemode = $maxsize;

$exludesubdirs=false; // - не обрабатывать подкаталоги

switch ($dobu)
{
    case 
"2":
        
$path_result = decompress($path, "../".$bufile);
        die(
$path_result);
      break;
    default:
        die(
"0");
        break;
}

/*decompress*/
function decompress($path, $selarchive) {
        global 
$conf, $site_root, $wspl1, $wspl2, $wsfn1, $wsfn2, $fileoverwrite, $filegroup_list, $filegroup_activated, $filegroup_other_activated, $output, $filegroup_perms, $filegroup_other_perms, $new_dir_perms, $new_dir_perms_on, $uninstlog, $nolog, $neverlog;

        
$filename = $selarchive;

        if (!
file_exists($filename)) {
                return 
"0";
        } else {

        
$site_root_md = explode('/', $site_root);
        
$site_root_mk = '';
        for (
$site_root_md_cc = 0; $site_root_md_cc < count($site_root_md); $site_root_md_cc++) {
                
$site_root_mk .= $site_root_md[$site_root_md_cc].'/';
                if (@!
file_exists($site_root_mk)) {
                        if (
$new_dir_perms_on) {
                                if (@
mkdir($site_root_mk, octdec('0'.$new_dir_perms))) {
                                        
$output .= '<span class="filedir">'.$conf['lang_makedir'].': ...'.substr($site_root_mk, -70).'</span><br />';
                                        if (
$nolog == FALSE) {
                                                
$uninstlog .= $site_root_mk."n";
                                                }
                                        }
                                } else {
                                        if (@
mkdir($site_root_mk)) {
                                                
$output .= '<span class="filedir">'.$conf['lang_makedir'].': ...'.substr($site_root_mk, -70).'</span><br />';
                                                if (
$nolog == FALSE) {
                                                        
$uninstlog .= $site_root_mk."n";
                                                        }
                                                }
                                        }
                        }
        }

        
$fh = gzopen($filename, 'rb');
        
$unp = '';
        while (!
feof($fh)) {
                
$unp .= gzread($fh, 5242880);
                }
        
gzclose($fh);

        
$error_in_func = false;
        if (
substr($unp, 0, 5) !== chr(119).chr(105).chr(115).chr(112).chr(108)) {
                
//error($conf['lang_notsupportedarchive']);
                
$error_in_func = true;
                }

        
$splarr = explode($wspl1, $unp);

        
$stored_unp_path = 'winull';

        if (!
$error_in_func) {
        foreach (
$splarr as $splarrk => $splarrv) {
                if (
strlen($splarrv) < 1) {continue;}
                list (
$fileunp, $permsunp, $contentsunp) = explode($wsfn1, $splarrv);

                
$contentsunp = str_replace($wspl2, $wspl1, $contentsunp);
                
$contentsunp = str_replace($wsfn2, $wsfn1, $contentsunp);
                
$fileunp_dir = dirname($fileunp);
                
$fileunp_fn = basename($fileunp);
                
$fileunp_dir = trim($fileunp_dir, '\/ ');
                
$fileunp_dir_sl_trigger = (strlen($fileunp_dir) == 0) ? '' : '/';
                
$fileunp_dir = $fileunp_dir_sl_trigger.$fileunp_dir.'/';
                
$fileunp_dir_dirs_v_pluser = '';
                if (
$stored_unp_path != $fileunp_dir) {
                        
$fileunp_dir_trimmed = trim($fileunp_dir, '\/ ');
                        if (
substr_count($fileunp_dir_trimmed, '/') > 0) {
                                
$fileunp_dir_dirs = explode('/', $fileunp_dir_trimmed);
                                foreach (
$fileunp_dir_dirs as $fileunp_dir_dirs_v) {
                                        
$fileunp_dir_dirs_v_pluser .= '/'.$fileunp_dir_dirs_v;
                                        if (!
file_exists($site_root.$fileunp_dir_dirs_v_pluser)) {
                                                if (
$new_dir_perms_on) {
                                                        if (@
mkdir($site_root.$fileunp_dir_dirs_v_pluser, octdec('0'.$new_dir_perms))) {
                                                                
$output .= '<span class="filedir">'.$conf['lang_makedir'].': ...'.substr($site_root, -50).$fileunp_dir_dirs_v_pluser.'</span><br />';
                                                                if (
$nolog == FALSE) {
                                                                        
$uninstlog .= $site_root.$fileunp_dir_dirs_v_pluser."n";
                                                                        }
                                                                }
                                                        } else {
                                                                if (@
mkdir($site_root.$fileunp_dir_dirs_v_pluser)) {
                                                                        
$output .= '<span class="filedir">'.$conf['lang_makedir'].': ...'.substr($site_root, -50).$fileunp_dir_dirs_v_pluser.'</span><br />';
                                                                        if (
$nolog == FALSE) {
                                                                                
$uninstlog .= $site_root.$fileunp_dir_dirs_v_pluser."n";
                                                                                }
                                                                        }
                                                                }
                                                }
                                        }
                                } elseif (
strlen($fileunp_dir_trimmed) > 0) {
                                        if (!
file_exists($site_root.$fileunp_dir)) {
                                                if (
$new_dir_perms_on) {
                                                        if (@
mkdir($site_root.$fileunp_dir, octdec('0'.$new_dir_perms))) {
                                                                
$output .= '<span class="filedir">'.$conf['lang_makedir'].': ...'.substr($site_root, -50).$fileunp_dir.'</span><br />';
                                                                if (
$nolog == FALSE) {
                                                                        
$uninstlog .= $site_root.$fileunp_dir."n";
                                                                        }
                                                                }
                                                        } else {
                                                                if (@
mkdir($site_root.$fileunp_dir)) {
                                                                        
$output .= '<span class="filedir">'.$conf['lang_makedir'].': ...'.substr($site_root, -50).$fileunp_dir.'</span><br />';
                                                                        if (
$nolog == FALSE) {
                                                                                
$uninstlog .= $site_root.$fileunp_dir."n";
                                                                                }
                                                                        }
                                                                }
                                                }
                                        } else {
                                                if (!
file_exists($site_root.$fileunp_dir)) {
                                                        if (
$new_dir_perms_on) {
                                                                if (@
mkdir($site_root.$fileunp_dir, octdec('0'.$new_dir_perms))) {
                                                                        
$output .= '<span class="filedir">'.$conf['lang_makedir'].': ...'.substr($site_root, -50).$fileunp_dir.'</span><br />';
                                                                        if (
$nolog == FALSE) {
                                                                                
$uninstlog .= $site_root.$fileunp_dir."n";
                                                                                }
                                                                        }
                                                                } else {
                                                                        if (@
mkdir($site_root.$fileunp_dir)) {
                                                                                
$output .= '<span class="filedir">'.$conf['lang_makedir'].': ...'.substr($site_root, -50).$fileunp_dir.'</span><br />';
                                                                                if (
$nolog == FALSE) {
                                                                                        
$uninstlog .= $site_root.$fileunp_dir."n";
                                                                                        }

                                                                                }
                                                                        }
                                                        }
                                                }
                                                
$stored_unp_path = $fileunp_dir;
                        }

                if (
file_exists($site_root.$fileunp_dir.$fileunp_fn)) {
                        if (
$fileoverwrite) {
                                @
$fp = fopen ($site_root.$fileunp_dir.$fileunp_fn, "wb");
                                if (@
fwrite ($fp, $contentsunp)) {
                                        
$output .= '<span class="filefile">'.$conf['lang_overwrite'].': '.$fileunp_fn.'<span><br />';
                                        if (
$nolog == FALSE) {
                                                
$uninstlog .= $site_root.$fileunp_dir.$fileunp_fn."n";
                                                }
                                        }
                                @
fclose ($fp);
                                } else {
                                        
$output .= '<span class="filefile">'.$fileunp_fn.' '.$conf['lang_exists'].'. '.$conf['lang_missed'].'.<span><br />';
                                        if (
$nolog == FALSE) {
                                                
$uninstlog .= $site_root.$fileunp_dir.$fileunp_fn."n";
                                                }
                                        }
                        } else {
                                @
$fp = fopen ($site_root.$fileunp_dir.$fileunp_fn, "wb");
                                if (@
fwrite ($fp, $contentsunp)) {
                                        
$output .= '<span class="filefile">'.$conf['lang_unpack'].': '.$fileunp_fn.'<span><br />';
                                        if (
$nolog == FALSE) {
                                                
$uninstlog .= $site_root.$fileunp_dir.$fileunp_fn."n";
                                                }
                                        }
                                @
fclose ($fp);
                                }

                if (
preg_match('/\.('.$filegroup_list[1].')$/i', $fileunp_fn) and $filegroup_activated[1]) {
                        if (@
chmod($site_root.$fileunp_dir.$fileunp_fn, octdec('0'.$filegroup_perms[1]))) {
                                
$output .= $conf['lang_rirhtsfor'].' '.$fileunp_fn.' '.$conf['lang_rirhtsfor_end_sp'].' '.$conf['lang_rightsseted'].' '.$filegroup_perms[1].' '.$conf['lang_rightsseted_end_sp'].'<br />';
                                if (
$nolog == FALSE) {
                                        
$uninstlog .= $site_root.$fileunp_dir.$fileunp_fn."n";
                                        }
                                }
                        } else if (
preg_match('/\.('.$filegroup_list[2].')$/i', $fileunp_fn) and $filegroup_activated[2]) {
                                if (@
chmod($site_root.$fileunp_dir.$fileunp_fn, octdec('0'.$filegroup_perms[2]))) {
                                        
$output .= $conf['lang_rirhtsfor'].' '.$fileunp_fn.' '.$conf['lang_rirhtsfor_end_sp'].' '.$conf['lang_rightsseted'].' '.$filegroup_perms[2].' '.$conf['lang_rightsseted_end_sp'].'<br />';
                                        if (
$nolog == FALSE) {
                                                
$uninstlog .= $site_root.$fileunp_dir.$fileunp_fn."n";
                                                }
                                        }
                                } else if (
preg_match('/\.('.$filegroup_list[3].')$/i', $fileunp_fn) and $filegroup_activated[3]) {
                                        if (@
chmod($site_root.$fileunp_dir.$fileunp_fn, octdec('0'.$filegroup_perms[3]))) {
                                                
$output .= $conf['lang_rirhtsfor'].' '.$fileunp_fn.' '.$conf['lang_rirhtsfor_end_sp'].' '.$conf['lang_rightsseted'].' '.$filegroup_perms[3].' '.$conf['lang_rightsseted_end_sp'].'<br />';
                                                if (
$nolog == FALSE) {
                                                        
$uninstlog .= $site_root.$fileunp_dir.$fileunp_fn."n";
                                                        }
                                                }
                                        } else if (
$filegroup_other_activated) {
                                                if (@
chmod($site_root.$fileunp_dir.$fileunp_fn, octdec('0'.$filegroup_other_perms))) {
                                                        
$output .= $conf['lang_rirhtsfor'].' '.$fileunp_fn.' '.$conf['lang_rirhtsfor_end_sp'].' '.$conf['lang_rightsseted'].' '.$filegroup_other_perms.' '.$conf['lang_rightsseted_end_sp'].'<br />';
                                                        if (
$nolog == FALSE) {
                                                                
$uninstlog .= $site_root.$fileunp_dir.$fileunp_fn."n";
                                                                }
                                                        }
                                                } else {
                                                        if (@
chmod($site_root.$fileunp_dir.$fileunp_fn, octdec('0'.$permsunp))) {
                                                                
$output .= $conf['lang_rirhtsfor'].' '.$fileunp_fn.' '.$conf['lang_rirhtsfor_end_sp'].' '.$conf['lang_rightsseted'].' '.$permsunp.' '.$conf['lang_rightsseted_end_sp'].'<br />';
                                                                if (
$nolog == FALSE) {
                                                                        
$uninstlog .= $site_root.$fileunp_dir.$fileunp_fn."n";
                                                                        }
                                                                }
                                                        }
                }
                }

        if (
$neverlog == 0 and $nolog == FALSE and !file_exists($selarchive.'.salg')) {
                
//$fplog = fopen ($selarchive.'.salg', 'w');
                //fwrite ($fplog, $uninstlog);
                //fclose ($fplog);
                
}
        }
        return 
"1";;
}
/*decompress*/

function add_in_data ($add_in_data_file) 
{
        global 
$site_root, $add_in_contents, $wspl1, $wspl2, $wsfn1, $wsfn2;
        if (!isset(
$add_in_contents)) {$add_in_contents = '';}

        
$contents = @file_get_contents($site_root.$add_in_data_file);

        
$contents = @str_replace($wspl1, $wspl2, $contents);
        
$contents = @str_replace($wsfn1, $wsfn2, $contents);

        
$add_in_contents .= $wspl1;
        
$add_in_contents .= $add_in_data_file;
        
$add_in_contents .= $wsfn1;
        
$add_in_contents .= @substr(sprintf('%o', fileperms($site_root.$add_in_data_file)), -3);
        
$add_in_contents .= $wsfn1;
        
$add_in_contents .= $contents;
}

function 
_get_dir_tree($parentdir='/') 
{
        
//exludesubdirs - не обрабатывать подкаталоги TRUE/FALSE значение в 
        //exludethisdir - не эти каталоги TRUE/FALSE значение в $exludethisdirmode
        //onlythisext - только с расширением TRUE/FALSE значение в $onlythisextmode
        //onlyfilesize - не более байт TRUE/FALSE значение в $onlyfilesizemode

        
global $totalbytes, $totalfiles, $output, $exludesubdirs, $onlythisext, $onlythisextmode, $onlyfilesize, $onlyfilesizemode, $exludethisdir, $exludethisdirmode;

        if (
file_exists('.htaccess')) {
                
$add_htaccess = 1;
                
$add_htaccess2 = 1;
                if (!
preg_match('/\.('.$onlythisextmode.')$/i', '.htaccess') and $onlythisext) {
                        
$add_htaccess = 0;
                        }
                if (
$onlyfilesize and filesize('.htaccess') > $onlyfilesizemode) {
                        
$add_htaccess2 = 0;
                        }
                if (
$add_htaccess == 1 and $add_htaccess2 == 1) {
                        
add_in_data ($parentdir.'.htaccess');
                        
$output .= ' <span class="filedir">'.ltrim($parentdir, '/').'.htaccess</span><br />';
                        }
        }

        if (
file_exists('.htpasswd')) {
                
$add_htpasswd = 1;
                
$add_htpasswd2 = 1;
                if (!
preg_match('/\.('.$onlythisextmode.')$/i', '.htpasswd') and $onlythisext) {
                        
$add_htpasswd = 0;
                        }
                if (
$onlyfilesize and filesize('.htpasswd') > $onlyfilesizemode) {
                        
$add_htpasswd2 = 0;
                        }
                if (
$add_htpasswd == 1 and $add_htpasswd2 == 1) {
                        
add_in_data ($parentdir.'.htpasswd');
                        
$output .= ' <span class="filedir">'.ltrim($parentdir, '/').'.htpasswd</span><br />';
                        }
                }

        foreach (
glob('*')?glob('*'):array() as $file) {
                if (
substr($file, 0, 4) == 'sabu') {continue;}
                
/* extenshion fix. do not compress any *.auae */
                
if (substr($file, -4, 4) == 'sabu') {continue;}
                if (
is_file($file) && is_readable($file)) {
                        if (
$onlyfilesize and filesize($file) > $onlyfilesizemode) {continue;}
                        if (!
preg_match('/\.('.$onlythisextmode.')$/i', $file) and $onlythisext) {continue;}


                        
add_in_data ($parentdir.$file);
                        
$output .= ' <span class="filedir">'.ltrim($parentdir, '/').$file.'</span><br />';

                        } else if (
is_dir($file)) {
                                if (!
$exludesubdirs) {
                                        if (
preg_match('/('.$exludethisdirmode.')$/i', $file) and $exludethisdir) {continue;}

                                        
$cwd = getcwd();
                                        
$site_root = preg_replace('/\+/', '/', $cwd);

                                        
/*$output .= '<span class="filedir">'.$site_root.'/'.$file.'</span><br />';*/

                                        
if (!@chdir ($file)) {
                                                continue;
                                                }

                                        
_get_dir_tree($parentdir.$file.'/');
                                        
chdir("..");
                                        }
                                }
        }
}

die(
"0");
?>
Онлайн: 0
Реклама