]> git.mjollnir.org Git - moodle.git/commitdiff
Upgrading to version 2.0 RC1 - hoping it will fix some Windows problems
authormoodler <moodler>
Sun, 17 Aug 2003 12:35:20 +0000 (12:35 +0000)
committermoodler <moodler>
Sun, 17 Aug 2003 12:35:20 +0000 (12:35 +0000)
in the older version.

lib/pclzip/pclzip.lib.php
lib/pclzip/readme.txt

index 0806cffde99efb7e4027dc1cd4bad01bfcc8cf02..75d69929d6dadd8de6cf9ea013118385a3ada4b3 100644 (file)
@@ -1,8 +1,8 @@
 <?php\r
 // --------------------------------------------------------------------------------\r
-// PhpConcept Library - Zip Module 1.3\r
+// PhpConcept Library - Zip Module 2.0-rc1\r
 // --------------------------------------------------------------------------------\r
-// License GNU/LGPL - Vincent Blavet - January 2003\r
+// License GNU/LGPL - Vincent Blavet - July 2003\r
 // http://www.phpconcept.net\r
 // --------------------------------------------------------------------------------\r
 //\r
 \r
   // ----- Constants\r
   define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );\r
+  \r
+  // ----- File list separator\r
+  // In version 1.x of PclZip, the separator for file list is a space\r
+  // (which is not a very smart choice, specifically for windows paths !).\r
+  // A better separator should be a comma (,). This constant gives you the\r
+  // abilty to change that.\r
+  // However notice that changing this value, may have impact on existing\r
+  // scripts, using space separated filenames.\r
+  // Recommanded values for compatibility with older versions :\r
+  //define( 'PCLZIP_SEPARATOR', ' ' );\r
+  // Recommanded values for smart separation of filenames.\r
+  define( 'PCLZIP_SEPARATOR', ',' );\r
 \r
   // ----- Error configuration\r
   // 0 : PclZip Class integrated error handling\r
@@ -51,7 +63,7 @@
 // --------------------------------------------------------------------------------\r
 \r
   // ----- Global variables\r
-  $g_pclzip_version = "1.3";\r
+  $g_pclzip_version = "2.0-rc1";\r
 \r
   // ----- Error codes\r
   //   -1 : Unable to open file in binary write mode\r
   define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );\r
   define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );\r
   define( 'PCLZIP_OPT_SET_CHMOD', 77005 );\r
+  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );\r
+  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );\r
 \r
   // ----- Call backs values\r
   define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );\r
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
                                                    PCLZIP_OPT_ADD_PATH => 'optional',\r
                                                    PCLZIP_CB_PRE_ADD => 'optional',\r
-                                                   PCLZIP_CB_POST_ADD => 'optional' ));\r
+                                                   PCLZIP_CB_POST_ADD => 'optional',\r
+                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional' ));\r
         if ($v_result != 1) {\r
           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
           return 0;\r
         if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
           $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
         }\r
+        if (!isset($v_options[PCLZIP_OPT_NO_COMPRESSION])) {\r
+          $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_NO_COMPRESSION not set.");\r
+        }\r
+        else {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_NO_COMPRESSION set.");\r
+        }\r
       }\r
 \r
       // ----- Look for 2 args\r
     else if (is_string($p_filelist))\r
     {\r
       // ----- Create a list with the elements from the string\r
-      $v_list = explode(" ", $p_filelist);\r
+      $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);\r
 \r
       // ----- Call the create fct\r
       $v_result = $this->privCreate($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
                                                    PCLZIP_OPT_ADD_PATH => 'optional',\r
                                                    PCLZIP_CB_PRE_ADD => 'optional',\r
-                                                   PCLZIP_CB_POST_ADD => 'optional' ));\r
+                                                   PCLZIP_CB_POST_ADD => 'optional',\r
+                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional' ));\r
         if ($v_result != 1) {\r
           //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
           return 0;\r
         if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
           $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
         }\r
