function uploadFile($file) { header('Content-Description: File Transfer'); if (MainWPUtility::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'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); while (@ob_get_level()) { @ob_end_clean(); } $this->readfile_chunked($file); exit; }
private static function addExcludedBackups(&$files, &$arr) { $newExcludes = array(); //Backup buddy $newExcludes[] = 'wp-content/uploads/backupbuddy_backups'; $newExcludes[] = 'wp-content/uploads/backupbuddy_temp'; $newExcludes[] = 'wp-content/uploads/pb_backupbuddy'; //ManageWP $newExcludes[] = 'wp-content/managewp'; //InfiniteWP $newExcludes[] = 'wp-content/infinitewp'; //WordPress Backup to Dropbox $newExcludes[] = 'wp-content/backups'; //BackWPUp $newExcludes[] = 'wp-content/uploads/backwpup*'; //WP Complete Backup $newExcludes[] = 'wp-content/plugins/wp-complete-backup/storage'; //Online Backup for WordPress $newExcludes[] = 'wp-content/backups'; //XCloner $newExcludes[] = 'administrator/backups'; foreach ($newExcludes as $newExclude) { $path = explode('/', $newExclude); $found = true; $newExcludeSuffix = null; $currentArr = null; foreach ($path as $pathPart) { if ($currentArr == null) { if (isset($files[$pathPart])) { $currentArr = $files[$pathPart]; } } else { if (isset($currentArr[$pathPart])) { $currentArr = $currentArr[$pathPart]; } else { if (MainWPUtility::endsWith($pathPart, "*")) { foreach ($currentArr as $key => $val) { if (MainWPUtility::startsWith($key, substr($pathPart, 0, strlen($pathPart) - 1))) { if ($newExcludeSuffix == null) { $newExcludeSuffix = array(); } $newExcludeSuffix[] = $key; } } if ($newExcludeSuffix != null && count($newExcludeSuffix) > 0) { break; } } $currentArr = null; } } if (!is_array($currentArr)) { $found = false; break; } } if ($found) { if ($newExcludeSuffix != null) { $newExclude = substr($newExclude, 0, strrpos($newExclude, '/') + 1); foreach ($newExcludeSuffix as $newExcludeSuff) { $arr[] = $newExclude . $newExcludeSuff; } } else { $arr[] = $newExclude; } } } }