function PclZipUtilPathReduction in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php \PclZipUtilPathReduction()
5 calls to PclZipUtilPathReduction()
- PclZip::privAddFile in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php - PclZip::privCalculateStoredFilename in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php - PclZip::privConvertHeader2FileInfo in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php - PclZip::privFileDescrExpand in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php - PclZip::privFileDescrParseAtt in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ PCLZip/ pclzip.lib.php, line 5396
Code
function PclZipUtilPathReduction($p_dir) {
$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;
}
}
else {
if ($i == sizeof($v_list) - 1) {
$v_result = $v_list[$i];
}
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;
}