Example #1
0
if (!class_exists('filesystem')) {
    require_once 'install/classes/class.filesystem.php';
    $filesystem = new filesystem($config['ftp_server'], $config['ftp_user'], $config['ftp_pw'], $config['ftp_port']);
    $filesystem->set_wd($config['ftp_path'], $config['fpath']);
}
$tar_packs = array(1 => 'update.admin.tar', 2 => 'update.misc.tar');
if (empty($_REQUEST['sub']) || !isset($tar_packs[$_REQUEST['sub']])) {
    $sub = 1;
} else {
    $sub = $_REQUEST['sub'];
}
require 'install/classes/function.chmod.php';
require 'install/classes/class.tar.php';
$tar = new tar(realpath('install/files/'), $tar_packs[$sub]);
$tar->ignore_chmod();
$error = $tar->extract_files('./');
$files = implode("\n", $tar->list_files());
$dirs = array('language' => null, 'templates' => null, 'designs' => null, 'images' => null);
preg_match_all('~^(' . implode('|', array_keys($dirs)) . ')/(\\d+)/([^\\n]+)$~m', $files, $replicable, PREG_SET_ORDER);
foreach ($replicable as $rep) {
    if ($dirs[$rep[1]] === null) {
        $dirs[$rep[1]] = array();
        $dir = dir($rep[1]);
        while (false !== ($entry = $dir->read())) {
            if (is_id($entry) && is_dir($rep[1] . '/' . $entry)) {
                $dirs[$rep[1]][$entry] = $rep[1] . '/' . $entry . '/';
            }
        }
        $dir->close();
    }
    $content = file_get_contents($rep[0]);
        } elseif ($extension == 'tar.gz') {
            gzAbortNotLoaded();
            $temp = gzTempfile($file);
            $temp = realpath($temp);
            include 'classes/class.tar.php';
            $tar = new tar(dirname($temp), basename($temp));
            $tar->extract_files(realpath($dir));
            $filesystem->unlink($temp);
            if (!empty($tar->error)) {
                error($redirect, $tar->error);
            }
        } elseif ($extension == 'tar') {
            $file = realpath($file);
            include 'classes/class.tar.php';
            $tar = new tar(dirname($file), basename($file));
            $tar->extract_files($dir);
            if (!empty($tar->error)) {
                error($redirect, $tar->error);
            }
        } elseif ($extension == 'gz') {
            gzAbortNotLoaded();
            $new = $dir . DIRECTORY_SEPARATOR . basename($file);
            $temp = gzTempfile($file, $new);
        }
    }
    ok($redirect);
} elseif ($job == 'all_chmod') {
    echo head();
    $chmod = getViscachaCHMODs();
    ?>
	<table class="border" border="0" cellspacing="0" cellpadding="4" align="center">
Example #3
0
                        @unlink($HTTP_POST_FILES['file']['tmp_name']);
                        $m->error_redir("backup_upload_invalid");
                    }
                    @move_uploaded_file($HTTP_POST_FILES['file']['tmp_name'], $s->cfg['path']['data'] . "/backup.tar");
                }
                $tar->new_tar($s->cfg['path']['data'], "backup.tar");
                $list1 = $tar->list_files();
                $list2 = array();
                foreach ($s->cfg['file'] as $file) {
                    $list2[] = basename($file);
                }
                if ($list1 !== $list2) {
                    @unlink($s->cfg['path']['data'] . "/backup.tar");
                    $m->error_redir("backup_corrupt");
                }
                $tar->extract_files($s->cfg['path']['data']);
            }
            $s->cfg['block:config'] = 1;
            $m->location("sec=backup", "Backup restaurado");
        } else {
            if ($act == "remove") {
                if (!$s->cfg['ver']['demo']) {
                    if (@file_exists($s->cfg['path']['data'] . "/backup.tar")) {
                        @unlink($s->cfg['path']['data'] . "/backup.tar");
                    }
                }
                $m->location("sec=backup", "Backup removido");
            }
        }
    }
}