#!/usr/local/bin/perl # Program: make-others # Filename: make-others # Programmer: Ben Y. Yoshino # Description: Shell script to find home pages of other users # Dependencies: Requires PERL # Copyright info: Permission to use, copy, modify and distribute this # software and its documentation for any purpose and # without fee is hereby granted, provided that the # above copyright notice and this permission notice # appear in supporting documentation. This software is # provided "as is" without expressed or implied # warranty. Ben Y. Yoshino will not be held liable for # any damages whatsoever resulting from the use of this # software. # # Copyright 1995, Ben Y. Yoshino. # All rights reserved. $, = ' '; # set output field separator $\ = "\n"; # set output record separator @list = (); # initialize list $tmpfile = "/usr/tmp/others.$$"; $server_base = "http://www2.hawaii.edu"; $server_name = "ITS Web Server 2"; $pubhtdir = "public_html"; @homefiles = ("welcome.html", "Welcome.html"); #$debug = 1; # Debug flag #$limit = 200; # For debug only $ssi = 0; #Server-side includes, not done in here. while (@pwent = getpwent) { $name = $pwent[0]; $gcos = $pwent[6]; $dir = $pwent[7]; $rname = $gcos; @namar = split(" ", $gcos); $cnt = $#namar; if ($cnt > 0) { $rname = $namar[$cnt] . ","; for ($i = 0; $i < $cnt ; $i ++) { $rname = $rname . " " . $namar[$i]; } } $output = ""; if (-x $dir) { $output = $output . sprintf("%s at %s", $rname, $dir); $htdir = $dir . "/" . $pubhtdir; if (! -d $htdir || ! -x $htdir) { next; } opendir(DIRHAND, $htdir); @dirents = readdir DIRHAND; if ($#dirents == 1) { # Empty directory next; } push(@list, $output); if ($debug) { print "Added $output"; } } if ($debug) { if ($limit -- < 0) { last; } } } endpwent; @list = sort @list; open(TMPFILE, ">$tmpfile"); foreach $name (@list) { print TMPFILE "$name"; } close TMPFILE; undef @list; $count = 0; print ''; print ''; print "$server_name Home Pages"; print ''; print ''; print "

List of $server_name home pages

"; print '

Sorted by last name

'; print 'A total of ' . $count . ' pages

'; print '
'; print '

Created on '. &timetodate(time) . ' by a script.
' ; print 'Copyright © 1996 Ben Y. Yoshino
'; print 'All rights reserved.

'; print ''; print ''; sub timetodate { local ($time) = @_; local ($[) = 0; local ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); local ($hrcvt, $ap); local(@Days) = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); local(@Months) = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time); $ap = ($hour / 12) > 1; $hrcvt = ($hour == 12) ? 12 : (($hour == 0) ? 12 : $hour % 12); return sprintf("%s, %s %d %4d %2d:%02d:%02d %s", $Days[$wday], $Months[$mon], $mday, 1900 + $year, $hrcvt, $min, $sec, ($ap) ? "PM" : "AM"); } sub gettitle { local ($homepg) = @_; local ($done, $oneline, $within); local ($/) = "\n"; local ($title) = ''; if ($debug) { print "Getting title for $homepg"; } open(PAGEIN, $homepg); $within = $ssi = 0; while ($oneline = ) { if ($oneline =~ /