+        if (!isset($v_options[PCLZIP_OPT_NO_COMPRESSION])) {\r
+          $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_NO_COMPRESSION not set.");\r
+        }\r
+        else {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_NO_COMPRESSION set.");\r
+        }\r
       }\r
 \r
       // ----- Look for 2 args\r
     else if (is_string($p_filelist))\r
     {\r
       // ----- Create a list with the elements from the string\r
-      $v_list = explode(" ", $p_filelist);\r
+      $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);\r
 \r
       // ----- Call the create fct\r
       $v_result = $this->privAdd($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
   //   PCLZIP_OPT_ADD_PATH :\r
   //   PCLZIP_OPT_REMOVE_PATH :\r
   //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
+  //   PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and\r
+  //     not as files.\r
+  //     The resulting content is in a new field 'content' in the file\r
+  //     structure.\r
+  //     This option must be used alone (any other options are ignored).\r
   //   PCLZIP_CB_PRE_EXTRACT :\r
   //   PCLZIP_CB_POST_EXTRACT :\r
   // Return Values :\r
   //   The list of the extracted files, with a status of the action.\r
   //   (see PclZip::listContent() for list entry format)\r
   // --------------------------------------------------------------------------------\r
-//  function extractByIndex($p_index, $p_path="./", $p_remove_path="")\r
   function extractByIndex($p_index /* $options */)\r
   {\r
     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");\r
     $v_size = func_num_args();\r
     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
 \r
+    // ----- Default values for option\r
+    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;\r
+\r
     // ----- Look for arguments\r
     if ($v_size > 1) {\r
       // ----- Get the arguments\r
                                             array (PCLZIP_OPT_PATH => 'optional',\r
                                                    PCLZIP_OPT_REMOVE_PATH => 'optional',\r
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
+                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',\r
                                                    PCLZIP_OPT_ADD_PATH => 'optional',\r
                                                    PCLZIP_CB_PRE_EXTRACT => 'optional',\r
                                                    PCLZIP_CB_POST_EXTRACT => 'optional',\r
           }\r
           $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];\r
         }\r
+        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {\r
+          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");\r
+        }\r
+        else {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");\r
+        }\r
       }\r
 \r
       // ----- Look for 2 args\r
           }\r
 \r
           // ----- Get the value\r
-          $v_result_list[$p_options_list[$i]] = strtr($p_options_list[$i+1], '\\', '/');\r
+          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);\r
           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
           $i++;\r
         break;\r
 \r
         // ----- Look for options that request no value\r
         case PCLZIP_OPT_REMOVE_ALL_PATH :\r
+        case PCLZIP_OPT_EXTRACT_AS_STRING :\r
+        case PCLZIP_OPT_NO_COMPRESSION :\r
           $v_result_list[$p_options_list[$i]] = true;\r
           //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
         break;\r
     for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++)\r
     {\r
       // ----- Recuperate the filename\r
-      $p_filename = $p_list[$j];\r
+      $p_filename = PclZipUtilTranslateWinPath($p_list[$j], false);\r
 \r
       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file [$p_filename]");\r
 \r
           $p_remove_dir = substr($p_remove_dir, 2);\r
       }\r
 \r
-      if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)\r
+      $v_compare = PclZipUtilPathInclusion($p_remove_dir, $p_filename);\r
+      if ($v_compare > 0)\r
+//      if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)\r
       {\r
-        $v_stored_filename = substr($p_filename, strlen($p_remove_dir));\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path '$p_remove_dir' in file '$p_filename' = '$v_stored_filename'");\r
+\r
+        if ($v_compare == 2) {\r
+          $v_stored_filename = "";\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");\r
+        }\r
+        else {\r
+          $v_stored_filename = substr($p_filename, strlen($p_remove_dir));\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$p_filename' = '$v_stored_filename'");\r
+        }\r
       }\r
     }\r
     // ----- Look for path to add\r
       }\r
     }\r
 \r
