#!/usr/bin/perl # $ # $ (Cougaindex version 2.6) # $ # $ Simple script with no administration which is used as a default indexer, allows you # $ to customize the layout of directories say for downloading purposes... because the # $ files are generated on the fly it will only display the contents of what is in the # $ specific directory. # $ # $ This code is distributed in the hope that is will be useful but WITHOUT ANY # $ WARRANTY. ALL WARRANTIES, EXPRESSED OR IMPLIED ARE HEREBY DISCLAMED. This includes # $ but isn't limited to warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR # $ PURPOSE. The RESELLING of this code is STRICTLY PROHIBITED. # $ # $ $Revision: 2.6 # $ $Author: Paul Williams # $ $Email: paul@rainbow.nwnet.co.uk # $ $URL: http://www.cougasoft.org/ # $ $Created: 05/12/1996 11:01 # $ $Last Modified: 01/04/2000 18:12 # $ # $ Copyright 1996, 1997, 1998, 1999, 2000 Cougasoft. All rights reserved. # $ # $ The http location of the graphics, so the below variable when viewed on # $ your website will look like: http://www.yourdomain.com/cougaindex/icons $imgloc = 'http://www.ulrich-wenger.ch/_icons/'; $imgloc .= "/" if ($imgloc !~ /\/$/); # $ Set the colours for the script to output here, I'm assuming you have either # $ a working or rough knowledge of perl so editing them by hand shouldn't be # $ a problem. If you get errors and have edited it, double check the variables. $BODYTEXT = '#000000'; $BGCOLOR = '#C0C0C0'; $LINK = '#004080'; $VLINK = '#0000A0'; $ALINK = '#0000A0'; $TBCOLOR = '#BABABA'; # $ Colour of the table. $BACKGROUNDGIF = ''; $ENV{'SCRIPT_NAME'} =~ /(.*)\/index[\w\W]+.[\w\W]+$/; # # $-------------------------------------------------------------------------------------------- # # M A I N P R O G R A M # # $-------------------------------------------------------------------------------------------- # print "Content-type: text/html\n\n" . # $ Please don't change this, people also seem to like to alter this which is # $ also a little dis-heartening, especially as its hidden inside the html output. "\n" . "\n" . "\n" . " Cougaindex - $1\n"; print "\n"; print "\n" . "\n" . "\n" . "\n" . "\n" . "\n"; print "\n"; print "\n" . "\n" . "\n" . "\n" . "\n"; print "\n"; opendir(DIR, "."); @dir = sort(readdir(DIR)); foreach (@dir) { next if (/^[\.]/); next if (/index[\w\W]+.[\.cgi\.pl]+$/i); if (-d) { push(@directory, $_); } elsif (/readme/i) { $read = $_; } else { push(@file, $_); } } closedir(DIR); foreach (@directory) { print "\n" . "\n" . "\n" . "\n" . "\n"; print "\n"; } foreach (@file) { if (/\.txt\b|\.html\b|\.htm\b|\.shtml\b|\.doc\b|\.rtf\b|\.dot\b|\.wri\b/i) { $img = "html.gif"; $type= "Document"; } elsif (/\.gif\b|\.jpg\b|\.bmp\b|\.jpeg\b|\.jpe\b|\.jfif\b|\.pjprg\b|\.pjp\b|\.psd\b|\.xbm\b|\.ief\b|\.png\b|\.pcd\b|\.rgb\b|\.ppm\b|\.pgm\b|\.pbm\b|\.pnm\b|\.xwd\b|\.xpm\b|\.xbm\b|\.ras\b|\.tiff\b|\.tif\b/i) { $img = "image.gif"; $type= "Image"; } elsif (/\.pl\b|\.cgi\b|\.c\b|\.sh\b/i) { $img = "script.gif"; $type= "Script"; } elsif (/\.exe\b|\.com\b|\.bat\b|\.bin\b/i) { $img = "exe.gif"; $type= "Executable"; } elsif (/\.zip\b|\.tar\b|\.gz\b|\.z\b|\.lzh\b|\.arj\b|\.arc\b|\.taz\b|\.shar\b|\.gtar\b|\.hqx\b/i) { $img = "compress.gif"; $type= "Compressed"; } elsif (/\.wav\b|\.midi\b|\.mid\b|\.au\b|\.snd\b|\.aif\b|\.aiff\b|\.aifc\b|\.rmi\b|\.ra\b|\.ram\b|\.mp2\b|\.mpa\b|\.abs\n|\.mpega\b/i) { $img = "audio.gif"; $type= "Sound"; } elsif (/\.mov\b|\.qt\b|\.moov\b|\.mpv2\b|\.mp2v\b|\.mpeg\b|\.mpg\b|\.mpe\b|\.mpv\b|\.vbs\b|\.mpegv\b/i) { $img = "move.gif"; $type= "Video"; } else { $img = "anon.gif"; $type = "?"; } $SIZE = (-s); printf("\n" . "\n" . "\n" . "\n" . "\n", $imgloc, $img, $_, $_, int($SIZE / 1024), $type); printf("\n"); } print "
FilenameSize 
..-Higher Dir
$_-Dir
%s %d kb%s
\n"; if ($read) { open (README, "$read"); print "
";
                    while ()
                     {
                        print ;
                     }
                  print "
"; close (README); } print "\n"; print "\n"; # # $-------------------------------------------------------------------------------------------- # =========================================================================================== # $-------------------------------------------------------------------------------------------- #