Simple little "descript.ion" savvy directory indexer.

Since I get dozens of hits on various directories which I have tucked away, (Such as my toys directory, I’ve opted to open it up cleanly, rather than force-redirect people to my software page. There’s nothing wrong with being a /little/ snoopy, after all. ;)

Whilst playing around with my lister, I recalled the silly functionality of 4DOS’s “descript.ion” files.

These files have a rather plain format, which is:
”[filename] description”, such as: descript.ion This file, silly!

I decided I’d make my little indexer support that – rather than just spew out filenames.

Here’s some fairly trivial PHP; feel free to modify to your needs. Note that it is fairly incomplete, and I do have some things hard coded. I started breaking it apart for display here, but realize this is more of a task for anyone else to modify for their needs. You’ll probably want to remove my inlaid spanning. header.inc and footer.inc are merely for show, you can use them for html wrapping purposes.

’; ////////////////////////////////// // // VARIABLES // ////////////////////////////////// // How far away (in hours) is the server from our locale? $localTimeOffset = ”-15”; // What’s the name of our locale? $localTimeZone = “PST”; // Initialize our variables // No, we don’t know what this file is. $fileDescription = “”; // Do we have a “descript.ion” formatted file? not by default. $haveDescFile = 0; function number_friendly_conversion ($my_number , $round = 1) { if ($my_number < 1024 ) { return ”$my_number”.’b’; } else if ($my_number < 1048576 ) { $return_value = round ($my_number /1024 , $round ); $return_value = ”$return_value”.’k’; } else if ($my_number < 1073741824 ) { $return_value = round ($my_number /1048576 , $round ); $return_value = ”$return_value”.’M’; } else { $return_value = round ($my_number /1073741824 , $round ); $return_value = ”$return_value”.’G’; } return $return_value; } if (file_exists(“header.inc”)) { include(“header.inc”); } else { echo “DescrIndexer”; } echo “Automagically generated index for: “” . dirname($_SERVER[‘PHP_SELF’]) . “”
Begrudgingly created on ” . date(“d.m.Y \\a\\t H:i ”, (date(“U”) + ($localTimeOffset * 3600))) . ”$localTimeZone”; ?>

0 == $filename) { // Let us assume that no one is using tabs; one line only, after all! // The below is similar to perl’s chop() – kill the newlines! $fileDescription = substr($myfile1, 0, -1); // We’ve got our man – stop processing break; } else { // Bummer – we don’t know what this is. $fileDescription = “”; } } } // Only print files, not directories, and no dotfiles, .inc , or gpg .sig files, for security, and brevity. if (is_file($filename) and eregi(“[a-zA-Z0-9_]+”, $filename) and !(eregi(“.\.inc$”, $filename)) and !(eregi(”^.\.sig$”, $filename)) and ($filename != “descript.ion”)) { $localFileSize = number_friendly_conversion(filesize($filename)); print ” $filename $localFileSize [” . date(“d.m.y\/H:i”, (filemtime($filename) + ($localTimeOffset * 3600))) . ”]$fileDescription
\n”; } } if (file_exists(“footer.inc”)) { include(“footer.inc”); } else { echo “”; } ?>

As above, I’m using tabs to denote the break between filename and description; descript.ion files use any whitespace, if memory serves. Of course, feel free to change for your needs. A modified version of the above works quite well for my needs. It’s a one-pass, hence the lack of subroutines and functionality – I might be expanding it for a special ‘File’ database section of Rollator, but that’d be silly to use descript.ion files when you’ve got a full MySQL backend! ;)