PclZipUtilPathInclusion

The WordPress Core PclZipUtilPathInclusion function.

Description

PclZipUtilPathInclusion( $p_dir, $p_path ); 

Parameters (2)

0. $p_dir
The dir.
1. $p_path
The path.

Usage

  1. if ( !function_exists( 'PclZipUtilPathInclusion' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/class-pclzip.php'; 
  3.  
  4. // The dir. 
  5. $p_dir = null; 
  6.  
  7. // The path. 
  8. $p_path = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = PclZipUtilPathInclusion($p_dir, $p_path); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/class-pclzip.php  
  1. function PclZipUtilPathInclusion($p_dir, $p_path) 
  2. $v_result = 1; 
  3.  
  4. // ----- Look for path beginning by ./ 
  5. if ( ($p_dir == '.') 
  6. || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { 
  7. $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); 
  8. if ( ($p_path == '.') 
  9. || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { 
  10. $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); 
  11.  
  12. // ----- Explode dir and path by directory separator 
  13. $v_list_dir = explode("/", $p_dir); 
  14. $v_list_dir_size = sizeof($v_list_dir); 
  15. $v_list_path = explode("/", $p_path); 
  16. $v_list_path_size = sizeof($v_list_path); 
  17.  
  18. // ----- Study directories paths 
  19. $i = 0; 
  20. $j = 0; 
  21. while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { 
  22.  
  23. // ----- Look for empty dir (path reduction) 
  24. if ($v_list_dir[$i] == '') { 
  25. $i++; 
  26. continue; 
  27. if ($v_list_path[$j] == '') { 
  28. $j++; 
  29. continue; 
  30.  
  31. // ----- Compare the items 
  32. if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { 
  33. $v_result = 0; 
  34.  
  35. // ----- Next items 
  36. $i++; 
  37. $j++; 
  38.  
  39. // ----- Look if everything seems to be the same 
  40. if ($v_result) { 
  41. // ----- Skip all the empty items 
  42. while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; 
  43. while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; 
  44.  
  45. if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { 
  46. // ----- There are exactly the same 
  47. $v_result = 2; 
  48. else if ($i < $v_list_dir_size) { 
  49. // ----- The path is shorter than the dir 
  50. $v_result = 0; 
  51.  
  52. // ----- Return 
  53. return $v_result;