+    // ----- Look for empty stored filename\r
+    if ($p_header['stored_filename'] == "") {\r
+      $p_header['status'] = "filtered";\r
+    }\r
+    \r
     // ----- Check the path length\r
     if (strlen($p_header['stored_filename']) > 0xFF) {\r
       $p_header['status'] = 'filename_too_long';\r
     // ----- Look if no error, or file not skipped\r
     if ($p_header['status'] == 'ok') {\r
 \r
-    // ----- Look for a file\r
-    if (is_file($p_filename))\r
-    {\r
-      // ----- Open the source file\r
-      if (($v_file = @fopen($p_filename, "rb")) == 0)\r
-      {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-\r
-      // ----- Creates a compressed temporary file\r
-      if (($v_file_compressed = @gzopen($p_filename.'.gz', "wb")) == 0)\r
-      {\r
-        // ----- Close the file\r
-        fclose($v_file);\r
-\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Unable to open file '$p_filename.gz' in gz binary write mode");\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-\r
-      // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
-      $v_size = filesize($p_filename);\r
-      while ($v_size != 0)\r
-      {\r
-        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
-        $v_buffer = fread($v_file, $v_read_size);\r
-        $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
-        @gzputs($v_file_compressed, $v_binary_data, $v_read_size);\r
-        $v_size -= $v_read_size;\r
-      }\r
-\r
-      // ----- Close the file\r
-      @fclose($v_file);\r
-      @gzclose($v_file_compressed);\r
-\r
-      // ----- Check the minimum file size\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "gzip file size ".filesize($p_filename.'.gz'));\r
-      if (filesize($p_filename.'.gz') < 18)\r
+      // ----- Look for a file\r
+      if (is_file($p_filename))\r
       {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Invalid file "'.$p_filename.'.gz'.'" size (less than header size)');\r
+        // ----- Open the source file\r
+        if (($v_file = @fopen($p_filename, "rb")) == 0) {\r
+          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+          return PclZip::errorCode();\r
+        }\r
 \r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
+        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {\r
+          // ----- Read the file content\r
+          $v_content_compressed = @fread($v_file, $p_header['size']);\r
 \r
-      // ----- Extract the compressed attributes\r
-      if (($v_file_compressed = @fopen($p_filename.'.gz', "rb")) == 0)\r
-      {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename.gz' in gz binary read mode");\r
+          // ----- Calculate the CRC\r
+          $p_header['crc'] = crc32($v_content_compressed);\r
+        }\r
+        else {\r
+          // ----- Read the file content\r
+          $v_content = @fread($v_file, $p_header['size']);\r
 \r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
+          // ----- Calculate the CRC\r
+          $p_header['crc'] = crc32($v_content);\r
 \r
-      // ----- Read the gzip file header\r
-      $v_binary_data = @fread($v_file_compressed, 10);\r
-      $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);\r
-\r
-      // ----- Check some parameters\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id1]='.bin2hex($v_data_header['id1']));\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id2]='.bin2hex($v_data_header['id2']));\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[cm]='.bin2hex($v_data_header['cm']));\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[flag]='.bin2hex($v_data_header['flag']));\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[mtime]='.$v_data_header['mtime']);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[xfl]='.bin2hex($v_data_header['xfl']));\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[os]='.bin2hex($v_data_header['os']));\r
-      $v_data_header['os'] = bin2hex($v_data_header['os']);\r
-\r
-      // ----- Read the gzip file footer\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after header ".ftell($v_file_compressed));\r
-      @fseek($v_file_compressed, filesize($p_filename.'.gz')-8);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position at beginning of footer ".ftell($v_file_compressed));\r
-      $v_binary_data = @fread($v_file_compressed, 8);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after footer ".ftell($v_file_compressed));\r
-      $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);\r
-\r
-      // ----- Set the attributes\r
-      $p_header['compression'] = ord($v_data_header['cm']);\r
-      //$p_header['mtime'] = $v_data_header['mtime'];\r
-      $p_header['crc'] = $v_data_footer['crc'];\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Compressed size ".(filesize($p_filename.'.gz')-18));\r
-      $p_header['compressed_size'] = filesize($p_filename.'.gz')-18;\r
-\r
-      // ----- Close the file\r
-      @fclose($v_file_compressed);\r
-\r
-      // ----- Call the header generation\r
-      if (($v_result = $this->privWriteFileHeader($p_header)) != 1)\r
-      {\r
-        // ----- Return status\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        return $v_result;\r
-      }\r
+          // ----- Compress the file\r
+          $v_content_compressed = gzdeflate($v_content);\r
+        }\r
 \r
-      // ----- Add the compressed data\r
-      if (($v_file_compressed = @fopen($p_filename.'.gz', "rb")) == 0)\r
-      {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename.gz' in gz binary read mode");\r
+        // ----- Set header parameters\r
+        $p_header['compressed_size'] = strlen($v_content_compressed);\r
+        $p_header['compression'] = 8;\r
 \r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
+        // ----- Call the header generation\r
+        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {\r
+          @fclose($v_file);\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
 \r
-      // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
-      fseek($v_file_compressed, 10);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position before reading compressed data ".ftell($v_file_compressed));\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, ' '.$p_header['compressed_size'].' bytes to read');\r
-      $v_size = $p_header['compressed_size'];\r
-      while ($v_size != 0)\r
-      {\r
-        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
-        $v_buffer = fread($v_file_compressed, $v_read_size);\r
-        $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
-        @fwrite($this->zip_fd, $v_binary_data, $v_read_size);\r
-        $v_size -= $v_read_size;\r
+        // ----- Write the compressed content\r
+        $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed);\r
+        @fwrite($this->zip_fd, $v_binary_data, $p_header['compressed_size']);\r
+        \r
+        // ----- Close the file\r
+        @fclose($v_file);\r
       }\r
 \r
-      // ----- Close the file\r
-      @fclose($v_file_compressed);\r
-\r
-      // ----- Unlink the temporary file\r
-      @unlink($p_filename.'.gz');\r
-    }\r
-\r
-    // ----- Look for a directory\r
-    else\r
-    {\r
-      // ----- Set the file properties\r
-      $p_header['filename'] .= '/';\r
-      $p_header['filename_len']++;\r
-      $p_header['size'] = 0;\r
-      $p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked\r
-\r
-      // ----- Call the header generation\r
-      if (($v_result = $this->privWriteFileHeader($p_header)) != 1)\r
+      // ----- Look for a directory\r
+      else\r
       {\r
-        // ----- Return status\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        return $v_result;\r
+        // ----- Set the file properties\r
+        $p_header['filename'] .= '/';\r
+        $p_header['filename_len']++;\r
+        $p_header['size'] = 0;\r
+        $p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked\r
+\r
+        // ----- Call the header generation\r
+        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
       }\r
     }\r
-    }\r
 \r
     // ----- Look for pre-add callback\r
     if (isset($p_options[PCLZIP_CB_POST_ADD])) {\r
     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtract", "list, path=$p_path, remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");\r
     $v_result=1;\r
 \r
-// COMMENTED OUT FOR MOODLE - IT WAS CAUSING PROBLEMS FOR WINDOWS  - Martin 25/5/2003\r
-//\r
-//    // ----- Check the path\r
-//    if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../")))\r
-//      $p_path = "./".$p_path;\r
-\r
+    // ----- Check the path\r
+    if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../")&& (substr($p_path,1,2)!= ":/")))\r
+      $p_path = "./".$p_path;\r
 \r
     // ----- Reduce the path last (and duplicated) '/'\r
     if (($p_path != "./") && ($p_path != "/"))\r
     $v_result=1;\r
 \r
     // ----- Check the path\r
-    if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../")))\r
+    if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../")&& (substr($p_path,1,2)!=":/")))\r
       $p_path = "./".$p_path;\r
 \r
     // ----- Reduce the path last (and duplicated) '/'\r
         }\r
         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");\r
 \r
-        // ----- Extracting the file\r
-        if (($v_result = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options)) != 1)\r
-        {\r
-          // ----- Close the zip file\r
-          $this->privCloseFd();\r
+        // ----- Look for extraction as string\r
+        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {\r
 \r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
+          // ----- Extracting the file\r
+          if (($v_result = $this->privExtractFileAsString($v_header, $v_string)) != 1)\r
+          {\r
+            // ----- Close the zip file\r
+            $this->privCloseFd();\r
+\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+            return $v_result;\r
+          }\r
+\r
+          // ----- Get the only interesting attributes\r
+          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)\r
+          {\r
+            // ----- Close the zip file\r
+            $this->privCloseFd();\r
+\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+            return $v_result;\r
+          }\r
+          \r
+          // ----- Set the file content\r
+          $p_file_list[$v_nb_extracted]['content'] = $v_string;\r
+          \r
+          // ----- Next extracted file\r
+          $v_nb_extracted++;\r
         }\r
+        else {\r
+          // ----- Extracting the file\r
+          if (($v_result = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options)) != 1)\r
+          {\r
+            // ----- Close the zip file\r
+            $this->privCloseFd();\r
 \r
-        // ----- Get the only interesting attributes\r
-        if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)\r
-        {\r
-          // ----- Close the zip file\r
-          $this->privCloseFd();\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+            return $v_result;\r
+          }\r
 \r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
+          // ----- Get the only interesting attributes\r
+          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)\r
+          {\r
+            // ----- Close the zip file\r
+            $this->privCloseFd();\r
+\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+            return $v_result;\r
+          }\r
         }\r
       }\r
     }\r
       if ($v_result == 0) {\r
         // ----- Change the file status\r
         $p_entry['status'] = "skipped";\r
+        $v_result = 1;\r
       }\r
 \r
       // ----- Update the informations\r
 \r
     // ----- Check the directory availability and create it if necessary\r
     else {\r
-      if (substr($p_entry['filename'], -1) == '/')\r
+      if (($p_entry['external']==0x41FF0010) || (substr($p_entry['filename'], -1) == '/'))\r
         $v_dir_to_check = $p_entry['filename'];\r
       else if (!strstr($p_entry['filename'], "/"))\r
         $v_dir_to_check = "";\r
     // ----- Look if extraction should be done\r
     if ($p_entry['status'] == 'ok') {\r
 \r
-    // ----- Do the extraction (if not a folder)\r
-    if (!($p_entry['external']==0x41FF0010))\r
-    {\r
-\r
-      // ----- Look for not compressed file\r
-      if ($p_entry['compressed_size'] == $p_entry['size'])\r
+      // ----- Do the extraction (if not a folder)\r
+      if (!($p_entry['external']==0x41FF0010))\r
       {\r
-        // ----- Trace\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");\r
 \r
-        // ----- Opening destination file\r
-        if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)\r
+        // ----- Look for not compressed file\r
+        if ($p_entry['compressed_size'] == $p_entry['size'])\r
         {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
-\r
-          // ----- Change the file status\r
-          $p_entry['status'] = "write_error";\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
-        }\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");\r
 \r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");\r
+          // ----- Opening destination file\r
+          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)\r
+          {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
 \r
-        // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
-        $v_size = $p_entry['compressed_size'];\r
-        while ($v_size != 0)\r
-        {\r
-          $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
-          $v_buffer = fread($this->zip_fd, $v_read_size);\r
-          $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
-          @fwrite($v_dest_file, $v_binary_data, $v_read_size);\r
-          $v_size -= $v_read_size;\r
-        }\r
+            // ----- Change the file status\r
+            $p_entry['status'] = "write_error";\r
 \r
-        // ----- Closing the destination file\r
-        fclose($v_dest_file);\r
+            // ----- Return\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+            return $v_result;\r
+          }\r
 \r
-        // ----- Change the file mtime\r
-        touch($p_entry['filename'], $p_entry['mtime']);\r
-      }\r
-      else\r
-      {\r
-        // ----- Trace\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");\r
 \r
-        // ----- Open the destination file in write mode\r
-        if (($v_dest_file = @fopen($p_entry['filename'].'.gz', 'wb')) == 0)\r
-        {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
+          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
+          $v_size = $p_entry['compressed_size'];\r
+          while ($v_size != 0)\r
+          {\r
+            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
+            $v_buffer = fread($this->zip_fd, $v_read_size);\r
+            $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
+            @fwrite($v_dest_file, $v_binary_data, $v_read_size);\r
+            $v_size -= $v_read_size;\r
+          }\r
 \r
-          // ----- Change the file status\r
-          $p_entry['status'] = "write_error";\r
+          // ----- Closing the destination file\r
+          fclose($v_dest_file);\r
 \r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
+          // ----- Change the file mtime\r
+          touch($p_entry['filename'], $p_entry['mtime']);\r
         }\r
-\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Start extraction of '".$p_entry['filename']."'");\r
-\r
-        // ----- Write gz file format header\r
-        $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));\r
-        fwrite($v_dest_file, $v_binary_data, 10);\r
-\r
-        // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
-        $v_size = $p_entry['compressed_size'];\r
-        while ($v_size != 0)\r
+        else\r
         {\r
-          $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
-          $v_buffer = fread($this->zip_fd, $v_read_size);\r
-          $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
-          @fwrite($v_dest_file, $v_binary_data, $v_read_size);\r
-          $v_size -= $v_read_size;\r
-        }\r
+          // ----- Trace\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");\r
 \r
-        // ----- Write gz file format footer\r
-        $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);\r
-        fwrite($v_dest_file, $v_binary_data, 8);\r
+          // ----- Opening destination file\r
+          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
 \r
-        // ----- Close the temporary file\r
-        fclose($v_dest_file);\r
+            // ----- Change the file status\r
+            $p_entry['status'] = "write_error";\r
 \r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after extract [".ftell($this->zip_fd)."]");\r
-\r
-        // ----- Uncompress\r
-        if (($v_src_file = gzopen($p_entry['filename'].'.gz', 'rb')) == 0)\r
-        {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in read binary mode");\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+            return $v_result;\r
+          }\r
 \r
-          // ----- Change the file status\r
-          $p_entry['status'] = "read_error";\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");\r
 \r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
-        }\r
+          // ----- Read the compressed file in a buffer (one shot)\r
+          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);\r
+          \r
+          // ----- Decompress the file\r
+          $v_file_content = gzinflate($v_buffer);\r
+          unset($v_buffer);\r
 \r
-        if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)\r
-        {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
+          // ----- Write the uncompressed data\r
+          @fwrite($v_dest_file, $v_file_content, $p_entry['size']);\r
+          unset($v_file_content);\r
 \r
-          // ----- Change the file status\r
-          $p_entry['status'] = "write_error";\r
-          gzclose($v_src_file);\r
+          // ----- Closing the destination file\r
+          @fclose($v_dest_file);\r
 \r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
+          // ----- Change the file mtime\r
+          touch($p_entry['filename'], $p_entry['mtime']);\r
         }\r
 \r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File size is '.filesize($p_entry['filename'].'.gz'));\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '$p_entry[size]' bytes");\r
