View Full Version : [REQ] view zip file contents hack
Joe Pimms
03-02-2005, 09:41 PM
what i need is a viewer that will show all the contents in a .zip file,
so when a user clicks to see whats in the file ( .zip file ) it will list all the contents of it...
look at the pictures
here is a little info HERE (http://ca3.php.net/manual/en/function.zip-read.php) or you can look at this script HERE (http://phpatm.free.fr/downloads.php?lang=en) this script let people view a zip file contents as a pop-up window.. This script is called PHPATM = PHP Advanced Transfer Manager witch is a download manager it would also be awsome if some one would intergrade this script into vbulletin ( 3.0.7 ) this hack would be displayed in the " postbit_attachment " template
and useing a collapse image.. so please help me on this as i do think this would be a great hack for those people that have sites with attachments on there sites
the pic's posted here were made as an example of what i would like to have
WhSox21
03-03-2005, 05:04 AM
I might still have some code laying around here from MyImgs.com when I programed that feature for that site. Do you have the ziplib installed on your server? An alternative way to do what you want would be to unzip the file into a directory and read the files in that directory. I'll do my best to help but I'm pretty busy now with the HelpDesk and just life in general. Hopefully I'll get to this eventually.
Joe Pimms
03-03-2005, 08:19 PM
hey host dose have ziplib and many others so it will work cause i used phpatm on my server to see if the zip viewer work and it did nicely
Joe Pimms
03-05-2005, 03:33 PM
so can any one please help on this hack ?
Joe Pimms
03-07-2005, 10:39 PM
can any one please please help me
why-not
03-08-2005, 12:27 AM
can any one please please help me
<?
// the location of the zip file and its name
/* windows use full path, ie: c:/www/docs/www/docs/test.zip */
$path_file = './http_docs/files/test.zip';
// type to return ( 0 = files array(), 1 = path and files array )
$type = 0;
// usage
$zip = zip_reader ( $path_file, $type );
// dump the results
print_r ( $zip );
function zip_reader ( $file )
{
$ds = array ();
$io = zip_open ( $file );
if ( $io )
{
while ( $handle = zip_read ( $io ) )
{
$ft = is_zip_dir ( zip_entry_name ( $handle ) );
if ( $ft[0] )
{
if ( $type )
{
$ds[$ft[1]][] = array ( $ft[2], real_size ( zip_entry_filesize ( $handle ) ), real_size ( zip_entry_compressedsize( $handle ) ) );
}
else
{
$ds[] = array ( $ft[2], real_size ( zip_entry_filesize ( $handle ) ), real_size ( zip_entry_compressedsize( $handle ) ) );
}
}
}
zip_close ( $io );
}
return ( $ds );
}
function is_zip_dir ( $in )
{
$out = array ();
$in = trim ( substr ( $in, strpos ( $in, chr ( 47 ) ) ) );
$test = substr ( $in, strrpos ( $in, chr ( 47 ) ) + 1 );
if ( ! empty ( $test ) )
{
$out[] = true;
$out[] = substr ( $in, 0, strrpos ( $in, chr ( 47 ) ) + 1 );
$out[] = $test;
}
else
{
$out[] = false;
$out[] = $in;
$out[] = '';
}
return ( $out );
}
function real_size ( $t )
{
$out = 0;
$math = pow ( 10, 2 );
if ( $t < 1024 )
{
$out = $t . ' bytes';
}
else if ( $t < 1048576 )
{
$out = ( floor( ( $t / 1024 ) * $math ) / $math ) . ' KB';
}
else if ( $t < 1073741824 )
{
$out = ( floor( ( $t / 1048576 ) * $math ) / $math ) . ' MB';
}
return ( $out );
}
?>
C, ya...
Sonia
Joe Pimms
03-08-2005, 02:30 AM
thanks for this but how do i use it there is no template edit like the pic i poted so how would this work ?i need it to be able to list a attachment id to open u have it saying to open test.zip
Arial
03-08-2005, 08:57 AM
Sonia? Please check your PM
Thank you.
Joe Pimms
03-11-2005, 05:17 AM
hey can you explain how this is to work for me please where i need it to be able to look more like or work more like the image i had made to show this hack ?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.