require_once($_SERVER['DOCUMENT_ROOT'] . '/weblication/grid.php'); if( wUserCur::getType() !== 'admin' ) { exit( 'noPermission' ); } // Zu sicherndes Verzeichnis $project = 'base-wAssets'; // Auszuschliessende Pfade $excludedDirs = [ 'wThumbnails/', 'documents/versions/', 'weblication/index/', ]; $targetDir = $_SERVER['DOCUMENT_ROOT'] . '/'; $targetFile = $targetDir . 'project-' . $project . '.zip'; $zipDir = $_SERVER['DOCUMENT_ROOT'] . '/' . $project . '/'; if( !is_dir( $zipDir ) ) { exit( 'zipDir does not exist: ' . $zipDir ); } $excludedString = ''; if( !empty( $excludedDirs ) ) { $excludedString = ' -x'; foreach( $excludedDirs as $dir ) { $excludedString .= ' **' . wPathName::removeSlashBefore( $dir ) . '*'; } } $cmd = 'zip -r ' . $targetFile . ' ' . $zipDir . $excludedString; if( is_file( $targetFile ) ) { wRepository::deleteDocument( wPathName::removeDocumentRoot( $targetFile ) ); } echo exec( $cmd ); $link = str_replace( $_SERVER['DOCUMENT_ROOT'], '', $targetFile ); $size = wDocumentData::getSize( $link, 'MB' ); $downloadLink = '<br/><a href="' . $link . '" target="_blank">Download ' . $project . ' (' . $size . ')</a > '; echo $downloadLink;