+        // ----- Look for chmod option\r
+        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");\r
 \r
-        // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
-        $v_size = $p_entry['size'];\r
-        while ($v_size != 0)\r
-        {\r
-          $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
-          $v_buffer = gzread($v_src_file, $v_read_size);\r
-          $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
-          @fwrite($v_dest_file, $v_binary_data, $v_read_size);\r
-          $v_size -= $v_read_size;\r
+          // ----- Change the mode of the file\r
+          chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);\r
         }\r
-        fclose($v_dest_file);\r
-        gzclose($v_src_file);\r
-\r
-        // ----- Change the file mtime\r
-        touch($p_entry['filename'], $p_entry['mtime']);\r
 \r
-        // ----- Delete the temporary file\r
-        @unlink($p_entry['filename'].'.gz');\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");\r
       }\r
-\r
-      // ----- Look for chmod option\r
-      if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");\r
-\r
-        // ----- Change the mode of the file\r
-        chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);\r
-      }\r
-\r
-      // ----- Trace\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");\r
-    }\r
     }\r
 \r
     // ----- Look for post-extract callback\r
   }\r
   // --------------------------------------------------------------------------------\r
 \r
+  // --------------------------------------------------------------------------------\r
+  // Function : privExtractFileAsString()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privExtractFileAsString(&$p_entry, &$p_string)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");\r
+    $v_result=1;\r
+\r
+    // ----- Read the file header\r
+    $v_header = array();\r
+    if (($v_result = $this->privReadFileHeader($v_header)) != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");\r
+\r
+    // ----- Check that the file header is coherent with $p_entry info\r
+    // TBC\r
+\r
+    // ----- Trace\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");\r
+\r
+    // ----- Do the extraction (if not a folder)\r
+    if (!($p_entry['external']==0x41FF0010))\r
+    {\r
+      // ----- Look for not compressed file\r
+      if ($p_entry['compressed_size'] == $p_entry['size'])\r
+      {\r
+        // ----- Trace\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");\r
+\r
+        // ----- Reading the file\r
+        $p_string = fread($this->zip_fd, $p_entry['compressed_size']);\r
+      }\r
+      else\r
+      {\r
+        // ----- Trace\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");\r
+\r
+        // ----- Reading the file\r
+        $v_data = fread($this->zip_fd, $p_entry['compressed_size']);\r
+        \r
+        // ----- Decompress the file\r
+        $p_string = gzinflate($v_data);\r
+      }\r
+\r
+      // ----- Trace\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");\r
+    }\r
+    else {\r
+        // TBC : error : can not extract a folder in a string\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
   // --------------------------------------------------------------------------------\r
   // Function : privReadFileHeader()\r
   // Description :\r
     if ($v_size > 26) {\r
       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');\r
       @fseek($this->zip_fd, $v_size-22);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');\r
       if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))\r
       {\r
         // ----- Error log\r
         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
         return PclZip::errorCode();\r
       }\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');\r
 \r
       // ----- Read for bytes\r
       $v_binary_data = @fread($this->zip_fd, 4);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");\r
       $v_data = unpack('Vid', $v_binary_data);\r
       //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");\r
 \r
 \r
     // ----- Go back to the maximum possible size of the Central Dir End Record\r
     if (!$v_found) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');\r
       $v_maximum_size = 65557; // 0xFFFF + 22;\r
       if ($v_maximum_size > $v_size)\r
         $v_maximum_size = $v_size;\r
         // ----- Compare the bytes\r
         if ($v_bytes == 0x504b0506)\r
         {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature : \''.ftell($this->zip_fd).'\'');\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');\r
           $v_pos++;\r
           break;\r
         }\r
     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);\r
     if (($v_pos + $v_data['comment_size'] + 18) != $v_size)\r
     {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Fail to find the right siganture");\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Fail to find the right signature");\r
 \r
       // ----- Error log\r
       PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Fail to find the right signature");\r
       case PCLZIP_OPT_REMOVE_ALL_PATH :\r
         $v_result = 'PCLZIP_OPT_REMOVE_ALL_PATH';\r
       break;\r
