ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
pclzip.lib.php File Reference

Go to the source code of this file.

Data Structures

class  PclZip

Functions

 PclZipUtilPathReduction ($p_dir)
 PclZipUtilPathInclusion ($p_dir, $p_path)
 PclZipUtilCopyBlock ($p_src, $p_dest, $p_size, $p_mode=0)
 PclZipUtilRename ($p_src, $p_dest)
 PclZipUtilOptionText ($p_option)
 PclZipUtilTranslateWinPath ($p_path, $p_remove_disk_letter=true)

Variables

if(!defined('PCLZIP_READ_BLOCK_SIZE'))
if(!defined('PCLZIP_SEPARATOR'))
if(!defined('PCLZIP_ERROR_EXTERNAL'))
if(!defined('PCLZIP_TEMPORARY_DIR'))
if(!defined('PCLZIP_TEMPORARY_FILE_RATIO')) 
$g_pclzip_version = "2.8.2"
const PCLZIP_ERR_USER_ABORTED = 2
const PCLZIP_ERR_NO_ERROR = 0
const PCLZIP_ERR_WRITE_OPEN_FAIL = -1
const PCLZIP_ERR_READ_OPEN_FAIL = -2
const PCLZIP_ERR_INVALID_PARAMETER = -3
const PCLZIP_ERR_MISSING_FILE = -4
const PCLZIP_ERR_FILENAME_TOO_LONG = -5
const PCLZIP_ERR_INVALID_ZIP = -6
const PCLZIP_ERR_BAD_EXTRACTED_FILE = -7
const PCLZIP_ERR_DIR_CREATE_FAIL = -8
const PCLZIP_ERR_BAD_EXTENSION = -9
const PCLZIP_ERR_BAD_FORMAT = -10
const PCLZIP_ERR_DELETE_FILE_FAIL = -11
const PCLZIP_ERR_RENAME_FILE_FAIL = -12
const PCLZIP_ERR_BAD_CHECKSUM = -13
const PCLZIP_ERR_INVALID_ARCHIVE_ZIP = -14
const PCLZIP_ERR_MISSING_OPTION_VALUE = -15
const PCLZIP_ERR_INVALID_OPTION_VALUE = -16
const PCLZIP_ERR_ALREADY_A_DIRECTORY = -17
const PCLZIP_ERR_UNSUPPORTED_COMPRESSION = -18
const PCLZIP_ERR_UNSUPPORTED_ENCRYPTION = -19
const PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE = -20
const PCLZIP_ERR_DIRECTORY_RESTRICTION = -21
const PCLZIP_OPT_PATH = 77001
const PCLZIP_OPT_ADD_PATH = 77002
const PCLZIP_OPT_REMOVE_PATH = 77003
const PCLZIP_OPT_REMOVE_ALL_PATH = 77004
const PCLZIP_OPT_SET_CHMOD = 77005
const PCLZIP_OPT_EXTRACT_AS_STRING = 77006
const PCLZIP_OPT_NO_COMPRESSION = 77007
const PCLZIP_OPT_BY_NAME = 77008
const PCLZIP_OPT_BY_INDEX = 77009
const PCLZIP_OPT_BY_EREG = 77010
const PCLZIP_OPT_BY_PREG = 77011
const PCLZIP_OPT_COMMENT = 77012
const PCLZIP_OPT_ADD_COMMENT = 77013
const PCLZIP_OPT_PREPEND_COMMENT = 77014
const PCLZIP_OPT_EXTRACT_IN_OUTPUT = 77015
const PCLZIP_OPT_REPLACE_NEWER = 77016
const PCLZIP_OPT_STOP_ON_ERROR = 77017
const PCLZIP_OPT_EXTRACT_DIR_RESTRICTION = 77019
const PCLZIP_OPT_TEMP_FILE_THRESHOLD = 77020
const PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD = 77020
const PCLZIP_OPT_TEMP_FILE_ON = 77021
const PCLZIP_OPT_ADD_TEMP_FILE_ON = 77021
const PCLZIP_OPT_TEMP_FILE_OFF = 77022
const PCLZIP_OPT_ADD_TEMP_FILE_OFF = 77022
const PCLZIP_ATT_FILE_NAME = 79001
const PCLZIP_ATT_FILE_NEW_SHORT_NAME = 79002
const PCLZIP_ATT_FILE_NEW_FULL_NAME = 79003
const PCLZIP_ATT_FILE_MTIME = 79004
const PCLZIP_ATT_FILE_CONTENT = 79005
const PCLZIP_ATT_FILE_COMMENT = 79006
const PCLZIP_CB_PRE_EXTRACT = 78001
const PCLZIP_CB_POST_EXTRACT = 78002
const PCLZIP_CB_PRE_ADD = 78003
const PCLZIP_CB_POST_ADD = 78004

