Die Klass ist in der Zip.php vorhanden
PHP-Code:
/**
* Class for manipulating zip archive files
*
* A class which provided common methods to manipulate ZIP formatted
* archive files.
* It provides creation, extraction, deletion and add features.
*
* @author Vincent Blavet <vincent@blavet.net>
* @version $Revision: 302924 $
* @package Archive_Zip
* @category Archive
*/
class Archive_Zip
{
/**
* The filename of the zip archive.
*
* @var string Name of the Zip file
*/
var $_zipname = '';
/**
* File descriptor of the opened Zip file.
*
* @var int Internal zip file descriptor
*/
var $_zip_fd = 0;
/**
* @var int last error code
*/
var $_error_code = 1;
/**
* @var string Last error description
*/
var $_error_string = '';
// {{{ constructor
/**
* Archive_Zip Class constructor. This flavour of the constructor only
* declare a new Archive_Zip object, identifying it by the name of the
* zip file.
*
* @param string $p_zipname The name of the zip archive to create
*
* @access public
*/
function Archive_Zip($p_zipname)
{
// ----- Check the zlib
if (!extension_loaded('zlib')) {
PEAR::loadExtension('zlib');
}
if (!extension_loaded('zlib')) {
die("The extension 'zlib' couldn't be found.\n".
"Please make sure your version of PHP was built ".
"with 'zlib' support.\n");
return false;
}
// ----- Set the attributes
$this->_zipname = $p_zipname;
$this->_zip_fd = 0;
return;
}
// }}}
// {{{ create()
/**
* This method creates a Zip Archive with the filename set with
* the constructor.
* The files and directories indicated in $p_filelist
* are added in the archive.
* When a directory is in the list, the directory and its content is added
* in the archive.
* The methods takes a variable list of parameters in $p_params.
* The supported parameters for this method are :
* 'add_path' : Add a path to the archived files.
* 'remove_path' : Remove the specified 'root' path of the archived files.
* 'remove_all_path' : Remove all the path of the archived files.
* 'no_compression' : The archived files will not be compressed.
*
*
* @param mixed $p_filelist The list of the files or folders to add.
* It can be a string with filenames separated
* by a comma, or an array of filenames.
* @param mixed $p_params An array of variable parameters and values.
*
* @return mixed An array of file description on success,
* an error code on error
*/
function create($p_filelist, $p_params = 0)
{
$this->_errorReset();
// ----- Set default values
if ($p_params === 0) {
$p_params = array();
}
if ($this->_check_parameters($p_params,
array('no_compression' => false,
'add_path' => "",
'remove_path' => "",
'remove_all_path' => false)) != 1) {
return 0;
}
Einen Kommentar schreiben: