XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Archive_Zip Class Reference

Public Member Functions

 __construct ($p_zipname)
 
 create ($p_filelist, $p_params=0)
 
 add ($p_filelist, $p_params=0)
 
 listContent ()
 
 extract ($p_params=0)
 
 delete ($p_params)
 
 properties ()
 
 duplicate ($p_archive)
 
 merge ($p_archive_to_add)
 
 errorCode ()
 
 errorName ($p_with_code=false)
 
 errorInfo ($p_full=false)
 
 _checkFormat ($p_level=0)
 
 _create ($p_list, &$p_result_list, &$p_params)
 
 _add ($p_list, &$p_result_list, &$p_params)
 
 _openFd ($p_mode)
 
 _closeFd ()
 
 _addList ($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
 
 _addFileList ($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
 
 _addFile ($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
 
 _writeFileHeader (&$p_header)
 
 _writeCentralFileHeader (&$p_header)
 
 _writeCentralHeader ($p_nb_entries, $p_size, $p_offset, $p_comment)
 
 _list (&$p_list)
 
 _convertHeader2FileInfo ($p_header, &$p_info)
 
 _extractByRule (&$p_file_list, &$p_params)
 
 _extractFile (&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params)
 
 _extractFileAsString (&$p_entry, &$p_string)
 
 _readFileHeader (&$p_header)
 
 _readCentralFileHeader (&$p_header)
 
 _readEndCentralDir (&$p_central_dir)
 
 _deleteByRule (&$p_result_list, &$p_params)
 
 _dirCheck ($p_dir, $p_is_dir=false)
 
 _merge (&$p_archive_to_add)
 
 _duplicate ($p_archive_filename)
 
 _check_parameters (&$p_params, $p_default)
 
 _errorLog ($p_error_code=0, $p_error_string='')
 
 _errorReset ()
 
 _tool_PathReduction ($p_dir)
 
 _tool_PathInclusion ($p_dir, $p_path)
 
 _tool_CopyBlock ($p_src, $p_dest, $p_size, $p_mode=0)
 
 _tool_Rename ($p_src, $p_dest)
 
 _tool_TranslateWinPath ($p_path, $p_remove_disk_letter=true)
 

Data Fields

 $_zipname =''
 
 $_zip_fd =0
 
 $_error_code =1
 
 $_error_string =''
 

Detailed Description

Definition at line 102 of file Archive_Zip.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $p_zipname)

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.

Parameters
string$p_zipnameThe name of the zip archive to create @access public

Definition at line 137 of file Archive_Zip.php.

Member Function Documentation

◆ _add()

_add ( $p_list,
& $p_result_list,
& $p_params )

Archive_Zip::_add()

{ Description }

Parameters
$p_list
$p_result_list
$p_params
Returns
int

Definition at line 857 of file Archive_Zip.php.

◆ _addFile()

_addFile ( $p_filename,
& $p_header,
$p_add_dir,
$p_remove_dir,
$p_remove_all_dir,
& $p_params )

Archive_Zip::_addFile()

{ Description }

Parameters
$p_filename
$p_header
$p_add_dir
$p_remove_dir
$p_remove_all_dir
$p_params
Returns
int

Definition at line 1278 of file Archive_Zip.php.

◆ _addFileList()

_addFileList ( $p_list,
& $p_result_list,
$p_add_dir,
$p_remove_dir,
$p_remove_all_dir,
& $p_params )

Archive_Zip::_addFileList()

{ Description }

Parameters
$p_list
$p_result_list
$p_add_dir
$p_remove_dir
$p_remove_all_dir
$p_params
Returns
int

Definition at line 1169 of file Archive_Zip.php.

◆ _addList()

_addList ( $p_list,
& $p_result_list,
$p_add_dir,
$p_remove_dir,
$p_remove_all_dir,
& $p_params )

Archive_Zip::_addList()

{ Description }

Parameters
$p_list
$p_result_list
$p_add_dir
$p_remove_dir
$p_remove_all_dir
$p_params
Returns
int

Definition at line 1093 of file Archive_Zip.php.

◆ _check_parameters()

_check_parameters ( & $p_params,
$p_default )

Archive_Zip::_check_parameters()

{ Description }

Parameters
$p_params
$p_default
Returns
int

Definition at line 3221 of file Archive_Zip.php.

◆ _checkFormat()

_checkFormat ( $p_level = 0)

Archive_Zip::_checkFormat()

{ Description }

Parameters
int$p_level
Returns
bool

Definition at line 764 of file Archive_Zip.php.

◆ _closeFd()

_closeFd ( )

Archive_Zip::_closeFd()

{ Description }

Definition at line 1054 of file Archive_Zip.php.

◆ _convertHeader2FileInfo()

_convertHeader2FileInfo ( $p_header,
& $p_info )

Archive_Zip::_convertHeader2FileInfo()

{ Description }

Parameters
$p_header
$p_info
Returns
int

Definition at line 1725 of file Archive_Zip.php.

◆ _create()

_create ( $p_list,
& $p_result_list,
& $p_params )

Archive_Zip::_create()

{ Description }

Parameters
$p_list
$p_result_list
$p_params
Returns
int

Definition at line 816 of file Archive_Zip.php.

◆ _deleteByRule()

_deleteByRule ( & $p_result_list,
& $p_params )

Archive_Zip::_deleteByRule()

{ Description }

Parameters
$p_result_list
$p_params
Returns
int

Definition at line 2641 of file Archive_Zip.php.

◆ _dirCheck()

_dirCheck ( $p_dir,
$p_is_dir = false )

Archive_Zip::_dirCheck()

{ Description }

Parameters
[type]$p_is_dir
bool$p_is_dir
Returns
int

Definition at line 2929 of file Archive_Zip.php.

◆ _duplicate()

_duplicate ( $p_archive_filename)

Archive_Zip::_duplicate()

{ Description }

Parameters
$p_archive_filename
Returns
int

Definition at line 3161 of file Archive_Zip.php.

◆ _errorLog()

_errorLog ( $p_error_code = 0,
$p_error_string = '' )

Archive_Zip::_errorLog()

{ Description }

Parameters
int$p_error_code
string$p_error_string

Definition at line 3283 of file Archive_Zip.php.

◆ _errorReset()

_errorReset ( )

Archive_Zip::_errorReset()

{ Description }

Definition at line 3301 of file Archive_Zip.php.

◆ _extractByRule()

_extractByRule ( & $p_file_list,
& $p_params )

Archive_Zip::_extractByRule()

{ Description }

Parameters
$p_file_list
$p_params
Returns
int

Fix PHP7

Definition at line 1769 of file Archive_Zip.php.

◆ _extractFile()

_extractFile ( & $p_entry,
$p_path,
$p_remove_path,
$p_remove_all_path,
& $p_params )

Archive_Zip::_extractFile()

{ Description }

Parameters
$p_entry
$p_path
$p_remove_path
$p_remove_all_path
$p_params
Returns
int

Definition at line 2000 of file Archive_Zip.php.

◆ _extractFileAsString()

_extractFileAsString ( & $p_entry,
& $p_string )

Archive_Zip::_extractFileAsString()

{ Description }

Parameters
$p_entry
$p_string
Returns
int

Definition at line 2237 of file Archive_Zip.php.

◆ _list()

_list ( & $p_list)

Archive_Zip::_list()

{ Description }

Parameters
$p_list
Returns
int

Definition at line 1649 of file Archive_Zip.php.

◆ _merge()

_merge ( & $p_archive_to_add)

Archive_Zip::_merge()

{ Description }

Parameters
$p_archive_to_add
Returns
int

Definition at line 2982 of file Archive_Zip.php.

◆ _openFd()

_openFd ( $p_mode)

Archive_Zip::_openFd()

{ Description }

Parameters
$p_mode
Returns
int

Definition at line 1019 of file Archive_Zip.php.

◆ _readCentralFileHeader()

_readCentralFileHeader ( & $p_header)

Archive_Zip::_readCentralFileHeader()

{ Description }

Parameters
$p_header
Returns
int

Definition at line 2398 of file Archive_Zip.php.

◆ _readEndCentralDir()

_readEndCentralDir ( & $p_central_dir)

Archive_Zip::_readEndCentralDir()

{ Description }

Parameters
$p_central_dir
Returns
int

Definition at line 2505 of file Archive_Zip.php.

◆ _readFileHeader()

_readFileHeader ( & $p_header)

Archive_Zip::_readFileHeader()

{ Description }

Parameters
$p_header
Returns
int

Definition at line 2295 of file Archive_Zip.php.

◆ _tool_CopyBlock()

_tool_CopyBlock ( $p_src,
$p_dest,
$p_size,
$p_mode = 0 )

_tool_CopyBlock()

{ Description }

Parameters
$p_src
$p_dest
$p_size
int$p_mode
Returns
int

Definition at line 3459 of file Archive_Zip.php.

◆ _tool_PathInclusion()

_tool_PathInclusion ( $p_dir,
$p_path )

_tool_PathInclusion()

{ Description }

Parameters
$p_dir
$p_path
Returns
int

Definition at line 3376 of file Archive_Zip.php.

◆ _tool_PathReduction()

_tool_PathReduction ( $p_dir)

_tool_PathReduction()

{ Description }

Parameters
$p_dir
Returns
string

Definition at line 3321 of file Archive_Zip.php.

◆ _tool_Rename()

_tool_Rename ( $p_src,
$p_dest )

_tool_Rename()

{ Description }

Parameters
$p_src
$p_dest
Returns
int

Definition at line 3522 of file Archive_Zip.php.

◆ _tool_TranslateWinPath()

_tool_TranslateWinPath ( $p_path,
$p_remove_disk_letter = true )

_tool_TranslateWinPath()

{ Description }

Parameters
[type]$p_remove_disk_letter
bool$p_remove_disk_letter
Returns
false|string

Definition at line 3562 of file Archive_Zip.php.

◆ _writeCentralFileHeader()

_writeCentralFileHeader ( & $p_header)

Archive_Zip::_writeCentralFileHeader()

{ Description }

Parameters
$p_header
Returns
int

Definition at line 1560 of file Archive_Zip.php.

◆ _writeCentralHeader()

_writeCentralHeader ( $p_nb_entries,
$p_size,
$p_offset,
$p_comment )

Archive_Zip::_writeCentralHeader()

{ Description }

Parameters
$p_nb_entries
$p_size
$p_offset
$p_comment
Returns
int

Definition at line 1616 of file Archive_Zip.php.

◆ _writeFileHeader()

_writeFileHeader ( & $p_header)

Archive_Zip::_writeFileHeader()

{ Description }

Parameters
$p_header
Returns
int

Definition at line 1508 of file Archive_Zip.php.

◆ add()

add ( $p_filelist,
$p_params = 0 )

This method add files or directory in an existing Zip Archive. If the Zip Archive does not exist it is created. The files and directories to add are indicated in $p_filelist. 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. 'callback_pre_add' : A callback function that will be called before each entry archiving. 'callback_post_add' : A callback function that will be called after each entry archiving.

@access public

Parameters
mixed$p_filelistThe list of the files or folders to add. It can be a string with filenames separated by a comma, or an array of filenames.
mixed$p_paramsAn array of variable parameters and values.
Returns
mixed An array of file description on success, 0 on an unrecoverable failure, an error code is logged.

Definition at line 255 of file Archive_Zip.php.

◆ create()

create ( $p_filelist,
$p_params = 0 )

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.

@access public

Parameters
mixed$p_filelistThe list of the files or folders to add. It can be a string with filenames separated by a comma, or an array of filenames.
mixed$p_paramsAn array of variable parameters and values.
Returns
mixed An array of file description on success, an error code on error

Definition at line 181 of file Archive_Zip.php.

◆ delete()

delete ( $p_params)

This methods delete archive entries in the zip archive. Notice that at least one filtering rule (set by the variable parameter list) must be set. Also notice that if you delete a folder entry, only the folder entry is deleted, not all the files bellonging to this folder. The supported variable parameters for this method are : 'by_name' : It can be a string with file/dir names separated by ',', or an array of file/dir names to delete from the archive. 'by_index' : A string with range of indexes separated by ',', (sample "1,3-5,12"). 'by_ereg' : A regular expression (ereg) that must match the extracted filename. 'by_preg' : A regular expression (preg) that must match the extracted filename.

@access public

Parameters
mixed$p_paramsAn array of variable parameters and values.
Returns
mixed An array of file description on success, 0 on an unrecoverable failure, an error code is logged.

Definition at line 475 of file Archive_Zip.php.

◆ duplicate()

duplicate ( $p_archive)

This method creates an archive by copying the content of an other one. If the archive already exist, it is replaced by the new one without any warning.

@access public

Parameters
mixed$p_archiveIt can be a valid Archive_Zip object or the filename of a valid zip archive.
Returns
int 1 on success, 0 on failure.

Definition at line 584 of file Archive_Zip.php.

◆ errorCode()

errorCode ( )

Method that gives the lastest error code.

@access public

Returns
int The error code value.

Definition at line 675 of file Archive_Zip.php.

◆ errorInfo()

errorInfo ( $p_full = false)

This method returns the description associated with the latest error.

@access public

Parameters
bool$p_fullIf set to true gives the description with the error code, the name and the description. If set to false gives only the description and the error code.
Returns
string The error description.

Definition at line 725 of file Archive_Zip.php.

◆ errorName()

errorName ( $p_with_code = false)

This method gives the latest error code name.

@access public

Parameters
bool$p_with_codeIf true, gives the name and the int value.
Returns
string The error name.

Definition at line 689 of file Archive_Zip.php.

◆ extract()

extract ( $p_params = 0)

This method extract the files and folders which are in the zip archive. It can extract all the archive or a part of the archive by using filter feature (extract by name, by index, by ereg, by preg). The extraction can occur in the current path or an other path. All the advanced features are activated by the use of variable parameters. The return value is an array of entry descriptions which gives information on extracted files (See listContent()). The method may return a success value (an array) even if some files are not correctly extracted (see the file status in listContent()). The supported variable parameters for this method are : 'add_path' : Path where the files and directories are to be extracted 'remove_path' : First part ('root' part) of the memorized path (if similar) to remove while extracting. 'remove_all_path' : Remove all the memorized path while extracting. 'extract_as_string' : 'set_chmod' : After the extraction of the file the indicated mode will be set. 'by_name' : It can be a string with file/dir names separated by ',', or an array of file/dir names to extract from the archive. 'by_index' : A string with range of indexes separated by ',', (sample "1,3-5,12"). 'by_ereg' : A regular expression (ereg) that must match the extracted filename. 'by_preg' : A regular expression (preg) that must match the extracted filename. 'callback_pre_extract' : A callback function that will be called before each entry extraction. 'callback_post_extract' : A callback function that will be called after each entry extraction.

@access public

Parameters
mixed$p_paramsAn array of variable parameters and values.
Returns
mixed An array of file description on success, 0 on an unrecoverable failure, an error code is logged.

Definition at line 410 of file Archive_Zip.php.

◆ listContent()

listContent ( )

This method gives the names and properties of the files and directories which are present in the zip archive. The properties of each entries in the list are : filename : Name of the file. For create() or add() it's the filename given by the user. For an extract() it's the filename of the extracted file. stored_filename : Name of the file / directory stored in the archive. size : Size of the stored file. compressed_size : Size of the file's data compressed in the archive (without the zip headers overhead) mtime : Last known modification date of the file (UNIX timestamp) comment : Comment associated with the file folder : true | false (indicates if the entry is a folder) index : index of the file in the archive (-1 when not available) status : status of the action on the entry (depending of the action) : Values are : ok : OK ! filtered : the file/dir was not extracted (filtered by user) already_a_directory : the file can't be extracted because a directory with the same name already exists write_protected : the file can't be extracted because a file with the same name already exists and is write protected newer_exist : the file was not extracted because a newer file already exists path_creation_fail : the file is not extracted because the folder does not exists and can't be created write_error : the file was not extracted because there was a error while writing the file read_error : the file was not extracted because there was a error while reading the file invalid_header : the file was not extracted because of an archive format error (bad file header) Note that each time a method can continue operating when there is an error on a single file, the error is only logged in the file status.

@access public

Returns
mixed An array of file description on success, 0 on an unrecoverable failure, an error code is logged.

Definition at line 353 of file Archive_Zip.php.

◆ merge()

merge ( $p_archive_to_add)

This method merge a valid zip archive at the end of the archive identified by the Archive_Zip object. If the archive ($this) does not exist, the merge becomes a duplicate. If the archive to add does not exist, the merge is a success.

@access public

Parameters
mixed$p_archive_to_addIt can be a valid Archive_Zip object or the filename of a valid zip archive.
Returns
int 1 on success, 0 on failure.

Definition at line 631 of file Archive_Zip.php.

◆ properties()

properties ( )

This method gives the global properties of the archive. The properties are : nb : Number of files in the archive comment : Comment associated with the archive file status : not_exist, ok

@access public

Returns
mixed An array with the global properties or 0 on error.

Definition at line 529 of file Archive_Zip.php.

Field Documentation

◆ $_error_code

$_error_code =1

Definition at line 121 of file Archive_Zip.php.

◆ $_error_string

$_error_string =''

Definition at line 126 of file Archive_Zip.php.

◆ $_zip_fd

$_zip_fd =0

Definition at line 116 of file Archive_Zip.php.

◆ $_zipname

$_zipname =''

Definition at line 109 of file Archive_Zip.php.


The documentation for this class was generated from the following file: