There’s always something to howl about.

A Saturday night toy: Your file server as a linked hierarchy

I owe more “Speaking in tongues” stuff, but I think I may have bored everyone to tears. This, by pointed contrast, is purely for fun.

Copy this code:

<?PHP
$thepath = $_SERVER['SERVER_NAME'];
$dir = '*';
if ($Bfolder) $dir = "$Bfolder/*";

foreach (glob($dir, GLOB_ONLYDIR) as $filename)
   {
   if (!$Bfolder) echo ("<BR>");
   ?>
   <a href="<?PHP echo($filename); 
   ?>" target="_blank">
   <?PHP echo($filename); ?></a><BR>
   <?PHP
   $URL = urlencode($filename);
   include ("http://$thepath/windex.php?Bfolder=$URL");
   }
?>

and paste it into a text file.

Save the file with the name “windex.php”.

FTP it into the top level of your file server.

Then go here:

http://MyServer.com/windex.php

substituting the name of your server for “MyServer”, of course.

What are you seeing? The entire directory tree of your file server expressed as links. Each sub-hierarchy of folders is visually separated by a space, just to make things pretty. Each one of those links will work, opening into a web page if the folder contains an HTML “index” file, or to a Unix like directory representation if not.

Just a toy, just for fun. I’d explain it to you, but then you’d have to kill me.

Technorati Tags: , , ,