#! /usr/local/bin/perl
# Time-stamp: "2005-08-19 01:57:08 ADT"  sburke@cpan.org
#
# desc{   build an index of all accounts with web pages on this host     }
#
#  sburke@cpan.org (c) 1995 Sean Michael Burke
# Released under the GNU Public License, blah blah blah

# Tue Jun 13 22:21:10 PDT 1995
#  first written
# Wed Nov  1 05:22:06 CST 1995
#  altered to send to stdout

# Recommended usage:
#    walker.pl > foo.html
# or walker.pl | mail sburke@cpan.org
#

$host= "www.ling.nwu.edu";
#  Set this to be the WWW alias name of your web server

print  ("<html><head><!--  autogenerated, no point in editing -->\n");
print  ("<title>Index of pages on $host</title>\n");
print  ("</head><body><h1>Index of pages at $host</h1>\n");

setpwent;			# we're gonna start scanning the user log!
while (@list = getpwent) {	# get the next entry
    ($acct,$personalname,$home) = @list[0,6,7];
    # the account name, personal name, and the home dir

    if (-e ($home . "/public_html" ) )  {
	#better get ready to use their personal name-- isolate and HTMLify it
	$personalname =~ s/,.*// ;
	$personalname =~ s/\&/&amp;/ ;
	$personalname =~ s/\</&lt;/ ;
	$personalname =~ s/\</&gt;/ ;

	$personalname =~ s/(^$)|(^ticket \d+$)/(none)/ ;
				 # if their name is blank, or is
				 #"ticket [number], say 'none'
	
	print  ("<BR>$personalname: <CODE>");
	print  ("<A HREF=\"http://$host/~$acct/\">");
	print  ("http://$host/~$acct/</A>");
	print  ("</CODE>\n");
    }
}
endpwent;			# all done

print ("<HR>Autogenerated on " . `date '+%D' `);
print ("</BODY></HTML>\n");

1;  #we done.  byebye.


