pclzip.lib.php File Reference

Go to the source code of this file.

Classes

Enumerations

Functions

Variables

  • if(!defined('PCLZIP_READ_BLOCK_SIZE'))
    if(!defined('PCLZIP_SEPARATOR'))
    if(!defined('PCLZIP_ERROR_EXTERNAL'))
    if(!defined('PCLZIP_TEMPORARY_DIR'))
    if(!defined('PCLZIP_TEMPORARY_FILE_RATIO')) $g_pclzip_version = "2.8.2"

Enumeration Type Documentation

Definition at line 162 of file pclzip.lib.php.

Definition at line 161 of file pclzip.lib.php.

Definition at line 160 of file pclzip.lib.php.

Definition at line 157 of file pclzip.lib.php.

Definition at line 159 of file pclzip.lib.php.

Definition at line 158 of file pclzip.lib.php.

Definition at line 168 of file pclzip.lib.php.

Definition at line 166 of file pclzip.lib.php.

Definition at line 167 of file pclzip.lib.php.

Definition at line 165 of file pclzip.lib.php.

Definition at line 121 of file pclzip.lib.php.

Definition at line 117 of file pclzip.lib.php.

Definition at line 113 of file pclzip.lib.php.

Definition at line 111 of file pclzip.lib.php.

Definition at line 114 of file pclzip.lib.php.

Definition at line 115 of file pclzip.lib.php.

Definition at line 112 of file pclzip.lib.php.

Definition at line 125 of file pclzip.lib.php.

Definition at line 109 of file pclzip.lib.php.

Definition at line 118 of file pclzip.lib.php.

Definition at line 124 of file pclzip.lib.php.

Definition at line 120 of file pclzip.lib.php.

Definition at line 107 of file pclzip.lib.php.

Definition at line 110 of file pclzip.lib.php.

Definition at line 108 of file pclzip.lib.php.

Definition at line 119 of file pclzip.lib.php.

Definition at line 104 of file pclzip.lib.php.

Definition at line 106 of file pclzip.lib.php.

Definition at line 116 of file pclzip.lib.php.

Definition at line 122 of file pclzip.lib.php.

Definition at line 123 of file pclzip.lib.php.

Definition at line 103 of file pclzip.lib.php.

Definition at line 105 of file pclzip.lib.php.

Definition at line 140 of file pclzip.lib.php.

Definition at line 129 of file pclzip.lib.php.

Definition at line 154 of file pclzip.lib.php.

Definition at line 152 of file pclzip.lib.php.

Definition at line 150 of file pclzip.lib.php.

Definition at line 137 of file pclzip.lib.php.

Definition at line 136 of file pclzip.lib.php.

Definition at line 135 of file pclzip.lib.php.

Definition at line 138 of file pclzip.lib.php.

Definition at line 139 of file pclzip.lib.php.

Definition at line 133 of file pclzip.lib.php.

Definition at line 148 of file pclzip.lib.php.

Definition at line 142 of file pclzip.lib.php.

Definition at line 134 of file pclzip.lib.php.

Definition at line 128 of file pclzip.lib.php.

Definition at line 141 of file pclzip.lib.php.

Definition at line 131 of file pclzip.lib.php.

Definition at line 130 of file pclzip.lib.php.

Definition at line 143 of file pclzip.lib.php.

Definition at line 132 of file pclzip.lib.php.

Definition at line 144 of file pclzip.lib.php.

Definition at line 153 of file pclzip.lib.php.

Definition at line 151 of file pclzip.lib.php.

Definition at line 149 of file pclzip.lib.php.


Function Documentation

PclZipUtilCopyBlock ( p_src,
p_dest,
p_size,
p_mode = 0 
)

Definition at line 5554 of file pclzip.lib.php.

Referenced by PclZip::privDeleteByRule().

05555   {
05556     $v_result = 1;
05557 
05558     if ($p_mode==0)
05559     {
05560       while ($p_size != 0)
05561       {
05562         $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
05563         $v_buffer = @fread($p_src, $v_read_size);
05564         @fwrite($p_dest, $v_buffer, $v_read_size);
05565         $p_size -= $v_read_size;
05566       }
05567     }
05568     else if ($p_mode==1)
05569     {
05570       while ($p_size != 0)
05571       {
05572         $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
05573         $v_buffer = @gzread($p_src, $v_read_size);
05574         @fwrite($p_dest, $v_buffer, $v_read_size);
05575         $p_size -= $v_read_size;
05576       }
05577     }
05578     else if ($p_mode==2)
05579     {
05580       while ($p_size != 0)
05581       {
05582         $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
05583         $v_buffer = @fread($p_src, $v_read_size);
05584         @gzwrite($p_dest, $v_buffer, $v_read_size);
05585         $p_size -= $v_read_size;
05586       }
05587     }
05588     else if ($p_mode==3)
05589     {
05590       while ($p_size != 0)
05591       {
05592         $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
05593         $v_buffer = @gzread($p_src, $v_read_size);
05594         @gzwrite($p_dest, $v_buffer, $v_read_size);
05595         $p_size -= $v_read_size;
05596       }
05597     }
05598 
05599     // ----- Return
05600     return $v_result;
05601   }

PclZipUtilOptionText ( p_option  ) 

Definition at line 5646 of file pclzip.lib.php.

05647   {
05648     
05649     $v_list = get_defined_constants();
05650     for (reset($v_list); $v_key = key($v_list); next($v_list)) {
05651             $v_prefix = substr($v_key, 0, 10);
05652             if ((   ($v_prefix == 'PCLZIP_OPT')
05653            || ($v_prefix == 'PCLZIP_CB_')
05654            || ($v_prefix == 'PCLZIP_ATT'))
05655                 && ($v_list[$v_key] == $p_option)) {
05656         return $v_key;
05657             }
05658     }
05659     
05660     $v_result = 'Unknown';
05661 
05662     return $v_result;
05663   }

