Quarantine a Dangerous File by Creating a ZIP Archive in PHP
If a dangerous or infected file has been detected by your anti-virus protection program, the next step is to neutralize the threat. By utilizing the following API in PHP, you will be able to instantly quarantine an infected file by creating a new ZIP archive and applying encryption and password protection features.
To begin the process, you will run this command to install the SDK:
composer require cloudmersive/cloudmersive_document_convert_api_client
Next, you can call the function with the below example code:
<?php
require_once(__DIR__ . '/vendor/autoload.php');// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');$apiInstance = new Swagger\Client\Api\ZipArchiveApi(
new GuzzleHttp\Client(),
$config
);
$password = "password_example"; // string | Password to place on the Zip file; the longer the password, the more secure
$input_file1 = "/path/to/inputfile"; // \SplFileObject | First input file to perform the operation on.
$encryption_algorithm = "encryption_algorithm_example"; // string | Encryption algorithm to use; possible values are AES-256 (recommended), AES-128, and PK-Zip (not recommended; legacy, weak encryption algorithm). Default is AES-256.try {
$result = $apiInstance->zipArchiveZipCreateQuarantine($password, $input_file1, $encryption_algorithm);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ZipArchiveApi->zipArchiveZipCreateQuarantine: ', $e->getMessage(), PHP_EOL;
}
?>
This operation can be performed to contain one or multiple dangerous files. If you need to obtain an API key, you can do so by registering for a free account on the Cloudmersive website; this will provide 800 calls/month across our wide array of APIs.