+      case PCLZIP_OPT_EXTRACT_AS_STRING :\r
+        $v_result = 'PCLZIP_OPT_EXTRACT_AS_STRING';\r
+      break;\r
       case PCLZIP_OPT_SET_CHMOD :\r
         $v_result = 'PCLZIP_OPT_SET_CHMOD';\r
       break;\r
   }\r
   // --------------------------------------------------------------------------------\r
 \r
+  // --------------------------------------------------------------------------------\r
+  // Function : PclZipUtilTranslateWinPath()\r
+  // Description :\r
+  //   Translate windows path by replacing '\' by '/' and optionally removing\r
+  //   drive letter.\r
+  // Parameters :\r
+  //   $p_path : path to translate.\r
+  //   $p_remove_disk_letter : true | false\r
+  // Return Values :\r
+  //   The path translated.\r
+  // --------------------------------------------------------------------------------\r
+  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)\r
+  {\r
+    if (OS_WINDOWS) {\r
+      // ----- Look for potential disk letter\r
+      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {\r
+          $p_path = substr($p_path, $v_position+1);\r
+      }\r
+      // ----- Change potential windows directory separator\r
+      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {\r
+          $p_path = strtr($p_path, '\\', '/');\r
+      }\r
+    }\r
+    return $p_path;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
 ?>\r
index 4d8b601d44539743918eb5f615e483314a7469d1..e53dfaf7bd85c7a5ef0e4c78680b8d4f62917a8a 100644 (file)
@@ -1,5 +1,5 @@
 // --------------------------------------------------------------------------------\r
-// PclZip 1.3 - readme.txt\r
+// PclZip 2.0-rc1 - readme.txt\r
 // --------------------------------------------------------------------------------\r
 // License GNU/GPL - january 2003\r
 // Vincent Blavet - vincent@phpconcept.net\r
 2 - What's new\r
 ==============\r
 \r
+  Version 2.0-rc1 :\r
+    ***** Warning : Some new features may break the backward compatibility for your scripts.\r
+                    Please carefully read the readme file.\r
+    - Add the ability to add files without compression. This is done with a new attribute\r
+      which is PCLZIP_OPT_NO_COMPRESSION.\r
+    - Add the attribute PCLZIP_OPT_EXTRACT_AS_STRING, which allow to extract a file directly\r
+      in a string without using any file (or temporary file).\r
+    - Add constant PCLZIP_SEPARATOR for static configuration of filename separators in a single string.\r
+      The default separator is now a comma (,) and not any more a blank space.\r
+      THIS BREAK THE BACKWARD COMPATIBILITY : Please check if this may have an impact with\r
+      your script.\r
+    - Improve algorythm performance by removing the use of temporary files when adding or \r
+      extracting files in an archive.\r
+    - Add (correct) detection of empty filename zipping. This can occurs when the removed\r
+      path is the same\r
+      as a zipped dir. The dir is not zipped (['status'] = filtered), only its content.\r
+    - Add better support for windows paths (thanks for help from manus@manusfreedom.com).\r
+\r
+\r
   Version 1.3 :\r
     - Removing the double include check. This is now done by include_once() and require_once()\r
       PHP directives.\r
 3 - Corrected bugs\r
 ==================\r
 \r
+  Corrected in Version 2.0 :\r
+    - Corrected : During an extraction, if a call-back fucntion is used and try to skip\r
+                  a file, all the extraction process is stopped. \r
+\r
   Corrected in Version 1.3 :\r
     - Corrected : Support of static synopsis for method extract() is broken.\r
     - Corrected : invalid size of archive content field (0xFF) should be (0xFFFF).\r