I`ve got a big Problem with the "zip_entry_read" function, and I don`t unterstand what I did wrong.
I tried to write a function, wicht reads all zip Entries of a file into an Array. It worked, I can read alle Methadata from this array.
But when i try to read the content, I always get nothing.
This is an example whre you can see whats the problem:
when I read 10 Bytes content IN the funktion, it works, but when I try the same with the returnvalue (or with the refference of the entries), it won`t work.
With the result of the function, I can also read all the methadata (filename, size ...) but only the Content, seems to be emty after the function.
<?php
require("zip_funct.inc.php");
function test(&$zip_entry = null)
{
$zip = zip_open("test.zip");
while( $tmp[] = zip_read($zip) );
array_pop($tmp);
$zip_entry = $tmp;
$n = 2;
var_dump($zip_entry);
$buf = zip_entry_read($zip_entry[$n], 10);
echo "CONTENT:\n------------------\n".$buf."\n";
echo "------------------\n";
echo "Name: " . zip_entry_name($zip_entry[$n]) . "\n";
echo "Actual Filesize: " . zip_entry_filesize($zip_entry[$n]) . "\n";
echo "Compressed Size: " . zip_entry_compressedsize($zip_entry[$n]) . "\n";
echo "Compression Method: " . zip_entry_compressionmethod($zip_entry[$n]) . "\n";
return $zip_entry;
}
$zip_entry = test(); $n = 2;
var_dump($zip_entry);
$buf = zip_entry_read($zip_entry[$n], 10);
echo "CONTENT:\n------------------\n".$buf."\n";
echo "------------------\n";
echo "Name: " . zip_entry_name($zip_entry[$n]) . "\n";
echo "Actual Filesize: " . zip_entry_filesize($zip_entry[$n]) . "\n";
echo "Compressed Size: " . zip_entry_compressedsize($zip_entry[$n]) . "\n";
echo "Compression Method: " . zip_entry_compressionmethod($zip_entry[$n]) . "\n";
?>
The screenoutput looks like this:
array(8) {
[0]=>
resource(61) of type (Zip Entry)
[1]=>
resource(62) of type (Zip Entry)
// and a lot other entries
}
CONTENT:
------------------
<html>
<h
------------------
Name: tmp.html
Actual Filesize: 1136
Compressed Size: 360
Compression Method: deflated
array(8) {
[0]=>
resource(61) of type (Zip Entry)
[1]=>
resource(62) of type (Zip Entry)
// and a lot other entries
}
CONTENT:
------------------
------------------
Name: tmp.html
Actual Filesize: 1136
Compressed Size: 360
Compression Method: deflated
And this output shows, that the returnvalue of the function still as a valid ressource and still returns the correct methadata, but the content is empty.
I try to solve this problem since weeks and I realy need help. If anybody has an idea whats the Problem, please notice hear.