Jump to content

Search For A File In A Zip


Zero3X

Recommended Posts

Basically I need to search through a zip file for one file. I've tried quite a few things but the zip functions are now really starting to annoy me.

 

My most recent attempt was this:

 

$zip = zip_open(myzip.zip);

while ($zip_file = zip_read($zip) != "file.php") {

}
zip_entry_open($zip, $zip_file);
  
  
	  $contents = zip_entry_read($zip_file);

 

But of course that just timed out on me.

 

Anyone got any ideas?

Link to comment
Share on other sites

That was a typo  ;D

 

When copy/pasting the actual code you are expecting help with, how can there be typo's?

 

It was a variable ($thezipfile = "myzip.zip") but it's seperated from the zip check section of the script by unrelated code. So I took the liberty of changing the variable to a string (and forgetting to use '"').

Link to comment
Share on other sites

Well, I've managed to get this all working. However, when I echo out the contents of the file it only shows the second line.

 

The complete file

<div>
Hello - I only get this outputted.
<?php
function doesnoexist();
?>
</div>

 

Does zip_entry_read not process characters like "<, >, ?" ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.