PclZipUtilPathInclusion ( p_dir,
p_path 
)

Definition at line 5477 of file pclzip.lib.php.

05478   {
05479     $v_result = 1;
05480     
05481     // ----- Look for path beginning by ./
05482     if (   ($p_dir == '.')
05483         || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
05484       $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
05485     }
05486     if (   ($p_path == '.')
05487         || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
05488       $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
05489     }
05490 
05491     // ----- Explode dir and path by directory separator
05492     $v_list_dir = explode("/", $p_dir);
05493     $v_list_dir_size = sizeof($v_list_dir);
05494     $v_list_path = explode("/", $p_path);
05495     $v_list_path_size = sizeof($v_list_path);
05496 
05497     // ----- Study directories paths
05498     $i = 0;
05499     $j = 0;
05500     while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
05501 
05502       // ----- Look for empty dir (path reduction)
05503       if ($v_list_dir[$i] == '') {
05504         $i++;
05505         continue;
05506       }
05507       if ($v_list_path[$j] == '') {
05508         $j++;
05509         continue;
05510       }
05511 
05512       // ----- Compare the items
05513       if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
05514         $v_result = 0;
05515       }
05516 
05517       // ----- Next items
05518       $i++;
05519       $j++;
05520     }
05521 
05522     // ----- Look if everything seems to be the same
05523     if ($v_result) {
05524       // ----- Skip all the empty items
05525       while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
05526       while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
05527 
05528       if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
05529         // ----- There are exactly the same
05530         $v_result = 2;
05531       }
05532       else if ($i < $v_list_dir_size) {
05533         // ----- The path is shorter than the dir
05534         $v_result = 0;
05535       }
05536     }
05537 
05538     // ----- Return
05539     return $v_result;
05540   }

PclZipUtilPathReduction ( p_dir  ) 

Definition at line 5396 of file pclzip.lib.php.

05397   {
05398     $v_result = "";
05399 
05400     // ----- Look for not empty path
05401     if ($p_dir != "") {
05402       // ----- Explode path by directory names
05403       $v_list = explode("/", $p_dir);
05404 
05405       // ----- Study directories from last to first
05406       $v_skip = 0;
05407       for ($i=sizeof($v_list)-1; $i>=0; $i--) {
05408         // ----- Look for current path
05409         if ($v_list[$i] == ".") {
05410           // ----- Ignore this directory
05411           // Should be the first $i=0, but no check is done
05412         }
05413         else if ($v_list[$i] == "..") {
05414                   $v_skip++;
05415         }
05416         else if ($v_list[$i] == "") {
05417                   // ----- First '/' i.e. root slash
05418                   if ($i == 0) {
05419             $v_result = "/".$v_result;
05420                     if ($v_skip > 0) {
05421                         // ----- It is an invalid path, so the path is not modified
05422                         // TBC
05423                         $v_result = $p_dir;
05424                 $v_skip = 0;
05425                     }
05426                   }
05427                   // ----- Last '/' i.e. indicates a directory
05428                   else if ($i == (sizeof($v_list)-1)) {
05429             $v_result = $v_list[$i];
05430                   }
05431                   // ----- Double '/' inside the path
05432                   else {
05433             // ----- Ignore only the double '//' in path,
05434             // but not the first and last '/'
05435                   }
05436         }
05437         else {
05438                   // ----- Look for item to skip
05439                   if ($v_skip > 0) {
05440                     $v_skip--;
05441                   }
05442                   else {
05443             $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
05444                   }
05445         }
05446       }
05447       
05448       // ----- Look for skip
05449       if ($v_skip > 0) {
05450         while ($v_skip > 0) {
05451             $v_result = '../'.$v_result;
05452             $v_skip--;
05453         }
05454       }
05455     }
05456 
05457     // ----- Return
05458     return $v_result;
05459   }

PclZipUtilRename ( p_src,
p_dest 
)

Definition at line 5616 of file pclzip.lib.php.

Referenced by PclZip::privDeleteByRule().

05617   {
05618     $v_result = 1;
05619 
05620     // ----- Try to rename the files
05621     if (!@rename($p_src, $p_dest)) {
05622 
05623       // ----- Try to copy & unlink the src
05624       if (!@copy($p_src, $p_dest)) {
05625         $v_result = 0;
05626       }
05627       else if (!@unlink($p_src)) {
05628         $v_result = 0;
05629       }
05630     }
05631 
05632     // ----- Return
05633     return $v_result;
05634   }

PclZipUtilTranslateWinPath ( p_path,
p_remove_disk_letter = true 
)

Definition at line 5677 of file pclzip.lib.php.

Referenced by PclZipUtilPathInclusion().

05678   {
05679     if (stristr(php_uname(), 'windows')) {
05680       // ----- Look for potential disk letter
05681       if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
05682           $p_path = substr($p_path, $v_position+1);
05683       }
05684       // ----- Change potential windows directory separator
05685       if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
05686           $p_path = strtr($p_path, '\\', '/');
05687       }
05688     }
05689     return $p_path;
05690   }


Variable Documentation

if (!defined('PCLZIP_READ_BLOCK_SIZE')) if (!defined('PCLZIP_SEPARATOR')) if (!defined('PCLZIP_ERROR_EXTERNAL')) if (!defined('PCLZIP_TEMPORARY_DIR')) if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) $g_pclzip_version = "2.8.2"

Definition at line 86 of file pclzip.lib.php.