#!/usr/local/bin/perl -s ############################################################################## # pfind v1.12 12-14-96 Dale Bewley dale@bewley.net # pfind v1.1 12-20-95 Dale Bewley dbewley@iupui.edu # v.9 ?-8?-95 $VERSION = "Page Find v1.11 beta."; #----------------------------------------------------------------------------- # This script and others found at http://www.bewley.net/perl/ # # Page finder. Finds almost* all the homepages on a site and creates a # catagorized HTML3 table or VRML SCENE. Does not use group info to catagorize, # instead takes info from home dir path. You may have to modify the findPages # routine to find the student and staff dirs on your site, no biggie. If # you need help email me. # # * NOTE: This is actually v1.11b2 27-july-96, but don't tell anyone. * # I just noticed something that makes the size of the html output # MUCH smaller! You really should upgrade if you use 1.11b or earlier. # I haven't touched the VRML part or anything else for that matter, so # the documentation is not COMPLETELY up to date, but very close and there # are no other improvments over 1.11b. # # Changes in this ver (1.11b): # o A little closer to the HTML3 spec. # o $FOOTER variable that points to file to append to output. # o Cleaned up some quick hacks. # Changes in this ver (1.1): # o Added -vrml option to ouput to a .wrl file. # o Added -h2v option to convert old html output to vrml. # # Todo: # o Move some options from variables to command line. # o Add more user options for vrml output customization. # o Actually organize by groups, not by directories. Maybe. # o Increase efficiency. Look for better ways to do these quick hacks. # o Calculate run time. not fun enough # o You tell me. # # Notes: # Well, this one is a little prettier. I haven't touched the VRML stuff, # but I cleaned up main and changed some of the HTML to make it # closer to the HTML3 spec. Notable the tables will behave a little # differently in Netscape (width=90% has been replaced with # units=relative width=90). # # * Almost, because if you are in the same group as the user and the # permissions are 705, it will not see the page. I think this is a # feature not a bug. # # Copyright (C) 1996 Dale Bewley # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ############################################################################## #- User Configurable Variables ----------------------------------------------# $WEBDIR = "www"; # default HTML directory $WEBSERVER = "bewley.net"; # local web server $BASE_HREF = "http://www.bewley.net/ TARGET=_new"; # filesize saver!!! $ULIMIT = -1; # maximum users to read from passwd -1 for all $BACKGROUND = ""; # page background of course $MAX_COLUMNS = 9; # width of table. $FOOTER = "/staff0/dbewley/public_html/pfind.footer"; # *NEW* # file printed at the bottom of page $HEADER = "/staff0/dbewley/public_html/pfind.header"; # *NEW* # file printed at the top of page #- following added for VRML option still under development -# $X=0; $ZGROUP=0; #----------------------------------------------------------------------------# #- Help! --------------------------------------------------------------------# sub HELP { print " See http://www.bewley.net/perl/pfind.html for now.\n"; } #- Main Program -------------------------------------------------------------# (&HELP && exit) if ($h); ($sec, $min, $hour, $mday, $mon, $year) = localtime($^T); $mon++; #the month is one behind if ($h2v){ &introVRML; &H2V; exit; } &findPages; if ($vrml) { &introVRML; &printVRML(\%studentPages, "Student Pages") && ($ZGROUP+=5); &printVRML(\%staffPages, "Staff Pages") && ($ZGROUP+=5); &printVRML(\%researchPages, "Research Pages") && ($ZGROUP+=5); print "}"; # add final brace to VRML output } else { # default HTML output &introHTML; &printHEADER; &printTable(\%studentPages, "Student Pages"); &printTable(\%staffPages, "Staff Pages"); &printTable(\%researchPages, "Research Pages"); &summary; &printFOOTER; } #- Print Introductory Information --------------------------------------------# sub introHTML { print "\n"; print "\n\nAlmost all the Homepages on $WEBSERVER"; # filesize saver!! i'm an idiot for not thinking of this in the last # upgrade print "\n\n\n\n"; print "\n"; print "
\n\t

