#!/usr/bin/perl -s
#
# mkpeople - rebuild the Web People Directory for IU Computer Science
# Steve Kinzler, kinzler@cs.indiana.edu, Sep 94/Jul 95/Nov 95/May 97
#
# comments added for sanity -- schisham 19971007
# converted to new web structure -- robh Oct 2001
# added exceptgroups to limit the display (and web harvesting of email addrs) - robh May 2004
#
# $Id: mkpeople,v 1.25 2007/05/03 16:23:18 root Exp root $
umask 002;
# head/tail files
$headfile="/l/www/People/headonly.html";
$tailfile="/l/www/People/tailonly.html";
# base url
$base="/People/auto/";
# location of mkpeople
$cwd = '/l/www/People/auto';
# root of WWW tree
$root = '../..';
# usernames to exclude
$except = '/usr/local/lib/userlist/nonusers';
@except = ('^[A-Z]');
# groups to exclude
@exceptgroups = ( 'other',
'classes',
'csother',
'cssystem',
'guests',
'projects',
'students',
'xfaculty',
'alumni',
'xstaff');
# file that, if existing in the homedir of a user, excludes them from the listing
$excludefile = ".web.exclude";
# machines serving as password hosts
@pwhost = ('moose', 'whale', 'silo');
# where to find the password file on the passwd hosts
%pwfile = ('whale', '/nfs/whale/etc/passwd',
'moose', '/nfs/moose/etc/passwd',
'silo', '/nfs/silo/etc/passwd');
$maxname = 50;
# lower UID limit
$minuid = 100;
$primary = 'PRIMARY';
# default group if none match
$dfltgrp = 'other';
# shells for skipped accounts
@deactiv = ('deactivated');
$foto = "$root/foto";
# hyplan link for personal WWW pages
$hyplan = "$root/hyplan"; # via filesystem
$hyplanroot = "/hyplan"; # via web
# resume forwarding filename
$resufwd = 'resume.forward';
# filenames for actual resume
@resume = ('resume.html', 'resume.txt');
# Address and fax override filenames. If these exist in the
# users moose home directory, use them instead of the defaults
# for the mailing address and fax number.
$addressfile=".web.address";
$faxfile=".web.fax";
$emailfile=".web.email";
# no longer used
#$facls = "$root/dept/faclist";
# part of page title
$title = 'IU Computer Science';
$bgcolor = '#FFFFFF';
$montage = 'bin/usermontage';
$maxcols = 10;
$swapgif = 1; # do we need to byte-order swap for correct GIF sizes?
$montpad = 0; # does $montage pad out to $maxcols columns?
$type2c = 's';
$domain = 'cs.indiana.edu';
$areacod = '812';
$prefix = '85';
$deptadd = 'Lindley Hall 215; Bloomington, IN 47405 USA';
@deptadd = ('admin', 'faculty', 'research', 'staff');
$deptfax = "$areacod-${prefix}5-4829";
@deptfax = ('admin', 'faculty', 'research', 'staff');
# student groups and file locations
%subgrp = ('grads', 'students /usr/local/lib/userlist/phdgrads /usr/local/lib/userlist/msgrads',
'majors', 'students /usr/local/lib/userlist/csmajors');
%supgrp = ('supstaff', 'research staff admin wkstudy');
# Group order ?
@gorder = ('faculty', 'supstaff',
'grads', 'majors', 'students', 'alumni', 'other');
# Group long names in assoc array
%gname = ('admin', 'Admin Staff', 'alumni', 'Alumni',
'faculty', 'Faculty', 'grads', 'Graduate Student',
'other', 'Guest', 'research', 'Research Staff',
'staff', 'Systems Staff', 'students', 'Other Student',
'supstaff', 'Staff', 'majors', 'Undergraduate Major',
'wkstudy', 'Work-study');
# Group long names plural
%gname2 = ('admin', 'Admin Staff', 'alumni', 'Alumni',
'faculty', 'Faculty', 'grads', 'Graduate Students',
'other', 'Guests', 'research', 'Research Staff',
'staff', 'Systems Staff', 'students', 'Other Students',
'supstaff', 'Staff', 'majors', 'Undergraduate Majors',
'wkstudy', 'Work-studies');
chdir $cwd || die "$0: cannot chdir $cwd ($!)\n";
## Collect User Data ##########################################################
while (@grent = getgrent) {
$primary{$grent[2] + 0} = $grent[0]
if $grent[3] =~ /(^|[ ,])$primary([ ,]|$)/;
}
endgrent;
# build exceptions array
open(EXCEPT, $except) || die "$0: cannot open $cwd/$except ($!)\n";
while (
[ Main Index
| Icon Listing
]
[ Main Index
| Text Listing
] The information in this directory is garnered nightly from accounts
on the CS systems. Persons listed
in this directory can change their full name, office, and office and
home phone using the
account management system.
You can also create
a personal web page (a hyplan) and résumé
(resume), and create and submit
a departmental photo. The icons in this directory are from the
Picons Archive, and may be rendered
poorly by some browsers due to dithering.
EOF
push(@menu, "Text Listings
\n[ ");
foreach $group (@groups) {
$gname2 = $gname2{$group} || $group;
push(@menu, ($n++) ? '| ' : '',
"$gname2\n");
}
$n = 0;
push(@menu, "]
\n");
push(@menu, " \n\n");
push(@menu, "Icon Listings
\n[ ");
foreach $group (@groups) {
$gname2 = $gname2{$group} || $group;
push(@menu, ($n++) ? '| ' : '',
"$gname2\n");
}
push(@menu, "]\n");
push(@menu, "Main Index
\n",
@intro, @search, @menu, @tail;
printtail(INDEX);
close INDEX;
exit if $exitindex;
## Write Text Listings ########################################################
@tmp = @groups;
$prevgroup = '';
while ($group = shift @tmp) {
$nextgroup = $tmp[0];
$gname2 = $gname2{$group} || $group;
open(GROUP, "> ${group}T.html") ||
die "$0: cannot open $cwd/${group}T.html ($!)\n";
print GROUP @dontedit;
printhead(GROUP);
print GROUP @title, "Text Listing - $gname2
\n", @intro;
$prevhtml = ($prevgroup)
? "Previous Text Listing"
: 'Previous Text Listing';
$nexthtml = ($nextgroup)
? "Next Text Listing"
: 'Next Text Listing';
print GROUP "\n", <
$prevhtml <-->
$nexthtml
$gname2
\n"
if $#supgrp > 0;
@members = sort split(/:/, $members{$supgrp});
push(@users, @members);
$supergroup{$supgrp} = $group;
print GROUP "\n\n";
foreach $user (@members) {
print GROUP &userline($user), "
\n";
}
print GROUP @footnote, @tail;
printtail(GROUP);
close GROUP;
$prevgroup = $group;
}
exit if $exittext;
## Write Icon Listings ########################################################
$prevgroup = '';
while ($group = shift @groups) {
$nextgroup = $groups[0];
$gname2 = $gname2{$group} || $group;
open(GROUP, "> $group.html") ||
die "$0: cannot open $cwd/$group.html ($!)\n";
print GROUP @dontedit;
printhead(GROUP);
print GROUP @title, "
\n";
}
print GROUP "Icon Listing - $gname2
\n", @intro;
$prevhtml = ($prevgroup)
? "Previous Icon Listing"
: 'Previous Icon Listing';
$nexthtml = ($nextgroup)
? "Next Icon Listing"
: 'Next Icon Listing';
print GROUP "\n", <
$prevhtml <-->
$nexthtml
$gname2
\n"
if $#supgrp > 0;
$size = ($#members == 0) ? "1 multiple" :
($#members < 5) ? $#members + 1 : 5;
# a little javascript action
print GROUP "\n", <
EOF
}
exit if $exiticon;
## Write User Pages ###########################################################
while ($user = shift @users) {
$nextuser = $users[0];
$name = $name{$user} || $user;
$group = $group{$user};
$gname = $gname{$group} || $group;
$dir = substr($user, 0, 1);
mkdir($dir, 0777 & (0777 ^ umask)) ||
die "$0: cannot mkdir $cwd/$dir ($!)\n" unless -e $dir;
open(FILE, "> $dir/$user.html") ||
die "$0: cannot open $cwd/$dir/$user ($!)\n";
print FILE @dontedit;
printhead(FILE);
print FILE "\n", <
[ Main Index
| Text Listing
| Icon Listing
]
EOF
print FILE &userseq($prevuser, $user, 'Previous Page'),
" <-->\n", &userseq($nextuser, $user, 'Next Page'),
"\n\n";
print FILE "\n
\n";
print FILE "\n\n";
print FILE "
\n";
print FILE "\n\n"
if $foto{$user};
print FILE "$name\n
\n";
print FILE '
\n";
@out = ("
Position: $gname");
push(@out, "Office: $office{$user}")
if $office{$user};
# Print the address if in one of the deptadd groups, looking
# for an addressfile override.
if (grep($group eq $_, @deptadd)) {
if ( -r "/nfs/moose/u/$user/$addressfile") {
$addrtmp=`cat /nfs/moose/u/$user/$addressfile`;
push(@out, "Address: $addrtmp");
}
else {
push(@out, "Address: $deptadd");
}
}
push(@out, "Office phone: $wphone{$user}")
if $wphone{$user};
# Print the fax number if in one of the deptadd groups, looking
# for a faxfile override.
if (grep($group eq $_, @deptadd)) {
if ( -r "/nfs/moose/u/$user/$faxfile") {
$faxtmp=`cat /nfs/moose/u/$user/$faxfile`;
push(@out, "Fax phone: $faxtmp");
}
else {
push(@out, "Fax phone: $deptfax");
}
}
push(@out, "Home phone: $hphone{$user}")
if $hphone{$user};
# Print the email address, looking for a emailfile override.
if ( -r "/nfs/moose/u/$user/$emailfile") {
chomp($emailtmp=`cat /nfs/moose/u/$user/$emailfile`);
}
elsif ( -r "/nfs/whale/u/$user/$emailfile") {
chomp($emailtmp=`cat /nfs/whale/u/$user/$emailfile`);
}
elsif ( -r "/nfs/silo/u/$user/$emailfile") {
chomp($emailtmp=`cat /nfs/silo/u/$user/$emailfile`);
}
else {
$emailtmp="$user\@$domain";
}
push(@out, "E-mail:\n" . &maillink($emailtmp));
print FILE "\n", join("
\n", @out), "\n";
print FILE "See the ";
print FILE "associated FAQ Entry if you want to change the contents of this page
\n";
printtail(FILE);
close FILE;
$prevuser = $user;
}
exit 0;
## General Subroutines ########################################################
# canonicalize GECOS info from passwd file
sub canon {
local($_) = shift;
s/\s+/ /g; s/^ //; s/ $//;
s/[^ -~]//g;
# [<>&] go bye-bye
s/&/&/g; s/</g; s/>/>/g;
foreach $key (@_) {
if ($key eq 'name') {
$_ = substr($_, 0, $maxname) if length > $maxname;
}
# the following looks like sendmail rules ;)
# parse a phone number
if ($key eq 'phone') {
s/^\( ?(\d{3}) ?\) ?-* ?/$1-/;
s/^(\d{3})[- .\/]?(\d{3})[- .\/]?(\d{4})$/$1-$2-$3/;
s/^(\d{3})[- .\/]?(\d{4})$/$areacod-$1-$2/;
s/^(\d)[- .\/]?(\d{4})$/$areacod-$prefix$1-$2/;
}
}
return $_;
}
sub supgrps {
local($group) = @_;
@_ = ($members{$group}) ? ($group) : ();
push(@_, grep($_ =~ /\S/ && $members{$_},
split(/\s+/, $supgrp{$group}))) if $supgrp{$group};
return @_;
}
sub userline {
local($user) = @_;
return '$user " .
'...' . '.' x ((8 - length($user)) % 8) .
(($hyplan{$user}) ? " hyplan"
: '.......') .
(($hyplan{$user} && $resume{$user}) ? ',' :
($hyplan{$user} && ! $resume{$user}) ? ' ' : '.') .
(($resume{$user})
? " résumé "
: '........') . "... " .
$name{$user} . (($foto{$user}) ? ' *' : '');
}
sub userseq {
local($ref, $rel, $txt) = @_;
local($dir);
return $txt unless $ref;
return '$txt";
}
# Printer the html header
sub printhead {
local($f) = @_;
if (open(HEADF, "<$headfile")) {
while(HEADER NOT AVAILABLE
\n"
}
}
# Printer the html footer
sub printtail {
local($f) = @_;
if (open(TAILF, "<$tailfile")) {
while(FOOTER NOT AVAILABLE
\n"
}
}
sub maillink {
my ($addr) = @_;
if ($addr =~ /^(.*)\@cs.indiana.edu$/) {
return("$1");
}
elsif ($addr =~ /^(.*)\@(.*)$/) {
return("$1");
}
elsif ($addr =~ /unlisted/i ) {
return("Unlisted");
}
else {
return("Invalid User-Supplied Email Address");
}
}
## Page Segments ##############################################################
__END__
__DONTEDIT__
__TITLE__
__INTRO__
Personnel Directory
PLEASE NOTE: This directory includes only people with current accounts on
the CS systems. This listing does not include
people who do not have CS accounts so some of the lists may not include
everyone in the specified group.
This directory is generated with
mkpeople,
greppeople and
usermontage.