tags:

views:

578

answers:

4

Note: I NEED A LIBRARY not links to documentation about extensions my host doesn't have or want installed.

The subject says it all.

I don't need to extract any files for the moment (although that might be a nice addition to my web app later) I just need to list the contents of rar and zip archives.

+4  A: 

http://us2.php.net/manual/en/ref.zip.php for zip-files.

http://us2.php.net/manual/en/rararchive.getentries.php for rar-files.

Björn
Thanks. However:Call to undefined function zip_open() Call to undefined function rar_open() I need a library because my host doesn't have these extensions installed.
kitsched
+1  A: 

PHP Compression Functions

everything you need (installation, usage examples) is included in that page.

listing rar files is as easy as

<?php

 $rar_file = rar_open('example.rar') or die("Can't open Rar archive");

 $entries = rar_list($rar_file);

 foreach ($entries as $entry) {
     echo 'Filename: ' . $entry->getName() . "\n";
     echo 'Packed size: ' . $entry->getPackedSize() . "\n";
     echo 'Unpacked size: ' . $entry->getUnpackedSize() . "\n";

     $entry->extract('/dir/extract/to/');
 }

 rar_close($rar_file);

 ?>
klez
Call to undefined function rar_open() That's why I need a library.
kitsched
+2  A: 

I honestly don't think you'll find one. What you're asking for is a library that includes the rar extension (giving php access and usability to the filesystem and compressed files: rar) itself if I'm understanding correctly. I really don't think anyone would go through the trouble of rebuilding/porting/moving/extracting/etc the rar extension when it's easier to install it. If I were you I'd contact the host to see if they'll install it and/or migrate to a new host.

Jesse O'Brien
Thanks, I'll try convincing them. If it doesn't work I'll grab my stuff and move elsewhere.
kitsched
Aye, I genuinely feel bad for you, I don't see how hosting companies these days can provide such bad support to paying users. I've had many friends complain about various extensions for things not being installed and hosts won't install them for no good reason at all, or will just ignore requests.
Jesse O'Brien
A: 

phpinfo(); you webhost

if you see this Rar support the you can use PECL's rar functions.

This class can make things simple

Or else I don't know if this is possible

atif089