Almost all the Homepages on $WEBSERVER

\n"; print "\t

Of $uCount entries in passwd, $pCount have "; print "homepages.

\n"; print "\tPage generated by $VERSION\n

\n\n"; printf ("\tBegun @ %02d/%02d/%02d %02d:%02d:%02d\n", $mday, $mon, $year, $hour, $min, $sec); print "

\n
\n"; } #- Print Introductory VRML Information ---------------------------------------# sub introVRML { #this is taken right from a sample file. needs to be changed print "#VRML V1.0 ascii\n"; print "Separator {\n"; print " DirectionalLight {\n"; print "\tdirection 0 0 -1 # Light shining from viewer into scene\n"; print " }\n"; print " PerspectiveCamera {\n"; print "\tposition -8.6 2.1 5.6\n"; print "\torientation -0.1352 -0.9831 -0.1233 1.1417\n"; print "\tfocalDistance 10.84\n"; print " }\n"; } #- Find User Pages -----------------------------------------------------------# sub findPages { setpwent; while ((@list = getpwent) && ($uCount != $ULIMIT)) { $uCount++; ($login, $gid, $home) = @list[0,3,7]; if (-r "$home/$WEBDIR") { $pCount++; # Your site may require changes here. $staffPages{$login} = $home if ($home =~ /staff/); $researchPages{$login} = $home if ($home =~ /research/); $studentPages{$login} = $home if($home =~ /student/); } } endpwent; } #- Print Results in Table Format ---------------------------------------------# sub printTable { # Arguments passed are a ref to a hash of pages and a caption. my($pageList) = shift; # ref to hash my($tableTitle) = shift; local($colCount) = 0; $pageCount = keys %$pageList; print "

\n\n"; print " \n"; print "\t\t\n "; print "\n \n"; foreach $login (sort keys %$pageList) { print "\t\n"; $colCount++; if ($colCount == $MAX_COLUMNS) { print " \n \n"; $colCount = 0; } } print "\n\n\t\t\n\n

$tableTitle

$login
$pageCount $tableTitle"; print "
\n
\n\n"; } #- Print Results in VRML Format ---------------------------------------------# sub printVRML { # Arguments passed are a ref to a hash of pages and a caption. my($pageList) = shift; # ref to hash my($tableTitle) = @_; my($colCount) = 0; my($rowCount)=0; $pageCount = keys %$pageList; print " #----- $tableTitle --------------------------------#\n"; print " Separator {\n"; print "\tTranslation { translation 1 1 $ZGROUP }\n"; print "\tMaterial { diffuseColor 1 0.1 ",$ZGROUP/10," }\n"; print "\tAsciiText { string \"$tableTitle\" }\n"; print " }\n"; foreach $login (sort keys %$pageList) { print " WWWAnchor {\n"; print "\tname \"http://$WEBSERVER/~$login/\"\n"; print "\tSeparator { # The sphere\n"; print "\t\tMaterial { diffuseColor 1 0 ",$ZGROUP/10," }\n"; print "\t\tTranslation { translation $colCount $rowCount $ZGROUP }\n"; print "\t\tSphere { radius .3 }\n"; print "\t}\n }\n"; $colCount++; if ($colCount == $MAX_COLUMNS) { $colCount = 0; $rowCount++; } } } #- Print Summary Information -------------------------------------------------# sub summary { ($fsec, $fmin, $fhour, $mday, $mon, $year) = localtime(time); $mon++; print "

\n"; # compute time to run someday printf ("Finished @ %02d/%02d/%02d %02d:%02d:%02d\n", $mday, $mon, $year, $fhour, $fmin, $fsec); print "

\n\n"; } #- Print Header File --------------------------------------------------------# sub printHEADER { open (HEADER, "<$HEADER") || warn "Can not open $HEADER for input. $!"; while (
) { print; } } #- Print Footer File --------------------------------------------------------# sub printFOOTER { open (FOOTER, "<$FOOTER") || warn "Can not open $FOOTER for input. $!"; while (