I have seen only one question on here but it does not answer my question. I am running a typical LAMP server that has the most up to date PHP 5 and MYSQL 5 with Redhat Linux.
I need to find a PHP only solution because my host does not allow me to use shell.
Here is my code that extracts ZIPs that are not passworded from vBulletin uploads to another directory:
if ($_GET['add'] == TRUE){
$zip = new ZipArchive;
$res = $zip->open($SOURCE FOLDER);
if ($res === TRUE) {
$zip->extractTo('$DESTINATION FOLDER/');
$zip->close();
echo 'File has been added to the library successfuly';
//Add a flag to that file to indicate it has already been added to the library.
mysql_query("UPDATE attachment SET library = 1 WHERE filedataid='$fileid'");
} else {
echo 'A uncompression or file error has occured';
}}
There must be some way to do this using just PHP, surely! Thank you.
UPDATE: My host informs me that gzip is installed on the server but not 7-Zip. I am looking into shell access too.
Have 7zip executable available to the script and call it to uncompress the file with the password via system().
You can do something similar with
unzip, if your host has that installed. See http://linux.about.com/od/commands/l/blcmdl1_unzip.htm.It supports -P with a password, so something like this:
Caveat: someone could see your password on that command line if they do a ps on the system and see your unzip command running.