private function local() { $this->files = readDirectrory(BACKUP_DIR . '/' . $this->params['name'], array('.zip')); include main::getPluginDir() . '/libs/pclzip.lib.php'; if (($n = count($this->files)) > 0) { for ($i = 0; $i < $n; $i++) { main::log(str_replace('%s', basename($this->files[$i]), lang::get("Data decompression: %s", false))); $this->archive = new PclZip($this->files[$i]); $file_in_zip = $this->archive->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER); } if (file_exists(BACKUP_DIR . '/' . $this->params['name'] . '/mysqldump.sql')) { main::log(lang::get("Run process restore Database", false)); $mysql = $this->incMysql(); $mysql->restore(BACKUP_DIR . '/' . $this->params['name'] . '/mysqldump.sql'); main::log(lang::get("Stopped process restore Database", false)); main::remove(BACKUP_DIR . '/' . $this->params['name'] . '/mysqldump.sql'); } } }
private static function getBackups() { $res = array(); if (is_dir(BACKUP_DIR)) { $dir_open = opendir(BACKUP_DIR); if ($dir_open) { $i = 0; while ($d = readdir($dir_open)) { if ($d != '.' && $d != '..' && is_dir(BACKUP_DIR . "/{$d}")) { $res['data'][$i]['name'] = $d; $res['data'][$i]['dt'] = self::getDateInName($d); $res['data'][$i]['type'] = 'local'; $parts = readDirectrory(BACKUP_DIR . "/" . $d, array('.zip', '.md5')); $res['data'][$i]['count'] = count($parts); $res['data'][$i]['size'] = 0; for ($j = 0; $j < $res['data'][$i]['count']; $j++) { $res['data'][$i]['size'] += filesize($parts[$j]); $parts[$j] = basename($parts[$j]); } $res['data'][$i]['files'] = implode(',', $parts); $i++; } } if (isset($res['data'])) { $res['md5'] = md5(print_r($res['data'], 1)); } } } return $res; }
function readDirectrory($dir, $format = '') { $result = array(); if (is_dir($dir)) { $dir_open = opendir($dir); if ($dir_open) { while ($d = readdir($dir_open)) { if ($d != '.' && $d != '..' && $d != BACKUP_DIR_NAME) { if (is_dir($dir . "/" . $d)) { $result = array_merge($result, readDirectrory($dir . "/" . $d, $format)); } elseif (is_file($dir . "/" . $d)) { if (empty($format)) { $result[] = $dir . "/" . $d; } elseif (!empty($format) && is_string($format)) { if (substr($d, -4) == $format) { $result[] = $dir . "/" . $d; } } elseif (!empty($format) && is_array($format)) { if (in_array(substr($d, -4), $format)) { $result[] = $dir . "/" . $d; } } } } } } } return $result; }
private function createListFiles() { if (!empty($this->params['minus-path'])) { $this->minus_path = explode(",", $this->params['minus-path']); } $files = array(ABSPATH . '.htaccess', ABSPATH . 'index.php', ABSPATH . 'license.txt', ABSPATH . 'readme.html', ABSPATH . 'wp-activate.php', ABSPATH . 'wp-blog-header.php', ABSPATH . 'wp-comments-post.php', ABSPATH . 'wp-config.php', ABSPATH . 'wp-config-sample.php', ABSPATH . 'wp-cron.php', ABSPATH . 'wp-links-opml.php', ABSPATH . 'wp-load.php', ABSPATH . 'wp-login.php', ABSPATH . 'wp-mail.php', ABSPATH . 'wp-settings.php', ABSPATH . 'wp-signup.php', ABSPATH . 'wp-trackback.php', ABSPATH . 'xmlrpc.php'); $folders = array(ABSPATH . 'wp-admin', ABSPATH . 'wp-content', ABSPATH . 'wp-includes'); if (!empty($this->params['plus-path'])) { $plus_path = explode(",", $this->params['plus-path']); foreach ($plus_path as $p) { if (empty($p)) { continue; } $p = ABSPATH . $p; if (file_exists($p)) { if (is_dir($p)) { $folders[] = $p; } else { $files[] = $p; } } } } $f = ''; foreach ($folders as $folder) { if (!is_dir($folder)) { continue; } $f = str_replace(ABSPATH, '', $folder); if (in_array($f, $this->minus_path)) { continue; } $files = array_merge($files, readDirectrory($folder)); } $ret = array(); if (($n = count($files)) > 0) { $f = ''; for ($i = 0; $i < $n; $i++) { $f = str_replace(ABSPATH, '', $files[$i]); if (!in_array($f, $this->minus_path) || strpos($f, 'cache') === false) { $ret[] = $files[$i]; } else { main::log(str_replace('%s', $f, lang::get('Skip file "%s"', false))); } } } return $files; }