mp_tar, $p_list, $p_mode, $p_list_detail, $p_add_dir, $p_remove_dir)) == 1) { // ----- Call the footer of the tar archive $v_result = PclTarHandleFooter($v_temp_tar, $p_mode); } // ----- Close the files gzclose($p_tar); gzclose($v_temp_tar); // ----- Unlink tar file if (!@unlink($p_tarname)) { // ----- Error log PclErrorLog(-11, "Error while deleting archive name $p_tarname"); } // ----- Rename tar file if (!@rename($v_temp_tarname, $p_tarname)) { // ----- Error log PclErrorLog(-12, "Error while renaming temporary file $v_temp_tarname to archive name $p_tarname"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Return TrFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look for uncompressed tar file else if ($p_mode=="tar") { // ----- Open the tar file if (($p_tar = fopen($p_tarname, "r+b")) == 0) { // ----- Error log PclErrorLog(-1, "Unable to open file '$p_tarname' in binary write mode"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Go to the beginning of last block TrFctMessage(__FILE__, __LINE__, 4, "Position before :".($p_mode=="tar"?ftell($p_tar):gztell($p_tar))); fseek($p_tar, $v_size-512); TrFctMessage(__FILE__, __LINE__, 4, "Position after :".($p_mode=="tar"?ftell($p_tar):gztell($p_tar))); // ----- Call the adding fct inside the tar if (($v_result = PclTarHandleAddList($p_tar, $p_list, $p_mode, $p_list_detail, $p_add_dir, $p_remove_dir)) == 1) { // ----- Call the footer of the tar archive $v_result = PclTarHandleFooter($p_tar, $p_mode); } // ----- Close the tarfile fclose($p_tar); } // ----- Look for unknown type else { // ----- Error log PclErrorLog(-3, "Invalid tar mode $p_mode"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Return TrFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclTarHandleAddList() // Description : // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is // different from the real path of the file. This is usefull if you want to have PclTar // running in any directory, and memorize relative path from an other directory. // Parameters : // $p_tar : File descriptor of the tar archive // $p_list : An array containing the file or directory names to add in the tar // $p_mode : "tar" for normal tar archive, "tgz" for gzipped tar archive // $p_list_detail : list of added files with their properties (specially the status field) // $p_add_dir : Path to add in the filename path archived // $p_remove_dir : Path to remove in the filename path archived // Return Values : // -------------------------------------------------------------------------------- function PclTarHandleAddList($p_tar, $p_list, $p_mode, &$p_list_detail, $p_add_dir, $p_remove_dir) { TrFctStart(__FILE__, __LINE__, "PclTarHandleAddList", "tar='$p_tar', list, mode='$p_mode', add_dir='$p_add_dir', remove_dir='$p_remove_dir'"); $v_result=1; $v_header = array(); // ----- Recuperate the current number of elt in list $v_nb = sizeof($p_list_detail); // ----- Check the parameters if ($p_tar == 0) { // ----- Error log PclErrorLog(-3, "Invalid file descriptor in file ".__FILE__.", line ".__LINE__); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Check the arguments if (sizeof($p_list) == 0) { // ----- Error log PclErrorLog(-3, "Invalid file list parameter (invalid or empty list)"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Loop on the files for ($j=0; ($j 99) { // ----- Error log PclErrorLog(-5, "File name is too long (max. 99) : '$p_filename'"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } TrFctMessage(__FILE__, __LINE__, 4, "File position before header =".($p_mode=="tar"?ftell($p_tar):gztell($p_tar))); // ----- Add the file if (($v_result = PclTarHandleAddFile($p_tar, $p_filename, $p_mode, $v_header, $p_add_dir, $p_remove_dir)) != 1) { // ----- Return status TrFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Store the file infos $p_list_detail[$v_nb++] = $v_header; // ----- Look for directory if (is_dir($p_filename)) { TrFctMessage(__FILE__, __LINE__, 2, "$p_filename is a directory"); // ----- Look for path if ($p_filename != ".") $v_path = $p_filename."/"; else $v_path = ""; // ----- Read the directory for files and sub-directories $p_hdir = opendir($p_filename); $p_hitem = readdir($p_hdir); // '.' directory $p_hitem = readdir($p_hdir); // '..' directory while ($p_hitem = readdir($p_hdir)) { // ----- Look for a file if (is_file($v_path.$p_hitem)) { TrFctMessage(__FILE__, __LINE__, 4, "Add the