Function Documentation

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

Definition at line 5554 of file pclzip.lib.php.

Referenced by PclZip\privDeleteByRule().

{
$v_result = 1;
if ($p_mode==0)
{
while ($p_size != 0)
{
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($p_src, $v_read_size);
@fwrite($p_dest, $v_buffer, $v_read_size);
$p_size -= $v_read_size;
}
}
else if ($p_mode==1)
{
while ($p_size != 0)
{
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @gzread($p_src, $v_read_size);
@fwrite($p_dest, $v_buffer, $v_read_size);
$p_size -= $v_read_size;
}
}
else if ($p_mode==2)
{
while ($p_size != 0)
{
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($p_src, $v_read_size);
@gzwrite($p_dest, $v_buffer, $v_read_size);
$p_size -= $v_read_size;
}
}
else if ($p_mode==3)
{
while ($p_size != 0)
{
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @gzread($p_src, $v_read_size);
@gzwrite($p_dest, $v_buffer, $v_read_size);
$p_size -= $v_read_size;
}
}
// ----- Return
return $v_result;
}

+ Here is the caller graph for this function:

PclZipUtilOptionText (   $p_option)

Definition at line 5646 of file pclzip.lib.php.

{
$v_list = get_defined_constants();
for (reset($v_list); $v_key = key($v_list); next($v_list)) {
$v_prefix = substr($v_key, 0, 10);
if (( ($v_prefix == 'PCLZIP_OPT')
|| ($v_prefix == 'PCLZIP_CB_')
|| ($v_prefix == 'PCLZIP_ATT'))
&& ($v_list[$v_key] == $p_option)) {
return $v_key;
}
}
$v_result = 'Unknown';
return $v_result;
}
PclZipUtilPathInclusion (   $p_dir,
  $p_path 
)

Definition at line 5477 of file pclzip.lib.php.

References PclZipUtilTranslateWinPath().

{
$v_result = 1;
// ----- Look for path beginning by ./
if ( ($p_dir == '.')
|| ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
$p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
}
if ( ($p_path == '.')
|| ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
$p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
}
// ----- Explode dir and path by directory separator
$v_list_dir = explode("/", $p_dir);
$v_list_dir_size = sizeof($v_list_dir);
$v_list_path = explode("/", $p_path);
$v_list_path_size = sizeof($v_list_path);
// ----- Study directories paths
$i = 0;
$j = 0;
while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
// ----- Look for empty dir (path reduction)
if ($v_list_dir[$i] == '') {
$i++;
continue;
}
if ($v_list_path[$j] == '') {
$j++;
continue;
}
// ----- Compare the items
if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
$v_result = 0;
}
// ----- Next items
$i++;
$j++;
}
// ----- Look if everything seems to be the same
if ($v_result) {
// ----- Skip all the empty items
while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
// ----- There are exactly the same
$v_result = 2;
}
else if ($i < $v_list_dir_size) {
// ----- The path is shorter than the dir
$v_result = 0;
}
}
// ----- Return
return $v_result;
}

+ Here is the call graph for this function:

PclZipUtilPathReduction (   $p_dir)

Definition at line 5396 of file pclzip.lib.php.

{
$v_result = "";
// ----- Look for not empty path
if ($p_dir != "") {
// ----- Explode path by directory names
$v_list = explode("/", $p_dir);
// ----- Study directories from last to first
$v_skip = 0;
for ($i=sizeof($v_list)-1; $i>=0; $i--) {
// ----- Look for current path
if ($v_list[$i] == ".") {
// ----- Ignore this directory
// Should be the first $i=0, but no check is done
}
else if ($v_list[$i] == "..") {
$v_skip++;
}
else if ($v_list[$i] == "") {
// ----- First '/' i.e. root slash
if ($i == 0) {
$v_result = "/".$v_result;
if ($v_skip > 0) {
// ----- It is an invalid path, so the path is not modified
// TBC
$v_result = $p_dir;
$v_skip = 0;
}
}
// ----- Last '/' i.e. indicates a directory
else if ($i == (sizeof($v_list)-1)) {
$v_result = $v_list[$i];
}
// ----- Double '/' inside the path
else {
// ----- Ignore only the double '//' in path,
// but not the first and last '/'
}
}
else {
// ----- Look for item to skip
if ($v_skip > 0) {
$v_skip--;
}
else {
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
}
}
}
// ----- Look for skip
if ($v_skip > 0) {
while ($v_skip > 0) {
$v_result = '../'.$v_result;
$v_skip--;
}
}
}
// ----- Return
return $v_result;
}
PclZipUtilRename (   $p_src,
  $p_dest 
)

