Edit File by line
/home/barbar84/www/extracte.../filemang...
File: pclzip.lib.php
if (($p_is_dir) && (substr($p_dir, -1)=='/'))
[5000] Fix | Delete
{
[5001] Fix | Delete
$p_dir = substr($p_dir, 0, strlen($p_dir)-1);
[5002] Fix | Delete
}
[5003] Fix | Delete
[5004] Fix | Delete
// ----- Check the directory availability
[5005] Fix | Delete
if ((is_dir($p_dir)) || ($p_dir == ""))
[5006] Fix | Delete
{
[5007] Fix | Delete
return 1;
[5008] Fix | Delete
}
[5009] Fix | Delete
[5010] Fix | Delete
// ----- Extract parent directory
[5011] Fix | Delete
$p_parent_dir = dirname($p_dir);
[5012] Fix | Delete
[5013] Fix | Delete
// ----- Just a check
[5014] Fix | Delete
if ($p_parent_dir != $p_dir)
[5015] Fix | Delete
{
[5016] Fix | Delete
// ----- Look for parent directory
[5017] Fix | Delete
if ($p_parent_dir != "")
[5018] Fix | Delete
{
[5019] Fix | Delete
if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
[5020] Fix | Delete
{
[5021] Fix | Delete
return $v_result;
[5022] Fix | Delete
}
[5023] Fix | Delete
}
[5024] Fix | Delete
}
[5025] Fix | Delete
[5026] Fix | Delete
// ----- Create the directory
[5027] Fix | Delete
if (!@mkdir($p_dir, 0777))
[5028] Fix | Delete
{
[5029] Fix | Delete
// ----- Error log
[5030] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
[5031] Fix | Delete
[5032] Fix | Delete
// ----- Return
[5033] Fix | Delete
return PclZip::errorCode();
[5034] Fix | Delete
}
[5035] Fix | Delete
[5036] Fix | Delete
// ----- Return
[5037] Fix | Delete
return $v_result;
[5038] Fix | Delete
}
[5039] Fix | Delete
// --------------------------------------------------------------------------------
[5040] Fix | Delete
[5041] Fix | Delete
// --------------------------------------------------------------------------------
[5042] Fix | Delete
// Function : privMerge()
[5043] Fix | Delete
// Description :
[5044] Fix | Delete
// If $p_archive_to_add does not exist, the function exit with a success result.
[5045] Fix | Delete
// Parameters :
[5046] Fix | Delete
// Return Values :
[5047] Fix | Delete
// --------------------------------------------------------------------------------
[5048] Fix | Delete
function privMerge(&$p_archive_to_add)
[5049] Fix | Delete
{
[5050] Fix | Delete
$v_result=1;
[5051] Fix | Delete
[5052] Fix | Delete
// ----- Look if the archive_to_add exists
[5053] Fix | Delete
if (!is_file($p_archive_to_add->zipname))
[5054] Fix | Delete
{
[5055] Fix | Delete
[5056] Fix | Delete
// ----- Nothing to merge, so merge is a success
[5057] Fix | Delete
$v_result = 1;
[5058] Fix | Delete
[5059] Fix | Delete
// ----- Return
[5060] Fix | Delete
return $v_result;
[5061] Fix | Delete
}
[5062] Fix | Delete
[5063] Fix | Delete
// ----- Look if the archive exists
[5064] Fix | Delete
if (!is_file($this->zipname))
[5065] Fix | Delete
{
[5066] Fix | Delete
[5067] Fix | Delete
// ----- Do a duplicate
[5068] Fix | Delete
$v_result = $this->privDuplicate($p_archive_to_add->zipname);
[5069] Fix | Delete
[5070] Fix | Delete
// ----- Return
[5071] Fix | Delete
return $v_result;
[5072] Fix | Delete
}
[5073] Fix | Delete
[5074] Fix | Delete
// ----- Open the zip file
[5075] Fix | Delete
if (($v_result=$this->privOpenFd('rb')) != 1)
[5076] Fix | Delete
{
[5077] Fix | Delete
// ----- Return
[5078] Fix | Delete
return $v_result;
[5079] Fix | Delete
}
[5080] Fix | Delete
[5081] Fix | Delete
// ----- Read the central directory informations
[5082] Fix | Delete
$v_central_dir = array();
[5083] Fix | Delete
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
[5084] Fix | Delete
{
[5085] Fix | Delete
$this->privCloseFd();
[5086] Fix | Delete
return $v_result;
[5087] Fix | Delete
}
[5088] Fix | Delete
[5089] Fix | Delete
// ----- Go to beginning of File
[5090] Fix | Delete
@rewind($this->zip_fd);
[5091] Fix | Delete
[5092] Fix | Delete
// ----- Open the archive_to_add file
[5093] Fix | Delete
if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
[5094] Fix | Delete
{
[5095] Fix | Delete
$this->privCloseFd();
[5096] Fix | Delete
[5097] Fix | Delete
// ----- Return
[5098] Fix | Delete
return $v_result;
[5099] Fix | Delete
}
[5100] Fix | Delete
[5101] Fix | Delete
// ----- Read the central directory informations
[5102] Fix | Delete
$v_central_dir_to_add = array();
[5103] Fix | Delete
if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
[5104] Fix | Delete
{
[5105] Fix | Delete
$this->privCloseFd();
[5106] Fix | Delete
$p_archive_to_add->privCloseFd();
[5107] Fix | Delete
[5108] Fix | Delete
return $v_result;
[5109] Fix | Delete
}
[5110] Fix | Delete
[5111] Fix | Delete
// ----- Go to beginning of File
[5112] Fix | Delete
@rewind($p_archive_to_add->zip_fd);
[5113] Fix | Delete
[5114] Fix | Delete
// ----- Creates a temporay file
[5115] Fix | Delete
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
[5116] Fix | Delete
[5117] Fix | Delete
// ----- Open the temporary file in write mode
[5118] Fix | Delete
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
[5119] Fix | Delete
{
[5120] Fix | Delete
$this->privCloseFd();
[5121] Fix | Delete
$p_archive_to_add->privCloseFd();
[5122] Fix | Delete
[5123] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
[5124] Fix | Delete
[5125] Fix | Delete
// ----- Return
[5126] Fix | Delete
return PclZip::errorCode();
[5127] Fix | Delete
}
[5128] Fix | Delete
[5129] Fix | Delete
// ----- Copy the files from the archive to the temporary file
[5130] Fix | Delete
// TBC : Here I should better append the file and go back to erase the central dir
[5131] Fix | Delete
$v_size = $v_central_dir['offset'];
[5132] Fix | Delete
while ($v_size != 0)
[5133] Fix | Delete
{
[5134] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[5135] Fix | Delete
$v_buffer = fread($this->zip_fd, $v_read_size);
[5136] Fix | Delete
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
[5137] Fix | Delete
$v_size -= $v_read_size;
[5138] Fix | Delete
}
[5139] Fix | Delete
[5140] Fix | Delete
// ----- Copy the files from the archive_to_add into the temporary file
[5141] Fix | Delete
$v_size = $v_central_dir_to_add['offset'];
[5142] Fix | Delete
while ($v_size != 0)
[5143] Fix | Delete
{
[5144] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[5145] Fix | Delete
$v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
[5146] Fix | Delete
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
[5147] Fix | Delete
$v_size -= $v_read_size;
[5148] Fix | Delete
}
[5149] Fix | Delete
[5150] Fix | Delete
// ----- Store the offset of the central dir
[5151] Fix | Delete
$v_offset = @ftell($v_zip_temp_fd);
[5152] Fix | Delete
[5153] Fix | Delete
// ----- Copy the block of file headers from the old archive
[5154] Fix | Delete
$v_size = $v_central_dir['size'];
[5155] Fix | Delete
while ($v_size != 0)
[5156] Fix | Delete
{
[5157] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[5158] Fix | Delete
$v_buffer = @fread($this->zip_fd, $v_read_size);
[5159] Fix | Delete
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
[5160] Fix | Delete
$v_size -= $v_read_size;
[5161] Fix | Delete
}
[5162] Fix | Delete
[5163] Fix | Delete
// ----- Copy the block of file headers from the archive_to_add
[5164] Fix | Delete
$v_size = $v_central_dir_to_add['size'];
[5165] Fix | Delete
while ($v_size != 0)
[5166] Fix | Delete
{
[5167] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[5168] Fix | Delete
$v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
[5169] Fix | Delete
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
[5170] Fix | Delete
$v_size -= $v_read_size;
[5171] Fix | Delete
}
[5172] Fix | Delete
[5173] Fix | Delete
// ----- Merge the file comments
[5174] Fix | Delete
$v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
[5175] Fix | Delete
[5176] Fix | Delete
// ----- Calculate the size of the (new) central header
[5177] Fix | Delete
$v_size = @ftell($v_zip_temp_fd)-$v_offset;
[5178] Fix | Delete
[5179] Fix | Delete
// ----- Swap the file descriptor
[5180] Fix | Delete
// Here is a trick : I swap the temporary fd with the zip fd, in order to use
[5181] Fix | Delete
// the following methods on the temporary fil and not the real archive fd
[5182] Fix | Delete
$v_swap = $this->zip_fd;
[5183] Fix | Delete
$this->zip_fd = $v_zip_temp_fd;
[5184] Fix | Delete
$v_zip_temp_fd = $v_swap;
[5185] Fix | Delete
[5186] Fix | Delete
// ----- Create the central dir footer
[5187] Fix | Delete
if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
[5188] Fix | Delete
{
[5189] Fix | Delete
$this->privCloseFd();
[5190] Fix | Delete
$p_archive_to_add->privCloseFd();
[5191] Fix | Delete
@fclose($v_zip_temp_fd);
[5192] Fix | Delete
$this->zip_fd = null;
[5193] Fix | Delete
[5194] Fix | Delete
// ----- Reset the file list
[5195] Fix | Delete
unset($v_header_list);
[5196] Fix | Delete
[5197] Fix | Delete
// ----- Return
[5198] Fix | Delete
return $v_result;
[5199] Fix | Delete
}
[5200] Fix | Delete
[5201] Fix | Delete
// ----- Swap back the file descriptor
[5202] Fix | Delete
$v_swap = $this->zip_fd;
[5203] Fix | Delete
$this->zip_fd = $v_zip_temp_fd;
[5204] Fix | Delete
$v_zip_temp_fd = $v_swap;
[5205] Fix | Delete
[5206] Fix | Delete
// ----- Close
[5207] Fix | Delete
$this->privCloseFd();
[5208] Fix | Delete
$p_archive_to_add->privCloseFd();
[5209] Fix | Delete
[5210] Fix | Delete
// ----- Close the temporary file
[5211] Fix | Delete
@fclose($v_zip_temp_fd);
[5212] Fix | Delete
[5213] Fix | Delete
// ----- Delete the zip file
[5214] Fix | Delete
// TBC : I should test the result ...
[5215] Fix | Delete
@unlink($this->zipname);
[5216] Fix | Delete
[5217] Fix | Delete
// ----- Rename the temporary file
[5218] Fix | Delete
// TBC : I should test the result ...
[5219] Fix | Delete
//@rename($v_zip_temp_name, $this->zipname);
[5220] Fix | Delete
PclZipUtilRename($v_zip_temp_name, $this->zipname);
[5221] Fix | Delete
[5222] Fix | Delete
// ----- Return
[5223] Fix | Delete
return $v_result;
[5224] Fix | Delete
}
[5225] Fix | Delete
// --------------------------------------------------------------------------------
[5226] Fix | Delete
[5227] Fix | Delete
// --------------------------------------------------------------------------------
[5228] Fix | Delete
// Function : privDuplicate()
[5229] Fix | Delete
// Description :
[5230] Fix | Delete
// Parameters :
[5231] Fix | Delete
// Return Values :
[5232] Fix | Delete
// --------------------------------------------------------------------------------
[5233] Fix | Delete
function privDuplicate($p_archive_filename)
[5234] Fix | Delete
{
[5235] Fix | Delete
$v_result=1;
[5236] Fix | Delete
[5237] Fix | Delete
// ----- Look if the $p_archive_filename exists
[5238] Fix | Delete
if (!is_file($p_archive_filename))
[5239] Fix | Delete
{
[5240] Fix | Delete
[5241] Fix | Delete
// ----- Nothing to duplicate, so duplicate is a success.
[5242] Fix | Delete
$v_result = 1;
[5243] Fix | Delete
[5244] Fix | Delete
// ----- Return
[5245] Fix | Delete
return $v_result;
[5246] Fix | Delete
}
[5247] Fix | Delete
[5248] Fix | Delete
// ----- Open the zip file
[5249] Fix | Delete
if (($v_result=$this->privOpenFd('wb')) != 1)
[5250] Fix | Delete
{
[5251] Fix | Delete
// ----- Return
[5252] Fix | Delete
return $v_result;
[5253] Fix | Delete
}
[5254] Fix | Delete
[5255] Fix | Delete
// ----- Open the temporary file in write mode
[5256] Fix | Delete
if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
[5257] Fix | Delete
{
[5258] Fix | Delete
$this->privCloseFd();
[5259] Fix | Delete
[5260] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
[5261] Fix | Delete
[5262] Fix | Delete
// ----- Return
[5263] Fix | Delete
return PclZip::errorCode();
[5264] Fix | Delete
}
[5265] Fix | Delete
[5266] Fix | Delete
// ----- Copy the files from the archive to the temporary file
[5267] Fix | Delete
// TBC : Here I should better append the file and go back to erase the central dir
[5268] Fix | Delete
$v_size = filesize($p_archive_filename);
[5269] Fix | Delete
while ($v_size != 0)
[5270] Fix | Delete
{
[5271] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[5272] Fix | Delete
$v_buffer = fread($v_zip_temp_fd, $v_read_size);
[5273] Fix | Delete
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
[5274] Fix | Delete
$v_size -= $v_read_size;
[5275] Fix | Delete
}
[5276] Fix | Delete
[5277] Fix | Delete
// ----- Close
[5278] Fix | Delete
$this->privCloseFd();
[5279] Fix | Delete
[5280] Fix | Delete
// ----- Close the temporary file
[5281] Fix | Delete
@fclose($v_zip_temp_fd);
[5282] Fix | Delete
[5283] Fix | Delete
// ----- Return
[5284] Fix | Delete
return $v_result;
[5285] Fix | Delete
}
[5286] Fix | Delete
// --------------------------------------------------------------------------------
[5287] Fix | Delete
[5288] Fix | Delete
// --------------------------------------------------------------------------------
[5289] Fix | Delete
// Function : privErrorLog()
[5290] Fix | Delete
// Description :
[5291] Fix | Delete
// Parameters :
[5292] Fix | Delete
// --------------------------------------------------------------------------------
[5293] Fix | Delete
function privErrorLog($p_error_code=0, $p_error_string='')
[5294] Fix | Delete
{
[5295] Fix | Delete
if (PCLZIP_ERROR_EXTERNAL == 1) {
[5296] Fix | Delete
PclError($p_error_code, $p_error_string);
[5297] Fix | Delete
}
[5298] Fix | Delete
else {
[5299] Fix | Delete
$this->error_code = $p_error_code;
[5300] Fix | Delete
$this->error_string = $p_error_string;
[5301] Fix | Delete
}
[5302] Fix | Delete
}
[5303] Fix | Delete
// --------------------------------------------------------------------------------
[5304] Fix | Delete
[5305] Fix | Delete
// --------------------------------------------------------------------------------
[5306] Fix | Delete
// Function : privErrorReset()
[5307] Fix | Delete
// Description :
[5308] Fix | Delete
// Parameters :
[5309] Fix | Delete
// --------------------------------------------------------------------------------
[5310] Fix | Delete
function privErrorReset()
[5311] Fix | Delete
{
[5312] Fix | Delete
if (PCLZIP_ERROR_EXTERNAL == 1) {
[5313] Fix | Delete
PclErrorReset();
[5314] Fix | Delete
}
[5315] Fix | Delete
else {
[5316] Fix | Delete
$this->error_code = 0;
[5317] Fix | Delete
$this->error_string = '';
[5318] Fix | Delete
}
[5319] Fix | Delete
}
[5320] Fix | Delete
// --------------------------------------------------------------------------------
[5321] Fix | Delete
[5322] Fix | Delete
// --------------------------------------------------------------------------------
[5323] Fix | Delete
// Function : privDisableMagicQuotes()
[5324] Fix | Delete
// Description :
[5325] Fix | Delete
// Parameters :
[5326] Fix | Delete
// Return Values :
[5327] Fix | Delete
// --------------------------------------------------------------------------------
[5328] Fix | Delete
function privDisableMagicQuotes()
[5329] Fix | Delete
{
[5330] Fix | Delete
$v_result=1;
[5331] Fix | Delete
[5332] Fix | Delete
// ----- Look if function exists
[5333] Fix | Delete
if ( (!function_exists("get_magic_quotes_runtime"))
[5334] Fix | Delete
|| (!function_exists("set_magic_quotes_runtime"))) {
[5335] Fix | Delete
return $v_result;
[5336] Fix | Delete
}
[5337] Fix | Delete
[5338] Fix | Delete
// ----- Look if already done
[5339] Fix | Delete
if ($this->magic_quotes_status != -1) {
[5340] Fix | Delete
return $v_result;
[5341] Fix | Delete
}
[5342] Fix | Delete
[5343] Fix | Delete
// ----- Get and memorize the magic_quote value
[5344] Fix | Delete
$this->magic_quotes_status = @get_magic_quotes_runtime();
[5345] Fix | Delete
[5346] Fix | Delete
// ----- Disable magic_quotes
[5347] Fix | Delete
if ($this->magic_quotes_status == 1) {
[5348] Fix | Delete
@set_magic_quotes_runtime(0);
[5349] Fix | Delete
}
[5350] Fix | Delete
[5351] Fix | Delete
// ----- Return
[5352] Fix | Delete
return $v_result;
[5353] Fix | Delete
}
[5354] Fix | Delete
// --------------------------------------------------------------------------------
[5355] Fix | Delete
[5356] Fix | Delete
// --------------------------------------------------------------------------------
[5357] Fix | Delete
// Function : privSwapBackMagicQuotes()
[5358] Fix | Delete
// Description :
[5359] Fix | Delete
// Parameters :
[5360] Fix | Delete
// Return Values :
[5361] Fix | Delete
// --------------------------------------------------------------------------------
[5362] Fix | Delete
function privSwapBackMagicQuotes()
[5363] Fix | Delete
{
[5364] Fix | Delete
$v_result=1;
[5365] Fix | Delete
[5366] Fix | Delete
// ----- Look if function exists
[5367] Fix | Delete
if ( (!function_exists("get_magic_quotes_runtime"))
[5368] Fix | Delete
|| (!function_exists("set_magic_quotes_runtime"))) {
[5369] Fix | Delete
return $v_result;
[5370] Fix | Delete
}
[5371] Fix | Delete
[5372] Fix | Delete
// ----- Look if something to do
[5373] Fix | Delete
if ($this->magic_quotes_status != -1) {
[5374] Fix | Delete
return $v_result;
[5375] Fix | Delete
}
[5376] Fix | Delete
[5377] Fix | Delete
// ----- Swap back magic_quotes
[5378] Fix | Delete
if ($this->magic_quotes_status == 1) {
[5379] Fix | Delete
@set_magic_quotes_runtime($this->magic_quotes_status);
[5380] Fix | Delete
}
[5381] Fix | Delete
[5382] Fix | Delete
// ----- Return
[5383] Fix | Delete
return $v_result;
[5384] Fix | Delete
}
[5385] Fix | Delete
// --------------------------------------------------------------------------------
[5386] Fix | Delete
[5387] Fix | Delete
}
[5388] Fix | Delete
// End of class
[5389] Fix | Delete
// --------------------------------------------------------------------------------
[5390] Fix | Delete
[5391] Fix | Delete
// --------------------------------------------------------------------------------
[5392] Fix | Delete
// Function : PclZipUtilPathReduction()
[5393] Fix | Delete
// Description :
[5394] Fix | Delete
// Parameters :
[5395] Fix | Delete
// Return Values :
[5396] Fix | Delete
// --------------------------------------------------------------------------------
[5397] Fix | Delete
function PclZipUtilPathReduction($p_dir)
[5398] Fix | Delete
{
[5399] Fix | Delete
$v_result = "";
[5400] Fix | Delete
[5401] Fix | Delete
// ----- Look for not empty path
[5402] Fix | Delete
if ($p_dir != "") {
[5403] Fix | Delete
// ----- Explode path by directory names
[5404] Fix | Delete
$v_list = explode("/", $p_dir);
[5405] Fix | Delete
[5406] Fix | Delete
// ----- Study directories from last to first
[5407] Fix | Delete
$v_skip = 0;
[5408] Fix | Delete
for ($i=sizeof($v_list)-1; $i>=0; $i--) {
[5409] Fix | Delete
// ----- Look for current path
[5410] Fix | Delete
if ($v_list[$i] == ".") {
[5411] Fix | Delete
// ----- Ignore this directory
[5412] Fix | Delete
// Should be the first $i=0, but no check is done
[5413] Fix | Delete
}
[5414] Fix | Delete
else if ($v_list[$i] == "..") {
[5415] Fix | Delete
$v_skip++;
[5416] Fix | Delete
}
[5417] Fix | Delete
else if ($v_list[$i] == "") {
[5418] Fix | Delete
// ----- First '/' i.e. root slash
[5419] Fix | Delete
if ($i == 0) {
[5420] Fix | Delete
$v_result = "/".$v_result;
[5421] Fix | Delete
if ($v_skip > 0) {
[5422] Fix | Delete
// ----- It is an invalid path, so the path is not modified
[5423] Fix | Delete
// TBC
[5424] Fix | Delete
$v_result = $p_dir;
[5425] Fix | Delete
$v_skip = 0;
[5426] Fix | Delete
}
[5427] Fix | Delete
}
[5428] Fix | Delete
// ----- Last '/' i.e. indicates a directory
[5429] Fix | Delete
else if ($i == (sizeof($v_list)-1)) {
[5430] Fix | Delete
$v_result = $v_list[$i];
[5431] Fix | Delete
}
[5432] Fix | Delete
// ----- Double '/' inside the path
[5433] Fix | Delete
else {
[5434] Fix | Delete
// ----- Ignore only the double '//' in path,
[5435] Fix | Delete
// but not the first and last '/'
[5436] Fix | Delete
}
[5437] Fix | Delete
}
[5438] Fix | Delete
else {
[5439] Fix | Delete
// ----- Look for item to skip
[5440] Fix | Delete
if ($v_skip > 0) {
[5441] Fix | Delete
$v_skip--;
[5442] Fix | Delete
}
[5443] Fix | Delete
else {
[5444] Fix | Delete
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
[5445] Fix | Delete
}
[5446] Fix | Delete
}
[5447] Fix | Delete
}
[5448] Fix | Delete
[5449] Fix | Delete
// ----- Look for skip
[5450] Fix | Delete
if ($v_skip > 0) {
[5451] Fix | Delete
while ($v_skip > 0) {
[5452] Fix | Delete
$v_result = '../'.$v_result;
[5453] Fix | Delete
$v_skip--;
[5454] Fix | Delete
}
[5455] Fix | Delete
}
[5456] Fix | Delete
}
[5457] Fix | Delete
[5458] Fix | Delete
// ----- Return
[5459] Fix | Delete
return $v_result;
[5460] Fix | Delete
}
[5461] Fix | Delete
// --------------------------------------------------------------------------------
[5462] Fix | Delete
[5463] Fix | Delete
// --------------------------------------------------------------------------------
[5464] Fix | Delete
// Function : PclZipUtilPathInclusion()
[5465] Fix | Delete
// Description :
[5466] Fix | Delete
// This function indicates if the path $p_path is under the $p_dir tree. Or,
[5467] Fix | Delete
// said in an other way, if the file or sub-dir $p_path is inside the dir
[5468] Fix | Delete
// $p_dir.
[5469] Fix | Delete
// The function indicates also if the path is exactly the same as the dir.
[5470] Fix | Delete
// This function supports path with duplicated '/' like '//', but does not
[5471] Fix | Delete
// support '.' or '..' statements.
[5472] Fix | Delete
// Parameters :
[5473] Fix | Delete
// Return Values :
[5474] Fix | Delete
// 0 if $p_path is not inside directory $p_dir
[5475] Fix | Delete
// 1 if $p_path is inside directory $p_dir
[5476] Fix | Delete
// 2 if $p_path is exactly the same as $p_dir
[5477] Fix | Delete
// --------------------------------------------------------------------------------
[5478] Fix | Delete
function PclZipUtilPathInclusion($p_dir, $p_path)
[5479] Fix | Delete
{
[5480] Fix | Delete
$v_result = 1;
[5481] Fix | Delete
[5482] Fix | Delete
// ----- Look for path beginning by ./
[5483] Fix | Delete
if ( ($p_dir == '.')
[5484] Fix | Delete
|| ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
[5485] Fix | Delete
$p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
[5486] Fix | Delete
}
[5487] Fix | Delete
if ( ($p_path == '.')
[5488] Fix | Delete
|| ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
[5489] Fix | Delete
$p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
[5490] Fix | Delete
}
[5491] Fix | Delete
[5492] Fix | Delete
// ----- Explode dir and path by directory separator
[5493] Fix | Delete
$v_list_dir = explode("/", $p_dir);
[5494] Fix | Delete
$v_list_dir_size = sizeof($v_list_dir);
[5495] Fix | Delete
$v_list_path = explode("/", $p_path);
[5496] Fix | Delete
$v_list_path_size = sizeof($v_list_path);
[5497] Fix | Delete
[5498] Fix | Delete
// ----- Study directories paths
[5499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function