Fix backup huge size on windows hosts

Fix downloading file to dashboard stall
Fix PHP warning when creating clone backup
This commit is contained in:
ruben- 2015-01-29 21:16:30 +01:00
parent 68add3dfae
commit ffe08e5576
4 changed files with 29 additions and 16 deletions

View file

@ -321,7 +321,7 @@ class MainWPBackup
'home' => get_option('home'),
'abspath' => ABSPATH,
'prefix' => $wpdb->prefix,
'lang' => WPLANG,
'lang' => defined('WPLANG') ? WPLANG : '',
'plugins' => $plugins,
'themes' => $themes)));
@ -523,7 +523,7 @@ class MainWPBackup
foreach ($iterator as $path)
{
$name = $path->__toString();
if (MainWPHelper::endsWith($name, '/.') || MainWPHelper::endsWith($name, '/..')) continue;
if ((basename($name) == '.') || (basename($name) == '..')) continue;
if (!MainWPHelper::inExcludes($excludes, str_replace(ABSPATH, '', $name)))
{

View file

@ -1710,13 +1710,12 @@ class MainWPChild
{
$backupFile = 'dbBackup-' . $fileNameUID . '-*.sql';
$dirs = MainWPHelper::getMainWPDir('backup');
$backupdir = $dirs[0];
$result = glob($backupdir . $backupFile . '*');
if (count($result) == 0) MainWPHelper::write(array());
$dirs = MainWPHelper::getMainWPDir('backup');
$backupdir = $dirs[0];
$result = glob($backupdir . $backupFile . '*');
if (count($result) == 0) MainWPHelper::write(array());
MainWPHelper::write(array('size' => filesize($result[0])));
MainWPHelper::write(array('size' => filesize($result[0])));
exit();
}
}
@ -2571,8 +2570,8 @@ class MainWPChild
$outPost = array();
$outPost['id'] = $post->ID;
$outPost['status'] = $post->post_status;
$outPost['title'] = $post->post_title;
$outPost['content'] = $post->post_content;
$outPost['title'] = utf8_encode($post->post_title);
$outPost['content'] = utf8_encode($post->post_content);
$outPost['comment_count'] = $post->comment_count;
$outPost['dts'] = strtotime($post->post_modified_gmt);
$usr = get_user_by('id', $post->post_author);
@ -4017,7 +4016,17 @@ class MainWPChild
$backupdir = $dirs[0];
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Description: File Transfer');
if (MainWPHelper::endsWith($file, '.tar.gz'))
{
header('Content-Type: application/x-gzip');
header("Content-Encoding: gzip'");
}
else
{
header('Content-Type: application/octet-stream');
}
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');

View file

@ -254,6 +254,8 @@ class TarArchiver
public function addDir($path, $excludes)
{
if ((basename($path) == '.') || (basename($path) == '..')) return;
$this->addEmptyDir($path, str_replace(ABSPATH, '', $path));
if (file_exists(rtrim($path, '/') . '/.htaccess')) $this->addFile(rtrim($path, '/') . '/.htaccess', rtrim(str_replace(ABSPATH, '', $path), '/') . '/mainwp-htaccess');
@ -270,7 +272,7 @@ class TarArchiver
foreach ($iterator as $path)
{
$name = $path->__toString();
if (MainWPHelper::endsWith($name, '/.') || MainWPHelper::endsWith($name, '/..')) continue;
if ((basename($name) == '.') || (basename($name) == '..')) continue;
if (!MainWPHelper::inExcludes($excludes, str_replace(ABSPATH, '', $name)))
{
@ -469,6 +471,8 @@ class TarArchiver
protected $cnt = 0;
private function addFile($path, $entryName)
{
if ((basename($path) == '.') || (basename($path) == '..')) return false;
if ($this->excludeZip && MainWPHelper::endsWith($path, '.zip'))
{
$this->log('Skipping ' . $path);
@ -933,7 +937,7 @@ class TarArchiver
if ($this->type == 'tar.gz')
{
//$this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
$this->archive = @gzopen($filepath, 'w');
$this->archive = @gzopen($filepath, 'wb');
}
else if ($this->type == 'tar.bz2')
{
@ -964,7 +968,7 @@ class TarArchiver
if ($this->type == 'tar.gz')
{
//$this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
$this->archive = @gzopen($filepath, 'a');
$this->archive = @gzopen($filepath, 'ab');
}
else if ($this->type == 'tar.bz2')
{
@ -1306,7 +1310,7 @@ class TarArchiver
else mkdir(dirname($to . $file['name']), 0777, true);
}
if (!empty($wp_filesystem))
if (!empty($wp_filesystem) && ($file['stat'][7] < 2000000))
{
$contents = '';
$bytesToRead = $file['stat'][7];

View file

@ -5,7 +5,7 @@
Description: Child Plugin for MainWP. The plugin is used so the installed blog can be securely managed remotely by your network. Plugin documentation and options can be found here http://docs.mainwp.com
Author: MainWP
Author URI: http://mainwp.com
Version: 2.0.6
Version: 2.0.7-beta
*/
header('X-Frame-Options: ALLOWALL');
//header('X-Frame-Options: GOFORIT');