Definition at line 5616 of file pclzip.lib.php.

Referenced by PclZip\privDeleteByRule().

{
$v_result = 1;
// ----- Try to rename the files
if (!@rename($p_src, $p_dest)) {
// ----- Try to copy & unlink the src
if (!@copy($p_src, $p_dest)) {
$v_result = 0;
}
else if (!@unlink($p_src)) {
$v_result = 0;
}
}
// ----- Return
return $v_result;
}

+ Here is the caller graph for this function:

PclZipUtilTranslateWinPath (   $p_path,
  $p_remove_disk_letter = true 
)

Definition at line 5677 of file pclzip.lib.php.

Referenced by PclZipUtilPathInclusion().

{
if (stristr(php_uname(), 'windows')) {
// ----- Look for potential disk letter
if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
$p_path = substr($p_path, $v_position+1);
}
// ----- Change potential windows directory separator
if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
$p_path = strtr($p_path, '\\', '/');
}
}
return $p_path;
}

+ Here is the caller graph for this function:

Variable Documentation

if (!defined('PCLZIP_READ_BLOCK_SIZE')) if (!defined('PCLZIP_SEPARATOR')) if (!defined('PCLZIP_ERROR_EXTERNAL')) if (!defined('PCLZIP_TEMPORARY_DIR')) if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) $g_pclzip_version = "2.8.2"

Definition at line 86 of file pclzip.lib.php.

const PCLZIP_ATT_FILE_COMMENT = 79006

Definition at line 162 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_ATT_FILE_CONTENT = 79005

Definition at line 161 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_ATT_FILE_MTIME = 79004

Definition at line 160 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_ATT_FILE_NAME = 79001

Definition at line 157 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_ATT_FILE_NEW_FULL_NAME = 79003

Definition at line 159 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_ATT_FILE_NEW_SHORT_NAME = 79002

Definition at line 158 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_CB_POST_ADD = 78004

Definition at line 168 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_CB_POST_EXTRACT = 78002

Definition at line 166 of file pclzip.lib.php.

Referenced by PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_CB_PRE_ADD = 78003

Definition at line 167 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_CB_PRE_EXTRACT = 78001

Definition at line 165 of file pclzip.lib.php.

Referenced by PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_ERR_ALREADY_A_DIRECTORY = -17

Definition at line 121 of file pclzip.lib.php.

const PCLZIP_ERR_BAD_CHECKSUM = -13

Definition at line 117 of file pclzip.lib.php.

const PCLZIP_ERR_BAD_EXTENSION = -9

Definition at line 113 of file pclzip.lib.php.

const PCLZIP_ERR_BAD_EXTRACTED_FILE = -7

Definition at line 111 of file pclzip.lib.php.

const PCLZIP_ERR_BAD_FORMAT = -10

Definition at line 114 of file pclzip.lib.php.

const PCLZIP_ERR_DELETE_FILE_FAIL = -11

Definition at line 115 of file pclzip.lib.php.

const PCLZIP_ERR_DIR_CREATE_FAIL = -8

Definition at line 112 of file pclzip.lib.php.

Referenced by PclZip\privDirCheck().

const PCLZIP_ERR_DIRECTORY_RESTRICTION = -21

Definition at line 125 of file pclzip.lib.php.

const PCLZIP_ERR_FILENAME_TOO_LONG = -5

Definition at line 109 of file pclzip.lib.php.

const PCLZIP_ERR_INVALID_ARCHIVE_ZIP = -14

Definition at line 118 of file pclzip.lib.php.

Referenced by PclZip\privDeleteByRule().

const PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE = -20

Definition at line 124 of file pclzip.lib.php.

const PCLZIP_ERR_INVALID_OPTION_VALUE = -16

Definition at line 120 of file pclzip.lib.php.

const PCLZIP_ERR_INVALID_PARAMETER = -3

Definition at line 107 of file pclzip.lib.php.

Referenced by PclZip\add(), PclZip\create(), PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_ERR_INVALID_ZIP = -6

Definition at line 110 of file pclzip.lib.php.

const PCLZIP_ERR_MISSING_FILE = -4

Definition at line 108 of file pclzip.lib.php.

