#!/usr/local/bin/perl
# Displays pretty HTML for all the people on a local machine that have homepages
# It tries to parse out the title of homepages, too.
#
# Kees Cook 1997
$|=1;
undef $/;
setpwent;
$num = 0;
while ( (($login,undef,undef,undef,undef,undef,$gecos,$home) = getpwent) ) {
if ($gecos =~ /^(.*)\(.*\)/) {
$gecos = $1;
}
($gecos) = split(',',$gecos);
# print "$login $gecos $home\n";
$file = "$home/public_html/index.html";
if ( -e "$home/public_html/index.cgi" ||
-e "$file") {
if (-e "$file") {
open(FILE,$file);
$text = ;
close(FILE);
if ($text =~ /(.*)<\/title>/i) {
$title = $1;
}
else {
$title="";
}
}
push(@titles,$title);
push(@logins,$login);
push(@homes,$home);
@names = split(' ',$gecos);
if (!@names) {
$name = $gecos;
}
else {
$name = pop @names if (@names);
$name .= " " . join(' ',@names);
}
# print "\t$gecos '$name'\n";
$tosort{$name} = $num;
push(@gecoss,$gecos);
$num++;
}
}
endpwent;
print "Content-type: text/html
User Homepages
User Homepages
\n";