Edit File by line
/home/barbar84/www/extracte.../filemang...
File: pclzip.lib.php
// --------------------------------------------------------------------------------
[2000] Fix | Delete
function privFileDescrExpand(&$p_filedescr_list, &$p_options)
[2001] Fix | Delete
{
[2002] Fix | Delete
$v_result=1;
[2003] Fix | Delete
[2004] Fix | Delete
// ----- Create a result list
[2005] Fix | Delete
$v_result_list = array();
[2006] Fix | Delete
[2007] Fix | Delete
// ----- Look each entry
[2008] Fix | Delete
for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
[2009] Fix | Delete
[2010] Fix | Delete
// ----- Get filedescr
[2011] Fix | Delete
$v_descr = $p_filedescr_list[$i];
[2012] Fix | Delete
[2013] Fix | Delete
// ----- Reduce the filename
[2014] Fix | Delete
$v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
[2015] Fix | Delete
$v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
[2016] Fix | Delete
[2017] Fix | Delete
// ----- Look for real file or folder
[2018] Fix | Delete
if (file_exists($v_descr['filename'])) {
[2019] Fix | Delete
if (@is_file($v_descr['filename'])) {
[2020] Fix | Delete
$v_descr['type'] = 'file';
[2021] Fix | Delete
}
[2022] Fix | Delete
else if (@is_dir($v_descr['filename'])) {
[2023] Fix | Delete
$v_descr['type'] = 'folder';
[2024] Fix | Delete
}
[2025] Fix | Delete
else if (@is_link($v_descr['filename'])) {
[2026] Fix | Delete
// skip
[2027] Fix | Delete
continue;
[2028] Fix | Delete
}
[2029] Fix | Delete
else {
[2030] Fix | Delete
// skip
[2031] Fix | Delete
continue;
[2032] Fix | Delete
}
[2033] Fix | Delete
}
[2034] Fix | Delete
[2035] Fix | Delete
// ----- Look for string added as file
[2036] Fix | Delete
else if (isset($v_descr['content'])) {
[2037] Fix | Delete
$v_descr['type'] = 'virtual_file';
[2038] Fix | Delete
}
[2039] Fix | Delete
[2040] Fix | Delete
// ----- Missing file
[2041] Fix | Delete
else {
[2042] Fix | Delete
// ----- Error log
[2043] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
[2044] Fix | Delete
[2045] Fix | Delete
// ----- Return
[2046] Fix | Delete
return PclZip::errorCode();
[2047] Fix | Delete
}
[2048] Fix | Delete
[2049] Fix | Delete
// ----- Calculate the stored filename
[2050] Fix | Delete
$this->privCalculateStoredFilename($v_descr, $p_options);
[2051] Fix | Delete
[2052] Fix | Delete
// ----- Add the descriptor in result list
[2053] Fix | Delete
$v_result_list[sizeof($v_result_list)] = $v_descr;
[2054] Fix | Delete
[2055] Fix | Delete
// ----- Look for folder
[2056] Fix | Delete
if ($v_descr['type'] == 'folder') {
[2057] Fix | Delete
// ----- List of items in folder
[2058] Fix | Delete
$v_dirlist_descr = array();
[2059] Fix | Delete
$v_dirlist_nb = 0;
[2060] Fix | Delete
if ($v_folder_handler = @opendir($v_descr['filename'])) {
[2061] Fix | Delete
while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
[2062] Fix | Delete
[2063] Fix | Delete
// ----- Skip '.' and '..'
[2064] Fix | Delete
if (($v_item_handler == '.') || ($v_item_handler == '..')) {
[2065] Fix | Delete
continue;
[2066] Fix | Delete
}
[2067] Fix | Delete
[2068] Fix | Delete
// ----- Compose the full filename
[2069] Fix | Delete
$v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
[2070] Fix | Delete
[2071] Fix | Delete
// ----- Look for different stored filename
[2072] Fix | Delete
// Because the name of the folder was changed, the name of the
[2073] Fix | Delete
// files/sub-folders also change
[2074] Fix | Delete
if (($v_descr['stored_filename'] != $v_descr['filename'])
[2075] Fix | Delete
&& (!isset($p_options[PCLZIP_OPT_RECopy_ALL_PATH]))) {
[2076] Fix | Delete
if ($v_descr['stored_filename'] != '') {
[2077] Fix | Delete
$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
[2078] Fix | Delete
}
[2079] Fix | Delete
else {
[2080] Fix | Delete
$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
[2081] Fix | Delete
}
[2082] Fix | Delete
}
[2083] Fix | Delete
[2084] Fix | Delete
$v_dirlist_nb++;
[2085] Fix | Delete
}
[2086] Fix | Delete
[2087] Fix | Delete
@closedir($v_folder_handler);
[2088] Fix | Delete
}
[2089] Fix | Delete
else {
[2090] Fix | Delete
// TBC : unable to open folder in read mode
[2091] Fix | Delete
}
[2092] Fix | Delete
[2093] Fix | Delete
// ----- Expand each element of the list
[2094] Fix | Delete
if ($v_dirlist_nb != 0) {
[2095] Fix | Delete
// ----- Expand
[2096] Fix | Delete
if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
[2097] Fix | Delete
return $v_result;
[2098] Fix | Delete
}
[2099] Fix | Delete
[2100] Fix | Delete
// ----- Concat the resulting list
[2101] Fix | Delete
$v_result_list = array_merge($v_result_list, $v_dirlist_descr);
[2102] Fix | Delete
}
[2103] Fix | Delete
else {
[2104] Fix | Delete
}
[2105] Fix | Delete
[2106] Fix | Delete
// ----- Free local array
[2107] Fix | Delete
unset($v_dirlist_descr);
[2108] Fix | Delete
}
[2109] Fix | Delete
}
[2110] Fix | Delete
[2111] Fix | Delete
// ----- Get the result list
[2112] Fix | Delete
$p_filedescr_list = $v_result_list;
[2113] Fix | Delete
[2114] Fix | Delete
// ----- Return
[2115] Fix | Delete
return $v_result;
[2116] Fix | Delete
}
[2117] Fix | Delete
// --------------------------------------------------------------------------------
[2118] Fix | Delete
[2119] Fix | Delete
// --------------------------------------------------------------------------------
[2120] Fix | Delete
// Function : privCreate()
[2121] Fix | Delete
// Description :
[2122] Fix | Delete
// Parameters :
[2123] Fix | Delete
// Return Values :
[2124] Fix | Delete
// --------------------------------------------------------------------------------
[2125] Fix | Delete
function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
[2126] Fix | Delete
{
[2127] Fix | Delete
$v_result=1;
[2128] Fix | Delete
$v_list_detail = array();
[2129] Fix | Delete
[2130] Fix | Delete
// ----- Magic quotes trick
[2131] Fix | Delete
$this->privDisableMagicQuotes();
[2132] Fix | Delete
[2133] Fix | Delete
// ----- Open the file in write mode
[2134] Fix | Delete
if (($v_result = $this->privOpenFd('wb')) != 1)
[2135] Fix | Delete
{
[2136] Fix | Delete
// ----- Return
[2137] Fix | Delete
return $v_result;
[2138] Fix | Delete
}
[2139] Fix | Delete
[2140] Fix | Delete
// ----- Add the list of files
[2141] Fix | Delete
$v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
[2142] Fix | Delete
[2143] Fix | Delete
// ----- Close
[2144] Fix | Delete
$this->privCloseFd();
[2145] Fix | Delete
[2146] Fix | Delete
// ----- Magic quotes trick
[2147] Fix | Delete
$this->privSwapBackMagicQuotes();
[2148] Fix | Delete
[2149] Fix | Delete
// ----- Return
[2150] Fix | Delete
return $v_result;
[2151] Fix | Delete
}
[2152] Fix | Delete
// --------------------------------------------------------------------------------
[2153] Fix | Delete
[2154] Fix | Delete
// --------------------------------------------------------------------------------
[2155] Fix | Delete
// Function : privAdd()
[2156] Fix | Delete
// Description :
[2157] Fix | Delete
// Parameters :
[2158] Fix | Delete
// Return Values :
[2159] Fix | Delete
// --------------------------------------------------------------------------------
[2160] Fix | Delete
function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
[2161] Fix | Delete
{
[2162] Fix | Delete
$v_result=1;
[2163] Fix | Delete
$v_list_detail = array();
[2164] Fix | Delete
[2165] Fix | Delete
// ----- Look if the archive exists or is empty
[2166] Fix | Delete
if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
[2167] Fix | Delete
{
[2168] Fix | Delete
[2169] Fix | Delete
// ----- Do a create
[2170] Fix | Delete
$v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
[2171] Fix | Delete
[2172] Fix | Delete
// ----- Return
[2173] Fix | Delete
return $v_result;
[2174] Fix | Delete
}
[2175] Fix | Delete
// ----- Magic quotes trick
[2176] Fix | Delete
$this->privDisableMagicQuotes();
[2177] Fix | Delete
[2178] Fix | Delete
// ----- Open the zip file
[2179] Fix | Delete
if (($v_result=$this->privOpenFd('rb')) != 1)
[2180] Fix | Delete
{
[2181] Fix | Delete
// ----- Magic quotes trick
[2182] Fix | Delete
$this->privSwapBackMagicQuotes();
[2183] Fix | Delete
[2184] Fix | Delete
// ----- Return
[2185] Fix | Delete
return $v_result;
[2186] Fix | Delete
}
[2187] Fix | Delete
[2188] Fix | Delete
// ----- Read the central directory informations
[2189] Fix | Delete
$v_central_dir = array();
[2190] Fix | Delete
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
[2191] Fix | Delete
{
[2192] Fix | Delete
$this->privCloseFd();
[2193] Fix | Delete
$this->privSwapBackMagicQuotes();
[2194] Fix | Delete
return $v_result;
[2195] Fix | Delete
}
[2196] Fix | Delete
[2197] Fix | Delete
// ----- Go to beginning of File
[2198] Fix | Delete
@rewind($this->zip_fd);
[2199] Fix | Delete
[2200] Fix | Delete
// ----- Creates a temporay file
[2201] Fix | Delete
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
[2202] Fix | Delete
[2203] Fix | Delete
// ----- Open the temporary file in write mode
[2204] Fix | Delete
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
[2205] Fix | Delete
{
[2206] Fix | Delete
$this->privCloseFd();
[2207] Fix | Delete
$this->privSwapBackMagicQuotes();
[2208] Fix | Delete
[2209] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
[2210] Fix | Delete
[2211] Fix | Delete
// ----- Return
[2212] Fix | Delete
return PclZip::errorCode();
[2213] Fix | Delete
}
[2214] Fix | Delete
[2215] Fix | Delete
// ----- Copy the files from the archive to the temporary file
[2216] Fix | Delete
// TBC : Here I should better append the file and go back to erase the central dir
[2217] Fix | Delete
$v_size = $v_central_dir['offset'];
[2218] Fix | Delete
while ($v_size != 0)
[2219] Fix | Delete
{
[2220] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[2221] Fix | Delete
$v_buffer = fread($this->zip_fd, $v_read_size);
[2222] Fix | Delete
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
[2223] Fix | Delete
$v_size -= $v_read_size;
[2224] Fix | Delete
}
[2225] Fix | Delete
[2226] Fix | Delete
// ----- Swap the file descriptor
[2227] Fix | Delete
// Here is a trick : I swap the temporary fd with the zip fd, in order to use
[2228] Fix | Delete
// the following methods on the temporary fil and not the real archive
[2229] Fix | Delete
$v_swap = $this->zip_fd;
[2230] Fix | Delete
$this->zip_fd = $v_zip_temp_fd;
[2231] Fix | Delete
$v_zip_temp_fd = $v_swap;
[2232] Fix | Delete
[2233] Fix | Delete
// ----- Add the files
[2234] Fix | Delete
$v_header_list = array();
[2235] Fix | Delete
if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
[2236] Fix | Delete
{
[2237] Fix | Delete
fclose($v_zip_temp_fd);
[2238] Fix | Delete
$this->privCloseFd();
[2239] Fix | Delete
@unlink($v_zip_temp_name);
[2240] Fix | Delete
$this->privSwapBackMagicQuotes();
[2241] Fix | Delete
[2242] Fix | Delete
// ----- Return
[2243] Fix | Delete
return $v_result;
[2244] Fix | Delete
}
[2245] Fix | Delete
[2246] Fix | Delete
// ----- Store the offset of the central dir
[2247] Fix | Delete
$v_offset = @ftell($this->zip_fd);
[2248] Fix | Delete
[2249] Fix | Delete
// ----- Copy the block of file headers from the old archive
[2250] Fix | Delete
$v_size = $v_central_dir['size'];
[2251] Fix | Delete
while ($v_size != 0)
[2252] Fix | Delete
{
[2253] Fix | Delete
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
[2254] Fix | Delete
$v_buffer = @fread($v_zip_temp_fd, $v_read_size);
[2255] Fix | Delete
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
[2256] Fix | Delete
$v_size -= $v_read_size;
[2257] Fix | Delete
}
[2258] Fix | Delete
[2259] Fix | Delete
// ----- Create the Central Dir files header
[2260] Fix | Delete
for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
[2261] Fix | Delete
{
[2262] Fix | Delete
// ----- Create the file header
[2263] Fix | Delete
if ($v_header_list[$i]['status'] == 'ok') {
[2264] Fix | Delete
if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
[2265] Fix | Delete
fclose($v_zip_temp_fd);
[2266] Fix | Delete
$this->privCloseFd();
[2267] Fix | Delete
@unlink($v_zip_temp_name);
[2268] Fix | Delete
$this->privSwapBackMagicQuotes();
[2269] Fix | Delete
[2270] Fix | Delete
// ----- Return
[2271] Fix | Delete
return $v_result;
[2272] Fix | Delete
}
[2273] Fix | Delete
$v_count++;
[2274] Fix | Delete
}
[2275] Fix | Delete
[2276] Fix | Delete
// ----- Transform the header to a 'usable' info
[2277] Fix | Delete
$this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
[2278] Fix | Delete
}
[2279] Fix | Delete
[2280] Fix | Delete
// ----- Zip file comment
[2281] Fix | Delete
$v_comment = $v_central_dir['comment'];
[2282] Fix | Delete
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
[2283] Fix | Delete
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
[2284] Fix | Delete
}
[2285] Fix | Delete
if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
[2286] Fix | Delete
$v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
[2287] Fix | Delete
}
[2288] Fix | Delete
if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
[2289] Fix | Delete
$v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
[2290] Fix | Delete
}
[2291] Fix | Delete
[2292] Fix | Delete
// ----- Calculate the size of the central header
[2293] Fix | Delete
$v_size = @ftell($this->zip_fd)-$v_offset;
[2294] Fix | Delete
[2295] Fix | Delete
// ----- Create the central dir footer
[2296] Fix | Delete
if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
[2297] Fix | Delete
{
[2298] Fix | Delete
// ----- Reset the file list
[2299] Fix | Delete
unset($v_header_list);
[2300] Fix | Delete
$this->privSwapBackMagicQuotes();
[2301] Fix | Delete
[2302] Fix | Delete
// ----- Return
[2303] Fix | Delete
return $v_result;
[2304] Fix | Delete
}
[2305] Fix | Delete
[2306] Fix | Delete
// ----- Swap back the file descriptor
[2307] Fix | Delete
$v_swap = $this->zip_fd;
[2308] Fix | Delete
$this->zip_fd = $v_zip_temp_fd;
[2309] Fix | Delete
$v_zip_temp_fd = $v_swap;
[2310] Fix | Delete
[2311] Fix | Delete
// ----- Close
[2312] Fix | Delete
$this->privCloseFd();
[2313] Fix | Delete
[2314] Fix | Delete
// ----- Close the temporary file
[2315] Fix | Delete
@fclose($v_zip_temp_fd);
[2316] Fix | Delete
[2317] Fix | Delete
// ----- Magic quotes trick
[2318] Fix | Delete
$this->privSwapBackMagicQuotes();
[2319] Fix | Delete
[2320] Fix | Delete
// ----- Delete the zip file
[2321] Fix | Delete
// TBC : I should test the result ...
[2322] Fix | Delete
@unlink($this->zipname);
[2323] Fix | Delete
[2324] Fix | Delete
// ----- Rename the temporary file
[2325] Fix | Delete
// TBC : I should test the result ...
[2326] Fix | Delete
//@rename($v_zip_temp_name, $this->zipname);
[2327] Fix | Delete
PclZipUtilRename($v_zip_temp_name, $this->zipname);
[2328] Fix | Delete
[2329] Fix | Delete
// ----- Return
[2330] Fix | Delete
return $v_result;
[2331] Fix | Delete
}
[2332] Fix | Delete
// --------------------------------------------------------------------------------
[2333] Fix | Delete
[2334] Fix | Delete
// --------------------------------------------------------------------------------
[2335] Fix | Delete
// Function : privOpenFd()
[2336] Fix | Delete
// Description :
[2337] Fix | Delete
// Parameters :
[2338] Fix | Delete
// --------------------------------------------------------------------------------
[2339] Fix | Delete
function privOpenFd($p_mode)
[2340] Fix | Delete
{
[2341] Fix | Delete
$v_result=1;
[2342] Fix | Delete
[2343] Fix | Delete
// ----- Look if already open
[2344] Fix | Delete
if ($this->zip_fd != 0)
[2345] Fix | Delete
{
[2346] Fix | Delete
// ----- Error log
[2347] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
[2348] Fix | Delete
[2349] Fix | Delete
// ----- Return
[2350] Fix | Delete
return PclZip::errorCode();
[2351] Fix | Delete
}
[2352] Fix | Delete
[2353] Fix | Delete
// ----- Open the zip file
[2354] Fix | Delete
if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
[2355] Fix | Delete
{
[2356] Fix | Delete
// ----- Error log
[2357] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
[2358] Fix | Delete
[2359] Fix | Delete
// ----- Return
[2360] Fix | Delete
return PclZip::errorCode();
[2361] Fix | Delete
}
[2362] Fix | Delete
[2363] Fix | Delete
// ----- Return
[2364] Fix | Delete
return $v_result;
[2365] Fix | Delete
}
[2366] Fix | Delete
// --------------------------------------------------------------------------------
[2367] Fix | Delete
[2368] Fix | Delete
// --------------------------------------------------------------------------------
[2369] Fix | Delete
// Function : privCloseFd()
[2370] Fix | Delete
// Description :
[2371] Fix | Delete
// Parameters :
[2372] Fix | Delete
// --------------------------------------------------------------------------------
[2373] Fix | Delete
function privCloseFd()
[2374] Fix | Delete
{
[2375] Fix | Delete
$v_result=1;
[2376] Fix | Delete
[2377] Fix | Delete
if ($this->zip_fd != 0)
[2378] Fix | Delete
@fclose($this->zip_fd);
[2379] Fix | Delete
$this->zip_fd = 0;
[2380] Fix | Delete
[2381] Fix | Delete
// ----- Return
[2382] Fix | Delete
return $v_result;
[2383] Fix | Delete
}
[2384] Fix | Delete
// --------------------------------------------------------------------------------
[2385] Fix | Delete
[2386] Fix | Delete
// --------------------------------------------------------------------------------
[2387] Fix | Delete
// Function : privAddList()
[2388] Fix | Delete
// Description :
[2389] Fix | Delete
// $p_add_dir and $p_reCopy_dir will give the ability to memorize a path which is
[2390] Fix | Delete
// different from the real path of the file. This is usefull if you want to have PclTar
[2391] Fix | Delete
// running in any directory, and memorize relative path from an other directory.
[2392] Fix | Delete
// Parameters :
[2393] Fix | Delete
// $p_list : An array containing the file or directory names to add in the tar
[2394] Fix | Delete
// $p_result_list : list of added files with their properties (specially the status field)
[2395] Fix | Delete
// $p_add_dir : Path to add in the filename path archived
[2396] Fix | Delete
// $p_reCopy_dir : Path to reCopy in the filename path archived
[2397] Fix | Delete
// Return Values :
[2398] Fix | Delete
// --------------------------------------------------------------------------------
[2399] Fix | Delete
// function privAddList($p_list, &$p_result_list, $p_add_dir, $p_reCopy_dir, $p_reCopy_all_dir, &$p_options)
[2400] Fix | Delete
function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
[2401] Fix | Delete
{
[2402] Fix | Delete
$v_result=1;
[2403] Fix | Delete
[2404] Fix | Delete
// ----- Add the files
[2405] Fix | Delete
$v_header_list = array();
[2406] Fix | Delete
if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
[2407] Fix | Delete
{
[2408] Fix | Delete
// ----- Return
[2409] Fix | Delete
return $v_result;
[2410] Fix | Delete
}
[2411] Fix | Delete
[2412] Fix | Delete
// ----- Store the offset of the central dir
[2413] Fix | Delete
$v_offset = @ftell($this->zip_fd);
[2414] Fix | Delete
[2415] Fix | Delete
// ----- Create the Central Dir files header
[2416] Fix | Delete
for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
[2417] Fix | Delete
{
[2418] Fix | Delete
// ----- Create the file header
[2419] Fix | Delete
if ($v_header_list[$i]['status'] == 'ok') {
[2420] Fix | Delete
if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
[2421] Fix | Delete
// ----- Return
[2422] Fix | Delete
return $v_result;
[2423] Fix | Delete
}
[2424] Fix | Delete
$v_count++;
[2425] Fix | Delete
}
[2426] Fix | Delete
[2427] Fix | Delete
// ----- Transform the header to a 'usable' info
[2428] Fix | Delete
$this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
[2429] Fix | Delete
}
[2430] Fix | Delete
[2431] Fix | Delete
// ----- Zip file comment
[2432] Fix | Delete
$v_comment = '';
[2433] Fix | Delete
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
[2434] Fix | Delete
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
[2435] Fix | Delete
}
[2436] Fix | Delete
[2437] Fix | Delete
// ----- Calculate the size of the central header
[2438] Fix | Delete
$v_size = @ftell($this->zip_fd)-$v_offset;
[2439] Fix | Delete
[2440] Fix | Delete
// ----- Create the central dir footer
[2441] Fix | Delete
if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
[2442] Fix | Delete
{
[2443] Fix | Delete
// ----- Reset the file list
[2444] Fix | Delete
unset($v_header_list);
[2445] Fix | Delete
[2446] Fix | Delete
// ----- Return
[2447] Fix | Delete
return $v_result;
[2448] Fix | Delete
}
[2449] Fix | Delete
[2450] Fix | Delete
// ----- Return
[2451] Fix | Delete
return $v_result;
[2452] Fix | Delete
}
[2453] Fix | Delete
// --------------------------------------------------------------------------------
[2454] Fix | Delete
[2455] Fix | Delete
// --------------------------------------------------------------------------------
[2456] Fix | Delete
// Function : privAddFileList()
[2457] Fix | Delete
// Description :
[2458] Fix | Delete
// Parameters :
[2459] Fix | Delete
// $p_filedescr_list : An array containing the file description
[2460] Fix | Delete
// or directory names to add in the zip
[2461] Fix | Delete
// $p_result_list : list of added files with their properties (specially the status field)
[2462] Fix | Delete
// Return Values :
[2463] Fix | Delete
// --------------------------------------------------------------------------------
[2464] Fix | Delete
function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
[2465] Fix | Delete
{
[2466] Fix | Delete
$v_result=1;
[2467] Fix | Delete
$v_header = array();
[2468] Fix | Delete
[2469] Fix | Delete
// ----- Recuperate the current number of elt in list
[2470] Fix | Delete
$v_nb = sizeof($p_result_list);
[2471] Fix | Delete
[2472] Fix | Delete
// ----- Loop on the files
[2473] Fix | Delete
for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
[2474] Fix | Delete
// ----- Format the filename
[2475] Fix | Delete
$p_filedescr_list[$j]['filename']
[2476] Fix | Delete
= PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
[2477] Fix | Delete
[2478] Fix | Delete
[2479] Fix | Delete
// ----- Skip empty file names
[2480] Fix | Delete
// TBC : Can this be possible ? not checked in DescrParseAtt ?
[2481] Fix | Delete
if ($p_filedescr_list[$j]['filename'] == "") {
[2482] Fix | Delete
continue;
[2483] Fix | Delete
}
[2484] Fix | Delete
[2485] Fix | Delete
// ----- Check the filename
[2486] Fix | Delete
if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
[2487] Fix | Delete
&& (!file_exists($p_filedescr_list[$j]['filename']))) {
[2488] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
[2489] Fix | Delete
return PclZip::errorCode();
[2490] Fix | Delete
}
[2491] Fix | Delete
[2492] Fix | Delete
// ----- Look if it is a file or a dir with no all path reCopy option
[2493] Fix | Delete
// or a dir with all its path reCopyd
[2494] Fix | Delete
// if ( (is_file($p_filedescr_list[$j]['filename']))
[2495] Fix | Delete
// || ( is_dir($p_filedescr_list[$j]['filename'])
[2496] Fix | Delete
if ( ($p_filedescr_list[$j]['type'] == 'file')
[2497] Fix | Delete
|| ($p_filedescr_list[$j]['type'] == 'virtual_file')
[2498] Fix | Delete
|| ( ($p_filedescr_list[$j]['type'] == 'folder')
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function