⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcltar.lib.php

📁 mambo的cms源代码
💻 PHP
📖 第 1 页 / 共 5 页
字号:
  // Parameters :  //   $p_tarname : Name of an existing tar file.  //   $p_path : Path where the files will be extracted. The files will use  //             their memorized path from $p_path.  //             If $p_path is "", files will be extracted in "./".  //   $p_remove_path : Path to remove (from the file memorized path) while writing the  //                    extracted files. If the path does not match the file path,  //                    the file is extracted with its memorized path.  //                    $p_path and $p_remove_path are commulative.  //   $p_mode : 'tar' or 'tgz', if not set, will be determined by $p_tarname extension  // Return Values :  //   Same as PclTarList()  // --------------------------------------------------------------------------------  function PclTarExtract($p_tarname, $p_path="./", $p_remove_path="", $p_mode="")  {    TrFctStart(__FILE__, __LINE__, "PclTarExtract", "tar='$p_tarname', path='$p_path', remove_path='$p_remove_path', mode='$p_mode'");    $v_result=1;    // ----- Extract the tar format from the extension    if (($p_mode == "") || (($p_mode!="tar") && ($p_mode!="tgz")))    {      if (($p_mode = PclTarHandleExtension($p_tarname)) == "")      {        // ----- Return        TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());        return 0;      }    }    // ----- Call the extracting fct    if (($v_result = PclTarHandleExtract($p_tarname, 0, $p_list, "complete", $p_path, $p_mode, $p_remove_path)) != 1)    {      TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());      return(0);    }    // ----- Return    TrFctEnd(__FILE__, __LINE__, $p_list);    return $p_list;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : PclTarExtractList()  // Description :  //   Extract the files present in the archive $p_tarname and specified in  //   $p_filelist, in the directory  //   $p_path. The relative path of the archived files are keep and become  //   relative to $p_path.  //   If a directory is sp閏ified in the list, all the files from this directory  //   will be extracted.  //   If a file with the same name already exists it will be replaced.  //   If the path to the file does not exist, it will be created.  //   Depending on the $p_tarname extension (.tar, .tar.gz or .tgz) the  //   function will determine the type of the archive.  // Parameters :  //   $p_tarname : Name of an existing tar file  //   $p_filelist : An array containing file or directory names, or  //                 a string containing one filename or directory name, or  //                 a string containing a list of filenames and/or directory  //                 names separated by spaces.  //   $p_path : Path where the files will be extracted. The files will use  //             their memorized path from $p_path.  //             If $p_path is "", files will be extracted in "./".  //   $p_remove_path : Path to remove (from the file memorized path) while writing the  //                    extracted files. If the path does not match the file path,  //                    the file is extracted with its memorized path.  //                    $p_path and $p_remove_path are commulative.  //   $p_mode : 'tar' or 'tgz', if not set, will be determined by $p_tarname extension  // Return Values :  //   Same as PclTarList()  // --------------------------------------------------------------------------------  function PclTarExtractList($p_tarname, $p_filelist, $p_path="./", $p_remove_path="", $p_mode="")  {    TrFctStart(__FILE__, __LINE__, "PclTarExtractList", "tar=$p_tarname, list, path=$p_path, remove_path='$p_remove_path', mode='$p_mode'");    $v_result=1;    // ----- Extract the tar format from the extension    if (($p_mode == "") || (($p_mode!="tar") && ($p_mode!="tgz")))    {      if (($p_mode = PclTarHandleExtension($p_tarname)) == "")      {        // ----- Return        TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());        return 0;      }    }    // ----- Look if the $p_filelist is really an array    if (is_array($p_filelist))    {      // ----- Call the extracting fct      if (($v_result = PclTarHandleExtract($p_tarname, $p_filelist, $p_list, "partial", $p_path, $v_tar_mode, $p_remove_path)) != 1)      {        TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());        return(0);      }    }    // ----- Look if the $p_filelist is a string    else if (is_string($p_filelist))    {      // ----- Create a list with the elements from the string      $v_list = explode(" ", $p_filelist);      // ----- Call the extracting fct      if (($v_result = PclTarHandleExtract($p_tarname, $v_list, $p_list, "partial", $p_path, $v_tar_mode, $p_remove_path)) != 1)      {        TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());        return(0);      }    }    // ----- Invalid variable    else    {      // ----- Error log      PclErrorLog(-3, "Invalid variable type p_filelist");      // ----- Return      TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());      return 0;    }    // ----- Return    TrFctEnd(__FILE__, __LINE__, $p_list);    return $p_list;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : PclTarExtractIndex()  // Description :  //   Extract the files present in the archive $p_tarname and specified at  //   the indexes in $p_index, in the directory  //   $p_path. The relative path of the archived files are keep and become  //   relative to $p_path.  //   If a directory is specified in the list, the directory only is created. All  //   the file stored in this archive for this directory  //   are not extracted.  //   If a file with the same name already exists it will be replaced.  //   If the path to the file does not exist, it will be created.  //   Depending on the $p_tarname extension (.tar, .tar.gz or .tgz) the  //   function will determine the type of the archive.  // Parameters :  //   $p_tarname : Name of an existing tar file  //   $p_index : A single index (integer) or a string of indexes of files to  //              extract. The form of the string is "0,4-6,8-12" with only numbers  //              and '-' for range or ',' to separate ranges. No spaces or ';'  //              are allowed.  //   $p_path : Path where the files will be extracted. The files will use  //             their memorized path from $p_path.  //             If $p_path is "", files will be extracted in "./".  //   $p_remove_path : Path to remove (from the file memorized path) while writing the  //                    extracted files. If the path does not match the file path,  //                    the file is extracted with its memorized path.  //                    $p_path and $p_remove_path are commulative.  //   $p_mode : 'tar' or 'tgz', if not set, will be determined by $p_tarname extension  // Return Values :  //   Same as PclTarList()  // --------------------------------------------------------------------------------  function PclTarExtractIndex($p_tarname, $p_index, $p_path="./", $p_remove_path="", $p_mode="")  {    TrFctStart(__FILE__, __LINE__, "PclTarExtractIndex", "tar=$p_tarname, index='$p_index', path=$p_path, remove_path='$p_remove_path', mode='$p_mode'");    $v_result=1;    // ----- Extract the tar format from the extension    if (($p_mode == "") || (($p_mode!="tar") && ($p_mode!="tgz")))    {      if (($p_mode = PclTarHandleExtension($p_tarname)) == "")      {        // ----- Return        TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());        return 0;      }    }    // ----- Look if the $p_index is really an integer    if (is_integer($p_index))    {      // ----- Call the extracting fct      if (($v_result = PclTarHandleExtractByIndexList($p_tarname, "$p_index", $p_list, $p_path, $p_remove_path, $v_tar_mode)) != 1)      {        TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());        return(0);      }    }    // ----- Look if the $p_filelist is a string    else if (is_string($p_index))    {      // ----- Call the extracting fct      if (($v_result = PclTarHandleExtractByIndexList($p_tarname, $p_index, $p_list, $p_path, $p_remove_path, $v_tar_mode)) != 1)      {        TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());        return(0);      }    }    // ----- Invalid variable    else    {      // ----- Error log      PclErrorLog(-3, "Invalid variable type $p_index");      // ----- Return      TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());      return 0;    }    // ----- Return    TrFctEnd(__FILE__, __LINE__, $p_list);    return $p_list;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : PclTarDelete()  // Description :  //   This function deletes from the archive $p_tarname the files which are listed  //   in $p_filelist. $p_filelist can be a string with file names separated by  //   spaces, or an array containing the file names.  // Parameters :  //   $p_tarname : Name of an existing tar file  //   $p_filelist : An array or a string containing file names to remove from the  //                 archive.  //   $p_mode : 'tar' or 'tgz', if not set, will be determined by $p_tarname extension  // Return Values :  //   List of the files which are kept in the archive (same format as PclTarList())  // --------------------------------------------------------------------------------  function PclTarDelete($p_tarname, $p_filelist, $p_mode="")  {    TrFctStart(__FILE__, __LINE__, "PclTarDelete", "tar='$p_tarname', list='$p_filelist', mode='$p_mode'");    $v_result=1;    // ----- Extract the tar format from the extension    if (($p_mode == "") || (($p_mode!="tar") && ($p_mode!="tgz")))    {      if (($p_mode = PclTarHandleExtension($p_tarname)) == "")      {        // ----- Return        TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());        return 0;      }    }    // ----- Look if the $p_filelist is really an array    if (is_array($p_filelist))    {      // ----- Call the extracting fct      if (($v_result = PclTarHandleDelete($p_tarname, $p_filelist, $p_list, $p_mode)) != 1)      {        TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());        return(0);      }    }    // ----- Look if the $p_filelist is a string    else if (is_string($p_filelist))    {      // ----- Create a list with the elements from the string      $v_list = explode(" ", $p_filelist);      // ----- Call the extracting fct      if (($v_result = PclTarHandleDelete($p_tarname, $v_list, $p_list, $p_mode)) != 1)      {        TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());        return(0);      }    }    // ----- Invalid variable    else    {      // ----- Error log      PclErrorLog(-3, "Invalid variable type p_filelist");      // ----- Return      TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());      return 0;    }    // ----- Return    TrFctEnd(__FILE__, __LINE__, $p_list);    return $p_list;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : PclTarUpdate()  // Description :  //   This function updates the files in $p_filelist which are already in the  //   $p_tarname archive with an older last modified date. If the file does not  //   exist, it is added at the end of the archive.  // Parameters :  //   $p_tarname : Name of an existing tar file  //   $p_filelist : An array or a string containing file names to update from the  //                 archive.  //   $p_mode : 'tar' or 'tgz', if not set, will be determined by $p_tarname extension  // Return Values :  //   List of the files contained in the archive. The field status contains  //   "updated", "not_updated", "added" or "ok" for the files not concerned.  // --------------------------------------------------------------------------------  function PclTarUpdate($p_tarname, $p_filelist, $p_mode="", $p_add_dir="", $p_remove_dir="")  {    TrFctStart(__FILE__, __LINE__, "PclTarUpdate", "tar='$p_tarname', list='$p_filelist', mode='$p_mode'");    $v_result=1;    // ----- Extract the tar format from the extension    if (($p_mode == "") || (($p_mode!="tar") && ($p_mode!="tgz")))    {      if (($p_mode = PclTarHandleExtension($p_tarname)) == "")      {        // ----- Return        TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());        return 0;      }    }    // ----- Look if the $p_filelist is really an array    if (is_array($p_filelist))    {      // ----- Call the extracting fct      if (($v_result = PclTarHandleUpdate($p_tarname, $p_filelist, $p_list, $p_mode, $p_add_dir, $p_remove_dir)) != 1)      {        TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());        return(0);      }    }    // ----- Look if the $p_filelist is a string    else if (is_string($p_filelist))    {      // ----- Create a list with the elements from the string      $v_list = explode(" ", $p_filelist);      // ----- Call the extracting fct      if (($v_result = PclTarHandleUpdate($p_tarname, $v_list, $p_list, $p_mode, $p_add_dir, $p_remove_dir)) != 1)      {        TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());        return(0);      }    }    // ----- Invalid variable    else    {      // ----- Error log      PclErrorLog(-3, "Invalid variable type p_filelist");      // ----- Return      TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());      return 0;    }    // ----- Return    TrFctEnd(__FILE__, __LINE__, $p_list);    return $p_list;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -