本文整理汇总了PHP中Zip::privErrorLog方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::privErrorLog方法的具体用法?PHP Zip::privErrorLog怎么用?PHP Zip::privErrorLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zip
的用法示例。
在下文中一共展示了Zip::privErrorLog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
//.........这里部分代码省略.........