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]); foreach ($dirs[$rep[1]] as $path) {
} } else { if (@file_exists($s->cfg['path']['data'] . "/backup.tar")) { @unlink($s->cfg['path']['data'] . "/backup.tar"); } if (!$HTTP_POST_FILES['file']['tmp_name']) { $m->error_redir("backup_upload_notmp"); } if (!preg_match("/\\.tar\$/", $HTTP_POST_FILES['file']['name'])) { @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']) {