Who does not know, tons of different archive formats zip, gz, bz, lzma, etc. are on the desktop no problem. When creating a Web application in PHP, the more complicated, so I did it exec () and 7-zip solved.
The appendix also a package with PHP - Function to extract and 7zip - Binary's for 32 / 64 - bit Linux and Windows systems.
To use on Linux systems, the 32/7z 64/7z and make it executable and integrated into the functions.php script. The extractAll function with the archive and possibly 7zip parameters called. rmdirr () deletes a directory recursively (even if there are files in subdirectories), very handy for just unpacked archives.
Download: php-7z
/* Nerd 2.0
* March 2010
* www.nerd20.de
*/
function extractAll($file, $cmd = '') {
// 64 / 32 Bit - Unix, Windows
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$cmd = '32\7z x '.$file.' -y '.$cmd;
}
else {
if(intval(-6981276091) == -6981276091) {
$cmd = '64/7z x '.$file.' -y '.$cmd;
}
else {
$cmd = '32/7z x '.$file.' -y '.$cmd;
}
}
// Ausführen
exec($cmd, $output);
return $output;
}
/**
* Delete a file, or a folder and its contents (recursive algorithm)
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.3
* @link http://aidanlister.com/repos/v/function.rmdirr.php
* @param string $dirname Directory to delete
* @return bool Returns TRUE on success, FALSE on failure
*/
function rmdirr($dirname)
{
// Sanity check
if (!file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (is_file($dirname) || is_link($dirname)) {
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
}
// Clean up
$dir->close();
return rmdir($dirname);
}
Vielen Dank an aidanlister.com für das Löschen von Verzeichnissen und dem smarty Blog für 32- / 64-Bit Abfrage.