const PCLZIP_ERR_MISSING_OPTION_VALUE = -15

Definition at line 119 of file pclzip.lib.php.

const PCLZIP_ERR_NO_ERROR = 0

Definition at line 104 of file pclzip.lib.php.

const PCLZIP_ERR_READ_OPEN_FAIL = -2

Definition at line 106 of file pclzip.lib.php.

Referenced by PclZip\privMerge(), and PclZip\properties().

const PCLZIP_ERR_RENAME_FILE_FAIL = -12

Definition at line 116 of file pclzip.lib.php.

const PCLZIP_ERR_UNSUPPORTED_COMPRESSION = -18

Definition at line 122 of file pclzip.lib.php.

const PCLZIP_ERR_UNSUPPORTED_ENCRYPTION = -19

Definition at line 123 of file pclzip.lib.php.

const PCLZIP_ERR_USER_ABORTED = 2

Definition at line 103 of file pclzip.lib.php.

const PCLZIP_ERR_WRITE_OPEN_FAIL = -1

Definition at line 105 of file pclzip.lib.php.

const PCLZIP_OPT_ADD_COMMENT = 77013

Definition at line 140 of file pclzip.lib.php.

Referenced by PclZip\add().

const PCLZIP_OPT_ADD_PATH = 77002
const PCLZIP_OPT_ADD_TEMP_FILE_OFF = 77022

Definition at line 154 of file pclzip.lib.php.

const PCLZIP_OPT_ADD_TEMP_FILE_ON = 77021

Definition at line 152 of file pclzip.lib.php.

const PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD = 77020

Definition at line 150 of file pclzip.lib.php.

const PCLZIP_OPT_BY_EREG = 77010

Definition at line 137 of file pclzip.lib.php.

Referenced by PclZip\delete(), and PclZip\extract().

const PCLZIP_OPT_BY_INDEX = 77009
const PCLZIP_OPT_BY_NAME = 77008

Definition at line 135 of file pclzip.lib.php.

Referenced by PclZip\delete(), PclZip\extract(), and PclZip\privDeleteByRule().

const PCLZIP_OPT_BY_PREG = 77011

Definition at line 138 of file pclzip.lib.php.

Referenced by PclZip\delete(), PclZip\extract(), and PclZip\privDeleteByRule().

const PCLZIP_OPT_COMMENT = 77012

Definition at line 139 of file pclzip.lib.php.

Referenced by PclZip\add(), PclZip\create(), and PclZip\privDeleteByRule().

const PCLZIP_OPT_EXTRACT_AS_STRING = 77006

Definition at line 133 of file pclzip.lib.php.

Referenced by PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_EXTRACT_DIR_RESTRICTION = 77019

Definition at line 148 of file pclzip.lib.php.

Referenced by PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_EXTRACT_IN_OUTPUT = 77015

Definition at line 142 of file pclzip.lib.php.

Referenced by PclZip\extract().

const PCLZIP_OPT_NO_COMPRESSION = 77007

Definition at line 134 of file pclzip.lib.php.

Referenced by PclZip\add(), and PclZip\create().

const PCLZIP_OPT_PATH = 77001

Definition at line 128 of file pclzip.lib.php.

Referenced by PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_PREPEND_COMMENT = 77014

Definition at line 141 of file pclzip.lib.php.

Referenced by PclZip\add().

const PCLZIP_OPT_REMOVE_ALL_PATH = 77004

Definition at line 131 of file pclzip.lib.php.

Referenced by PclZip\add(), PclZip\create(), PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_REMOVE_PATH = 77003
const PCLZIP_OPT_REPLACE_NEWER = 77016

Definition at line 143 of file pclzip.lib.php.

Referenced by PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_SET_CHMOD = 77005

Definition at line 132 of file pclzip.lib.php.

Referenced by PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_STOP_ON_ERROR = 77017

Definition at line 144 of file pclzip.lib.php.

Referenced by PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_TEMP_FILE_OFF = 77022

Definition at line 153 of file pclzip.lib.php.

Referenced by PclZip\add(), PclZip\create(), PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_TEMP_FILE_ON = 77021

Definition at line 151 of file pclzip.lib.php.

Referenced by PclZip\add(), PclZip\create(), PclZip\extract(), and PclZip\extractByIndex().

const PCLZIP_OPT_TEMP_FILE_THRESHOLD = 77020

Definition at line 149 of file pclzip.lib.php.

Referenced by PclZip\add(), PclZip\create(), PclZip\extract(), and PclZip\extractByIndex().