Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

collection_download_process_archive_command()

Description

Executes the archiver command when downloading a collection.


False when further processing needed e.g. when producing a zip file.

Parameters

ColumnTypeDefaultDescription
$collection_download_tar boolean
&$zip
$filename string
$usertempdir string
$archiver boolean
$settings_id integer
&$zipfile
$zip object
$zipfile string

Return

bool Will return true if there is no further work to be done as will be the case for a tar file.

Location

include/collections_functions.php lines 5185 to 5241

Definition

 
function collection_download_process_archive_command($collection_download_tar, &$zip$filename$usertempdir$archiver$settings_id, &$zipfile)
    {
    global 
$lang$use_zip_extension$collection_download_settings$archiver_listfile_argument$cmdfile$config_windows,$zipcommand;

    
$archiver_fullpath get_utility_path("archiver");

    
# Execute the archiver command.
    # If $collection_download is true the $collection_download_settings are used if defined, else the legacy $zipcommand is used.
    
if ($use_zip_extension && !$collection_download_tar)
        {
        
update_zip_progress_file("zipping");
        
$GLOBALS["use_error_exception"]=true;
        try
            {
            
$zip->close();
            }
        catch (
Throwable $e)
            {
            
debug("collection_download_process_archive_command: Unable to close zip file. Reason {$e->getMessage()}");
            }
        unset(
$GLOBALS["use_error_exception"]);
        
update_zip_progress_file("complete");
        
sleep(1);
        }
     elseif (
$collection_download_tar)
        {
        
header("Content-type: application/tar");
        
header("Content-disposition: attachment; filename=" $filename );
        
debug("collection_download tar command: tar -cv -C " $usertempdir " . ");
        
$cmdtempdir escapeshellarg($usertempdir);
        
passthru("find " $cmdtempdir ' -printf "%P\n" | tar -cv --no-recursion --dereference -C ' $cmdtempdir " -T -");
        
        return 
true;
        }
    elseif (
$archiver)
        {
        
update_zip_progress_file("zipping");
        
run_command($archiver_fullpath " " $collection_download_settings[$settings_id]["arguments"] . " " escapeshellarg($zipfile) . " " $archiver_listfile_argument escapeshellarg($cmdfile));
        
update_zip_progress_file("complete");
        }
    elseif (!
$use_zip_extension)
        {
        
update_zip_progress_file("zipping");    
        if (
$config_windows)
            
# Add the command file, containing the filenames, as an argument.
            
{
            
exec("$zipcommand " escapeshellarg($zipfile) . " @" escapeshellarg($cmdfile));
            }
        else
            {
            
# Pipe the command file, containing the filenames, to the executable.
            
exec("$zipcommand " escapeshellarg($zipfile) . " -@ < " escapeshellarg($cmdfile));
            }
            
update_zip_progress_file("complete");
        }
    return 
false;
    }

This article was last updated 4th December 2024 09:05 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.