rapidleech
rapidleech copied to clipboard
add password protection to ZIP/UNZIP actions
Hi. I wonder it is possible to add password encryption to ZIP/Unzip actions like Rar/Unrar? It's useful because most of (shared/free) host disable RAR function. By default the zip decryption is enabled. (See code below). I don't know about zip encryption:
<?php
$zip = new ZipArchive();
$zip_status = $zip->open("test.zip");
if ($zip_status === true)
{
if ($zip->setPassword("MySecretPassword"))
{
if (!$zip->extractTo(__DIR__))
echo "Extraction failed (wrong password?)";
}
$zip->close();
}
else
{
die("Failed opening archive: ". @$zip->getStatusString() . " (code: ". $zip_status .")");
}
?>
Thanks.
+1 Many RAR and ZIP have password for protection.
Please add this feature, thanks.
At the moment none of the 2 classes used supports encryption
ZipArchive supports it, but it has to be enabled/compiled on the server, so it may not be available on all servers: http://php.net/manual/en/zip.installation.php
Anyways, writting another zip/unzip options for only shown if the module is enabled seems to be a good idea.
AFAIK, in most shared servers zip encryption is disabled because of disabled function "system". But still zip decryption is enabled (code in first comment). Thank you for your attention.