Mortgage | Advertising | Loans | Credit Card | Shares
Need suggestions on a file system [Archive] - ZGeek

PDA

View Full Version : Need suggestions on a file system


Pirate
29-11-2005, 09:03 AM
I've got a problem to figure out and I need to find out the best way of doing it. At my work we generate a bunch of daily reports in excel. They are fairly hefty around 3 to 5 megs each and they are a complete bitch to send to the people who need them as they end up crashing peoples computers, slowing the network etc.

So what I am planning to do is have the person who makes the reports, ftp them to a directory in as a webpage generated by excel (html files, and images). Now, what I need to figure out is how to index these so people can visit a page, click a link and see the latest reports. What I want to do is have this index page automatically update itself so I don't have to do it during the day because I'll be doing it every 2 hours. Anyone got any suggestions?

jambo
29-11-2005, 09:26 AM
Would a simple directory listing script do it?

Pirate
29-11-2005, 09:40 AM
probably, is that like in the old days where you could open up a directory like http://www.domain.com/image/ and there would be a list? I don't know how to impliment that on my server :P

Its an apache server, anyone point me in the direction to do this?

jambo
29-11-2005, 09:51 AM
Sure, take a look here: http://httpd.apache.org/docs/1.3/mod/mod_autoindex.html

You can snazz the listing up with FancyIndexing, sort files by date created and hide images and sub-folders.

Spingo
29-11-2005, 09:55 AM
Easy peasy not so squeezy japanesey!

.htaccess file in the directory containing all of the excel files.

Insert line:
Options +Indexes

Pirate
29-11-2005, 10:05 AM
I love you guys, i really do. :)

ewe2
30-11-2005, 04:43 AM
Apache indexing is the shit. It's got to the point where ftp sites just gave up and put .htaccess files in.

stinky
30-11-2005, 10:59 AM
If you want to customise the index it's pretty easy to print a directory listing using php. The following should do it. I haven't actually run this so there may be errors in it.

Note I have put in a list of allowed filetypes and put the directory parsing into a function so you can call it multiple times to navigate directories fairly easily.

<?php

$root_dir = "/usr/local/apache/htdocs/reports/";

function read_dir($dir) {
$allow_filetypes = array("xls","doc","txt");
$contents = array();
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$ext = substr(($t=strrchr("file.ext",'.'))!==false?$t:'',1);
if in_array($ext,$allowed_filetypes) {
array_push($contents, $file)
}
}
}
closedir($handle);
return $contents;
}

$index = array();
$index = read_dir($root_dir);
print "<table>";
foreach ( $index as $file ) {
print "<tr><td><a href='$root_dir/$file'>$file</a>\n";
}

?>