本文整理汇总了PHP中PclZipUtilPathReduction函数的典型用法代码示例。如果您正苦于以下问题:PHP PclZipUtilPathReduction函数的具体用法?PHP PclZipUtilPathReduction怎么用?PHP PclZipUtilPathReduction使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PclZipUtilPathReduction函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: privCalculateStoredFilename
function privCalculateStoredFilename(&$p_filedescr, &$p_options)
{
//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'");
$v_result = 1;
// ----- Working variables
$p_filename = $p_filedescr['filename'];
if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
$p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
} else {
$p_add_dir = '';
}
if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
$p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
} else {
$p_remove_dir = '';
}
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path ='".$p_remove_dir."'");
if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
$p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
} else {
$p_remove_all_dir = 0;
}
// ----- Look for full name change
if (isset($p_filedescr['new_full_name'])) {
// ----- Remove drive letter if any
$v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'");
} else {
// ----- Look for short name change
// Its when we cahnge just the filename but not the path
if (isset($p_filedescr['new_short_name'])) {
$v_path_info = pathinfo($p_filename);
$v_dir = '';
if ($v_path_info['dirname'] != '') {
$v_dir = $v_path_info['dirname'] . '/';
}
$v_stored_filename = $v_dir . $p_filedescr['new_short_name'];
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'");
} else {
// ----- Calculate the stored filename
$v_stored_filename = $p_filename;
}
// ----- Look for all path to remove
if ($p_remove_all_dir) {
$v_stored_filename = basename($p_filename);
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'");
} else {
if ($p_remove_dir != "") {
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Partial path to remove");
if (substr($p_remove_dir, -1) != '/') {
$p_remove_dir .= "/";
}
if (substr($p_filename, 0, 2) == "./" || substr($p_remove_dir, 0, 2) == "./") {
if (substr($p_filename, 0, 2) == "./" && substr($p_remove_dir, 0, 2) != "./") {
$p_remove_dir = "./" . $p_remove_dir;
}
if (substr($p_filename, 0, 2) != "./" && substr($p_remove_dir, 0, 2) == "./") {
$p_remove_dir = substr($p_remove_dir, 2);
}
}
$v_compare = PclZipUtilPathInclusion($p_remove_dir, $v_stored_filename);
if ($v_compare > 0) {
if ($v_compare == 2) {
$v_stored_filename = "";
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
} else {
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'");
$v_stored_filename = substr($v_stored_filename, strlen($p_remove_dir));
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'");
}
}
}
}
// ----- Remove drive letter if any
$v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
// ----- Look for path to add
if ($p_add_dir != "") {
if (substr($p_add_dir, -1) == "/") {
$v_stored_filename = $p_add_dir . $v_stored_filename;
} else {
$v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
}
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
}
}
// ----- Filename (reduce the path of stored name)
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
$p_filedescr['stored_filename'] = $v_stored_filename;
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename']));
// ----- Return
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
return $v_result;
}
示例2: privAddFile
function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
{
//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='$p_filename', add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
$v_result = 1;
if ($p_filename == "") {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
// ----- Return
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
return PclZip::errorCode();
}
// ----- Calculate the stored filename
$v_stored_filename = $p_filename;
// ----- Look for all path to remove
if ($p_remove_all_dir) {
$v_stored_filename = basename($p_filename);
} else {
if ($p_remove_dir != "") {
if (substr($p_remove_dir, -1) != '/') {
$p_remove_dir .= "/";
}
if (substr($p_filename, 0, 2) == "./" || substr($p_remove_dir, 0, 2) == "./") {
if (substr($p_filename, 0, 2) == "./" && substr($p_remove_dir, 0, 2) != "./") {
$p_remove_dir = "./" . $p_remove_dir;
}
if (substr($p_filename, 0, 2) != "./" && substr($p_remove_dir, 0, 2) == "./") {
$p_remove_dir = substr($p_remove_dir, 2);
}
}
$v_compare = PclZipUtilPathInclusion($p_remove_dir, $p_filename);
if ($v_compare > 0) {
if ($v_compare == 2) {
$v_stored_filename = "";
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
} else {
$v_stored_filename = substr($p_filename, strlen($p_remove_dir));
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$p_filename' = '$v_stored_filename'");
}
}
}
}
// ----- Look for path to add
if ($p_add_dir != "") {
if (substr($p_add_dir, -1) == "/") {
$v_stored_filename = $p_add_dir . $v_stored_filename;
} else {
$v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
}
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
}
// ----- Filename (reduce the path of stored name)
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '$v_stored_filename', strlen ".strlen($v_stored_filename));
/* filename length moved after call-back in release 1.3
// ----- Check the path length
if (strlen($v_stored_filename) > 0xFF)
{
// ----- Error log
PclZip::privErrorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'");
// ----- Return
//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
return PclZip::errorCode();
}
*/
// ----- Set the file properties
clearstatcache();
$p_header['version'] = 20;
$p_header['version_extracted'] = 10;
$p_header['flag'] = 0;
$p_header['compression'] = 0;
$p_header['mtime'] = filemtime($p_filename);
$p_header['crc'] = 0;
$p_header['compressed_size'] = 0;
$p_header['size'] = filesize($p_filename);
$p_header['filename_len'] = strlen($p_filename);
$p_header['extra_len'] = 0;
$p_header['comment_len'] = 0;
$p_header['disk'] = 0;
$p_header['internal'] = 0;
$p_header['external'] = is_file($p_filename) ? 0xfe49ffe0 : 0x41ff0010;
$p_header['offset'] = 0;
$p_header['filename'] = $p_filename;
$p_header['stored_filename'] = $v_stored_filename;
$p_header['extra'] = '';
$p_header['comment'] = '';
$p_header['status'] = 'ok';
$p_header['index'] = -1;
// ----- Look for pre-add callback
if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_header, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
eval('$v_result = ' . $p_options[PCLZIP_CB_PRE_ADD] . '(PCLZIP_CB_PRE_ADD, $v_local_header);');
if ($v_result == 0) {
// ----- Change the file status
//.........这里部分代码省略.........
示例3: privConvertHeader2FileInfo
function privConvertHeader2FileInfo($p_header, &$p_info)
{
$v_result = 1;
// ----- Get the interesting attributes
$v_temp_path = PclZipUtilPathReduction($p_header['filename']);
$p_info['filename'] = $v_temp_path;
$v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
$p_info['stored_filename'] = $v_temp_path;
$p_info['size'] = $p_header['size'];
$p_info['compressed_size'] = $p_header['compressed_size'];
$p_info['mtime'] = $p_header['mtime'];
$p_info['comment'] = $p_header['comment'];
$p_info['folder'] = ($p_header['external'] & 0x10) == 0x10;
$p_info['index'] = $p_header['index'];
$p_info['status'] = $p_header['status'];
$p_info['crc'] = $p_header['crc'];
// ----- Return
return $v_result;
}
示例4: privCalculateStoredFilename
function privCalculateStoredFilename(&$p_filedescr, &$p_options)
{
$v_result = 1;
$p_filename = $p_filedescr['filename'];
if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
$p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
} else {
$p_add_dir = '';
}
if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
$p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
} else {
$p_remove_dir = '';
}
if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
$p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
} else {
$p_remove_all_dir = 0;
}
if (isset($p_filedescr['new_full_name'])) {
$v_stored_filename = $p_filedescr['new_full_name'];
} else {
if (isset($p_filedescr['new_short_name'])) {
$v_path_info = pathinfo($p_filename);
$v_dir = '';
if ($v_path_info['dirname'] != '') {
$v_dir = $v_path_info['dirname'] . '/';
}
$v_stored_filename = $v_dir . $p_filedescr['new_short_name'];
} else {
$v_stored_filename = $p_filename;
}
if ($p_remove_all_dir) {
$v_stored_filename = basename($p_filename);
} else {
if ($p_remove_dir != "") {
if (substr($p_remove_dir, -1) != '/') {
$p_remove_dir .= "/";
}
if (substr($p_filename, 0, 2) == "./" || substr($p_remove_dir, 0, 2) == "./") {
if (substr($p_filename, 0, 2) == "./" && substr($p_remove_dir, 0, 2) != "./") {
$p_remove_dir = "./" . $p_remove_dir;
}
if (substr($p_filename, 0, 2) != "./" && substr($p_remove_dir, 0, 2) == "./") {
$p_remove_dir = substr($p_remove_dir, 2);
}
}
$v_compare = PclZipUtilPathInclusion($p_remove_dir, $v_stored_filename);
if ($v_compare > 0) {
if ($v_compare == 2) {
$v_stored_filename = "";
} else {
$v_stored_filename = substr($v_stored_filename, strlen($p_remove_dir));
}
}
}
}
if ($p_add_dir != "") {
if (substr($p_add_dir, -1) == "/") {
$v_stored_filename = $p_add_dir . $v_stored_filename;
} else {
$v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
}
}
}
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
$p_filedescr['stored_filename'] = $v_stored_filename;
return $v_result;
}
示例5: privAddFile
function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
{
PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='{$p_filename}', add_dir='{$p_add_dir}', remove_dir='{$p_remove_dir}'");
$v_result = 1;
if ($p_filename == "") {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
// ----- Return
PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
return PclZip::errorCode();
}
// ----- Calculate the stored filename
$v_stored_filename = $p_filename;
// ----- Look for all path to remove
if ($p_remove_all_dir) {
$v_stored_filename = basename($p_filename);
} else {
if ($p_remove_dir != "") {
if (substr($p_remove_dir, -1) != '/') {
$p_remove_dir .= "/";
}
if (substr($p_filename, 0, 2) == "./" || substr($p_remove_dir, 0, 2) == "./") {
if (substr($p_filename, 0, 2) == "./" && substr($p_remove_dir, 0, 2) != "./") {
$p_remove_dir = "./" . $p_remove_dir;
}
if (substr($p_filename, 0, 2) != "./" && substr($p_remove_dir, 0, 2) == "./") {
$p_remove_dir = substr($p_remove_dir, 2);
}
}
if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) {
$v_stored_filename = substr($p_filename, strlen($p_remove_dir));
PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path '{$p_remove_dir}' in file '{$p_filename}' = '{$v_stored_filename}'");
}
}
}
// ----- Look for path to add
if ($p_add_dir != "") {
if (substr($p_add_dir, -1) == "/") {
$v_stored_filename = $p_add_dir . $v_stored_filename;
} else {
$v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
}
PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '{$p_add_dir}' in file '{$p_filename}' = '{$v_stored_filename}'");
}
// ----- Filename (reduce the path of stored name)
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '{$v_stored_filename}', strlen " . strlen($v_stored_filename));
/* filename length moved after call-back in release 1.3
// ----- Check the path length
if (strlen($v_stored_filename) > 0xFF)
{
// ----- Error log
PclZip::privErrorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'");
// ----- Return
PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
return PclZip::errorCode();
}
*/
// ----- Set the file properties
clearstatcache();
$p_header['version'] = 20;
$p_header['version_extracted'] = 10;
$p_header['flag'] = 0;
$p_header['compression'] = 0;
$p_header['mtime'] = filemtime($p_filename);
$p_header['crc'] = 0;
$p_header['compressed_size'] = 0;
$p_header['size'] = filesize($p_filename);
$p_header['filename_len'] = strlen($p_filename);
$p_header['extra_len'] = 0;
$p_header['comment_len'] = 0;
$p_header['disk'] = 0;
$p_header['internal'] = 0;
$p_header['external'] = is_file($p_filename) ? 0.0 : 0x41ff0010;
$p_header['offset'] = 0;
$p_header['filename'] = $p_filename;
$p_header['stored_filename'] = $v_stored_filename;
$p_header['extra'] = '';
$p_header['comment'] = '';
$p_header['status'] = 'ok';
// ----- Look for pre-add callback
if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '" . $p_options[PCLZIP_CB_PRE_ADD] . "()') is defined for the extraction");
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_header, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
eval('$v_result = ' . $p_options[PCLZIP_CB_PRE_ADD] . '(PCLZIP_CB_PRE_ADD, $v_local_header);');
if ($v_result == 0) {
// ----- Change the file status
$p_header['status'] = "skipped";
$v_result = 1;
}
// ----- Update the informations
// Only some fields can be modified
if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
$p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
//.........这里部分代码省略.........
示例6: privAddFile
function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
{
$v_result = 1;
if ($p_filename == "") {
Zip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
return Zip::errorCode();
}
$v_stored_filename = $p_filename;
if ($p_remove_all_dir) {
$v_stored_filename = basename($p_filename);
} elseif ($p_remove_dir != "") {
if (substr($p_remove_dir, -1) != '/') {
$p_remove_dir .= "/";
}
if (substr($p_filename, 0, 2) == "./" || substr($p_remove_dir, 0, 2) == "./") {
if (substr($p_filename, 0, 2) == "./" && substr($p_remove_dir, 0, 2) != "./") {
$p_remove_dir = "./" . $p_remove_dir;
}
if (substr($p_filename, 0, 2) != "./" && substr($p_remove_dir, 0, 2) == "./") {
$p_remove_dir = substr($p_remove_dir, 2);
}
}
$v_compare = PclZipUtilPathInclusion($p_remove_dir, $p_filename);
if ($v_compare > 0) {
if ($v_compare == 2) {
$v_stored_filename = "";
} else {
$v_stored_filename = substr($p_filename, strlen($p_remove_dir));
}
}
}
if ($p_add_dir != "") {
if (substr($p_add_dir, -1) == "/") {
$v_stored_filename = $p_add_dir . $v_stored_filename;
} else {
$v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
}
}
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
clearstatcache();
$p_header['version'] = 20;
$p_header['version_extracted'] = 10;
$p_header['flag'] = 0;
$p_header['compression'] = 0;
$p_header['mtime'] = filemtime($p_filename);
$p_header['crc'] = 0;
$p_header['compressed_size'] = 0;
$p_header['size'] = filesize($p_filename);
$p_header['filename_len'] = strlen($p_filename);
$p_header['extra_len'] = 0;
$p_header['comment_len'] = 0;
$p_header['disk'] = 0;
$p_header['internal'] = 0;
$p_header['external'] = is_file($p_filename) ? 0x0 : 0x10;
$p_header['offset'] = 0;
$p_header['filename'] = $p_filename;
$p_header['stored_filename'] = $v_stored_filename;
$p_header['extra'] = '';
$p_header['comment'] = '';
$p_header['status'] = 'ok';
$p_header['index'] = -1;
if ($p_header['stored_filename'] == "") {
$p_header['status'] = "filtered";
}
if (strlen($p_header['stored_filename']) > 0xff) {
$p_header['status'] = 'filename_too_long';
}
if ($p_header['status'] == 'ok') {
if (is_file($p_filename)) {
if (($v_file = @fopen($p_filename, "rb")) == 0) {
Zip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '{$p_filename}' in binary read mode");
return Zip::errorCode();
}
if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
$v_content_compressed = @fread($v_file, $p_header['size']);
$p_header['crc'] = @crc32($v_content_compressed);
$p_header['compressed_size'] = $p_header['size'];
$p_header['compression'] = 0;
} else {
$v_content = @fread($v_file, $p_header['size']);
$p_header['crc'] = @crc32($v_content);
$v_content_compressed = @gzdeflate($v_content);
$p_header['compressed_size'] = strlen($v_content_compressed);
$p_header['compression'] = 8;
}
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
@fclose($v_file);
return $v_result;
}
@fwrite($this->zip_fd, $v_content_compressed, $p_header['compressed_size']);
@fclose($v_file);
} else {
if (@substr($p_header['stored_filename'], -1) != '/') {
$p_header['stored_filename'] .= '/';
}
$p_header['size'] = 0;
$p_header['external'] = 0x10;
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
return $v_result;
}
//.........这里部分代码省略.........
示例7: privAddFile
function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir)
{
PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='$p_filename', add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
$v_result=1;
if ($p_filename == "")
{
// ----- Error log
PclErrorLog(-3, "Invalid file list parameter (invalid or empty list)");
// ----- Return
PclTraceFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());
return PclErrorCode();
}
// ----- Calculate the stored filename
$v_stored_filename = $p_filename;
if ($p_remove_dir != "")
{
if (substr($p_remove_dir, -1) != '/')
$p_remove_dir .= "/";
if ((substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./"))
{
if ((substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./"))
$p_remove_dir = "./".$p_remove_dir;
if ((substr($p_filename, 0, 2) != "./") && (substr($p_remove_dir, 0, 2) == "./"))
$p_remove_dir = substr($p_remove_dir, 2);
}
if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)
{
$v_stored_filename = substr($p_filename, strlen($p_remove_dir));
PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path '$p_remove_dir' in file '$p_filename' = '$v_stored_filename'");
}
}
if ($p_add_dir != "")
{
if (substr($p_add_dir, -1) == "/")
$v_stored_filename = $p_add_dir.$v_stored_filename;
else
$v_stored_filename = $p_add_dir."/".$v_stored_filename;
PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
}
// ----- Filename (reduce the path of stored name)
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '$v_stored_filename', strlen ".strlen($v_stored_filename));
// ----- Check the path length
if (strlen($v_stored_filename) > 0xFF)
{
// ----- Error log
PclErrorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'");
// ----- Return
PclTraceFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());
return PclErrorCode();
}
// ----- Set the file properties
clearstatcache();
$p_header['version'] = 20;
$p_header['version_extracted'] = 10;
$p_header['flag'] = 0;
$p_header['compression'] = 0;
$p_header['mtime'] = filemtime($p_filename);
$p_header['crc'] = 0;
$p_header['compressed_size'] = 0;
$p_header['size'] = filesize($p_filename);
$p_header['filename_len'] = strlen($p_filename);
$p_header['extra_len'] = 0;
$p_header['comment_len'] = 0;
$p_header['disk'] = 0;
$p_header['internal'] = 0;
$p_header['external'] = 0xFE49FFE0; // Value for a file : To be checked
$p_header['offset'] = 0;
$p_header['filename'] = $p_filename;
$p_header['stored_filename'] = $v_stored_filename;
$p_header['extra'] = '';
$p_header['comment'] = '';
$p_header['status'] = 'ok';
// ----- Look for a file
if (is_file($p_filename))
{
// ----- Open the source file
if (($v_file = fopen($p_filename, "rb")) == 0)
{
// ----- Error log
PclErrorLog(-2, "Unable to open file '$p_filename' in binary read mode");
// ----- Return
PclTraceFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());
return PclErrorCode();
}
// ----- Creates a compressed temporary file
if (($v_file_compressed = @gzopen($p_filename.'.gz', "wb")) == 0)
{
//.........这里部分代码省略.........