 |
AutoIndex PHP Script A Website Directory Indexer
|
| View previous topic :: View next topic |
| Author |
Message |
Gingah New Member

Joined: 02 Jun 2009 Posts: 2
|
Posted: Tue Jun 02, 2009 3:58 pm Post subject: Tar, Gzip and Zip functionality |
|
|
Hello,
First, I would like to express my admiration for AutoIndex; it makes PHP-based file browsing very easy, and is very useful in my webdevelopment. Secondly, I had problems getting the default Tar-compression working, and I really prefer Zip-archives, so I added functionality for them. I did this using the TAR/GZIP/BZIP2/ZIP Archives-class from phpclasses.org, and changing three files in my AutoIndex installation. I am dependant upon having the option to download entire directories with AutoIndex, and so I had to fix the Tar-bug I was experiencing somehow, and this was the result. To use this you MUST have PHP 5.2.0 or later installed, as zlib and bz2 was introduced there.
If anyone else would like to do the same, here are the installation instructions:
- Install AutoIndex 2.x (must be the PHP5 version, meaning PHP 5.2.x or later)
- Open index.php
- Find line 527, which contains $mime = new MimeType('.tar'); (It's line 527 in AutoIndex 2.2.4)
- Find line 533, which contains $tar = new Tar($list, $outfile, strlen($dir)); (It's line 533 in AutoIndex 2.2.4)
- Remove all code between line 527 and 533, meaning remove this:
| Code: | $mime = new MimeType('.tar');
header('Content-Type: ' . $mime -> __toString());
header('Content-Disposition: attachment; filename="'
. $outfile . '.tar"');
@set_time_limit(0);
$list = new DirectoryList($dir);
$tar = new Tar($list, $outfile, strlen($dir)); |
Where the code was, place the following code:
| Code: | // TAR/GZIP/BZIP2/ZIP
include('classes/archive.php');
$compress = $_GET['compress'];
if ($compress == 'tar') {
$compress_output = new tar_file("$dir");
} elseif ($compress == 'gzip') {
$compress_output = new gzip_file("$dir");
} elseif ($compress == 'bzip2') {
$compress_output = new bzip_file("$dir");
} elseif ($compress == 'zip') {
$compress_output = new zip_file("$dir");
}
$compress_output->set_options(array('inmemory' => 1, 'overwrite' => 1, 'recurse' => 1, 'storepaths' => 1));
$compress_output->add_files("$dir");
$compress_output->create_archive();
$compress_output->download_file(); |
Save and close index.php
Open templates/default/table_footer.tpl
Find line 43, which contains <a class="autoindex_a" href="{info:archive_link}">{words:download directory as tar.gz archive}</a> (It's line 43 in AutoIndex 2.2.4)
Remove the line
Where the code was, place the following code:
| Code: | <b>Download directory as</b>
<a class="autoindex_a" href="{info:archive_link_tar}">Tar</a>,
<a class="autoindex_a" href="{info:archive_link_gzip}">Gzip</a>,
<a class="autoindex_a" href="{info:archive_link_zip}">Zip</a> |
Save and close table_footer.tpl
Open classes/TemplateInfo.php
Find line 83, which contains case 'archive_link': (It's line 83 in AutoIndex 2.2.4)
Find line 88, which contains } (It's line 88 in AutoIndex 2.2.4)
Remove all code between line 83 and 88, meaning remove this:
| Code: | case 'archive_link':
{
global $config;
return Url::html_output($_SERVER['PHP_SELF']) . '?archive=true&dir='
. substr($this -> dir_list -> __get('dir_name'), strlen($config -> __get('base_dir')));
} |
Where the code was, place the following code:
| Code: | case 'archive_link_tar':
// Compress as Tar
{
global $config;
$url = Url::html_output($_SERVER['PHP_SELF']) . '?archive=true&compress=tar&dir='
. substr($this -> dir_list -> __get('dir_name'), strlen($config -> __get('base_dir')));
return $url;
}
case 'archive_link_gzip':
// Compress as Gzip
{
global $config;
$url = Url::html_output($_SERVER['PHP_SELF']) . '?archive=true&compress=gzip&dir='
. substr($this -> dir_list -> __get('dir_name'), strlen($config -> __get('base_dir')));
return $url;
}
case 'archive_link_bzip2':
// Compress as Bzip2
{
global $config;
$url = Url::html_output($_SERVER['PHP_SELF']) . '?archive=true&compress=bzip2&dir='
. substr($this -> dir_list -> __get('dir_name'), strlen($config -> __get('base_dir')));
return $url;
}
case 'archive_link_zip':
// Compress as Zip
{
global $config;
$url = Url::html_output($_SERVER['PHP_SELF']) . '?archive=true&compress=zip&dir='
. substr($this -> dir_list -> __get('dir_name'), strlen($config -> __get('base_dir')));
return $url;
} |
Save and close TemplateInfo.php
Download the TAR/GZIP/BZIP2/ZIP Archives-class
Or, if you do not wish to register at phpclasses.org, download the TAR/GZIP/BZIP2/ZIP Archives-class from this site
Open the archive you downloaded
Copy the file named archive.php
Paste the file into the classes folder in your AutoIndex installation
Information: The class has an open license, provided you do not remove the developers copyright-comment at the top.
The links for downloading a directory as Tar, Gzip or Zip appears where the original link was; directly below the file/folder tables. _________________
 |
|
| Back to top |
|
 |
mvveelen New Member

Joined: 26 Aug 2009 Posts: 3
|
Posted: Wed Aug 26, 2009 12:53 pm Post subject: |
|
|
Wow !! Looks nice, but it doesn't work (for me).
I have PHP 5.2.10 and did everything you told to do (twice....) but : doesn't work.
If I try it, it only gets me a filename like : "index" with no extension, and for all 3 options. It does pack all files, but the filename is just : index
What could be wrong ? |
|
| Back to top |
|
 |
zlatan24 New Member

Joined: 13 Sep 2009 Posts: 3
|
Posted: Mon Dec 07, 2009 7:49 am Post subject: |
|
|
| Today I downloaded a film in zip file and wanted to watch it,but I couldn't because it was damaged.A friend advised me next tool-corrupted program recovery zip.To my surprise utility helped me very easy and free of cost.Besides software showed how it can encounter problems with this application and corrupted files with *.zip extension. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|