#!/tool/perl-5.8.7/bin/perl # # ifinger V 5 - Serge Medow IIASA Feb 14 2006 # use FileHandle ; use strict ; use vars qw( $IF_HTTP $IF_DIR $IF_USER $NU_COL $DEF_FTD $DEF_FTDG $IF_GALIAS $IF_IMG) ; use vars qw( $A_Key $A_Sel $A_Key_nohead $A_PT $A_FD $A_FS $A_VW %Flags $is_internal) ; use vars qw( %Pid %Ipdn %Lid @Found @FProj $DEF_TITL) ; use vars qw ( %_COLS %_TITL %_SORT $CLR_ODD $CLR_EVN %_VIEW %_POS) ; BEGIN { $IF_HTTP = "http://www.iiasa.ac.at/cgi-bin/ifinger"; $IF_DIR = "/tool/www/ifinger"; $IF_IMG = "/ifinger/img" ; $IF_USER = "user.htm"; $IF_GALIAS = "galias" ; $NU_COL = 999999 ; $CLR_ODD = "#FFFFFF" ; $CLR_EVN = "#EEEEEE" ; $_COLS{photo} = 1 ; $_COLS{name} = 2 ; $_COLS{email} = 4 ; $_COLS{ext} = 8 ; $_COLS{room} = 16 ; $_COLS{proj} = 32 ; $_COLS{extbio} = 64 ; $_COLS{vdep} = 128 ; $_COLS{intbio} = 256 ; $_COLS{pos} = 512 ; $_TITL{no} = 1 ; $_TITL{co} = 2 ; $_TITL{vi} = 4 ; $_TITL{ys} = 8 ; $DEF_TITL = $_TITL{no} + $_TITL{co} + $_TITL{ys} ; $_SORT{name} = 1 ; $_SORT{email} = 2 ; $_SORT{ext} = 3 ; $_SORT{room} = 4 ; $_SORT{proj} = 5 ; $_SORT{pos} = 6 ; $_VIEW{std} = 1 ; $_VIEW{vdep} = 2 ; $_VIEW{sup} = 4 ; $_VIEW{res} = 8 ; $_VIEW{evenodd} = 16 ; $_VIEW{AD} = 32 ; $_VIEW{EJ} = 64 ; $_VIEW{KL} = 128 ; $_VIEW{MR} = 256 ; $_VIEW{ST} = 512 ; $_VIEW{UZ} = 1024 ; $_VIEW{NOPAGE} = 2048 ; $_VIEW{NOAZ} = 4096 ; $_VIEW{NOHDR} = 8192 ; $_VIEW{PHOTOS} = 16384 ; $_POS{f11} = "General Service" ; $_POS{s11} = "General" ; $_POS{f12} = "Ghost" ; $_POS{s12} = "Staff" ; $_POS{f13} = "Professional" ; $_POS{s13} = "Professional" ; $_POS{f14} = "Research Assistant" ; $_POS{s14} = "Res. Assist." ; $_POS{f15} = "Research Scholar" ; $_POS{s15} = "Research" ; $_POS{gsv} = $_POS{s11} ; $_POS{sta} = $_POS{s12} ; $_POS{pro} = $_POS{s13} ; $_POS{rsa} = $_POS{s14} ; $_POS{res} = $_POS{s15} ; $_POS{ass} = "Associate" ; $_POS{col} = "Collab." ; $_POS{vis} = "Visitor" ; $_POS{ysp} = "YSSP" ; $_POS{unk} = "Unknown" ; # $DEF_FTD = 63 ; $DEF_FTD = $_COLS{photo} + $_COLS{name} + $_COLS{email} + $_COLS{ext} + $_COLS{room} + $_COLS{proj} ; $DEF_FTDG = $DEF_FTD + $_COLS{pos} + $_COLS{extbio} + $_COLS{intbio} ; } sub Nq { $_[0] =~ s/"//g ; $_[0] ; } sub Ucf { $_[0] =~ s/"//g ; $_[0] =~ s/((^\w)|([_\-\s]\w))/\U$1/xg ; $_[0] ; } sub RdPasswd { my $FD=new FileHandle("ypcat passwd|") or die "ypcat passwd" ; while(<$FD>) { chomp($_); my @P = split(':', $_, 7) ; my $NPv = splice(@P,4,1) ; my @I = split(',', $NPv, 7) ; my $n = splice(@I, 6, 1) ; my @NP = split('/', lc($I[3])) ; my $s = $NP[-1] ; $s =~ s/(..).*/$1/ ; $n = $NU_COL-- if ($s =~ "co|vi|gu" && $n =~ /\D/) ; next if ($n =~ /\D/) ; $Lid{$n}=lc($P[0]) ; if(($s =~ "no" && ($A_PT & $_TITL{no})) || ($s =~ "co" && ($A_PT & $_TITL{co})) || ($s =~ "vi|gu" && ($A_PT & $_TITL{vi})) || ($s =~ "ys" && ($A_PT & $_TITL{ys}))) { $Pid{$n}{status} = $s ; splice(@NP,-1,1) ; $Pid{$n}{lproj} = "" ; foreach my $lnp (@NP) { $Pid{$n}{lproj}=lc($Ipdn{lc($lnp)}{name}).'/' ; } $Pid{$n}{lproj} =~ s/\/$// ; $Pid{$n}{lproj} =~ s/\s\s+/ /g ; $Pid{$n}{proj} = lc(join('/', @NP)) ; $Pid{$n}{projp} = $Pid{$n}{proj} ; $Pid{$n}{projp} =~ s/\W+/\//g ; $Pid{$n}{login} =lc($P[0]) ; $Pid{$n}{passwd} =$P[1] ; $Pid{$n}{uid} =$P[2] ; $Pid{$n}{gid} =$P[3] ; $Pid{$n}{home} =$P[4] ; $Pid{$n}{shell} =$P[5] ; my @nam = split(' ', $I[0]) ; foreach my $np ( split(' ', $I[0]) ) { if ($np =~ "[a-z]") { $Pid{$n}{fname} .= $np . " " ; } else { $Pid{$n}{lname} .= $np . " " ; } } if (! defined $Pid{$n}{lname}) { $Pid{$n}{lname} = join(' ', splice(@nam, $#nam, 1)) ; $Pid{$n}{fname} = join(' ', @nam) ; } chomp($Pid{$n}{fname}) ; chomp($Pid{$n}{lname}) ; $Pid{$n}{lname} = lc($Pid{$n}{lname}) ; $Pid{$n}{fname} = lc($Pid{$n}{fname}) ; $Pid{$n}{name} = $Pid{$n}{fname}.$Pid{$n}{lname} ; $Pid{$n}{fname} = Ucf($Pid{$n}{fname}) ; $Pid{$n}{lname} = Ucf($Pid{$n}{lname}) ; $Pid{$n}{ext} =$I[1] ; $Pid{$n}{room} =lc($I[2]) ; $Pid{$n}{room} =~ s/-//g ; $Pid{$n}{edate} =$I[4] ; $Pid{$n}{gate} =$I[5] ; $Pid{$n}{ipd} = 0 ; $Pid{$n}{pic} = 1 ; $Pid{$n}{pos}=$_POS{unk} ; } } close($FD) ; } sub RdIpdstaff() { my $FD=new FileHandle("ypcat ipdstaff|") or die "ypcat ipdstaff" ; while(<$FD>) { chomp($_); my @S = split(':', $_) ; my $id=splice(@S,0,1) ; $Pid{$id}{publn} = ToNoUmlaut($S[0]) ; $Pid{$id}{lname} = Ucf($S[0]) ; $Pid{$id}{fname} = Ucf($S[1]) ; $Pid{$id}{nat} = Nq(lc($S[2])) ; $Pid{$id}{proj} = Nq(lc($S[3])) ; $Pid{$id}{lproj} = "" ; foreach my $nlp ( split('/', $Pid{$id}{proj}) ) { $Pid{$id}{lproj} .= lc($Ipdn{$nlp}{name}).'/' ; } $Pid{$id}{lproj} =~ s/\/$// ; $Pid{$id}{lproj} =~ s/\s\s+/ /g ; $Pid{$id}{cbeg} = Nq($S[4]) ; $Pid{$id}{cend} = Nq($S[5]) ; $Pid{$id}{ext} = Nq($S[6]) ; $Pid{$id}{room} = lc($S[7]) ; $Pid{$id}{room} =~ s/["-]//g ; $Pid{$id}{plname}= Ucf($S[8]) ; $Pid{$id}{pfname}= Ucf($S[9]) ; $Pid{$id}{pic} = Nq($S[10]); if (length($S[11])) { $Pid{$id}{lname}= Ucf($S[11]); } if (length($S[12])) { $Pid{$id}{fname}= Ucf($S[12]); } $Pid{$id}{name} = lc($Pid{$id}{lname}.$Pid{$id}{fname}.$Pid{$id}{plname}.$Pid{$id}{pfname}) ; $Pid{$id}{pos}=$_POS{"s$S[13]"} ; $Pid{$id}{ipd} = 1 ; } close($FD) ; } sub RdIpdname() { my $FD=new FileHandle("ypcat ipdname|") or die "ypcat ipdname" ; while(<$FD>) { chomp($_); $_ =~ s/"//g ; my @S = split(':', $_) ; my $id=lc(splice(@S,0,1)) ; $Ipdn{$id}{flag} = substr(lc($S[0]),0,1) ; $Ipdn{$id}{name} = Ucf($S[1]) ; $Ipdn{$id}{ccn} = $S[2] ; $Ipdn{$id}{head} = $S[3] ; $Ipdn{$id}{sec} = $S[4] ; } close($FD) ; } sub DoBase { my $a=join('',@_) ; $a =~ tr/+/ / ; $a =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack("C", hex($1))/eg; $a =~ s/\\([^\w\\])/$1/gs ; $a ; } sub DoArgv { my @args = split(':', DoBase(@ARGV)) ; my $na = scalar @args ; if ($na<=1) { $A_Sel = "na" ; # Selector $A_Key = lc($args[0]) ; # Key } else { $A_Sel = substr(lc($args[0]),0,2) ; $A_Key = lc($args[1]) ; } $A_PT = 0 + ($na>=3) ? $args[2] : $_TITL{no} ; # People Type if ( $A_Sel =~ /gr|de|pr/ ) { $A_FD = 0 + ($na>=4) ? $args[3] : $DEF_FTDG ; # Fields to Display } else { $A_FD = 0 + ($na>=4) ? $args[3] : $DEF_FTD ; # Fields to Display } $A_FS = 0 + ($na>=5) ? $args[4] : $_SORT{name} ; # Field to Sort By $A_VW = 0 + ($na>=6) ? $args[5] : $_VIEW{std} ; # How to View if ($A_VW & $_VIEW{PHOTOS}) { $A_VW = $_VIEW{std} + $_VIEW{PHOTOS} + $_VIEW{NOHDR} + $_VIEW{NOPAGE} + $_VIEW{NOA} ; $A_FD = $DEF_FTD ; } $is_internal = (defined $ENV{REMOTE_ADDR}) ? ( ($ENV{REMOTE_ADDR} =~ "^147.125.*")?1:0 ) : 0 ; } sub ShowData { return if (! -f $_[0]) ; if ($A_FD & $_COLS{vdep} ) { $A_FD -= $_COLS{vdep} ; $A_VW |= $_VIEW{vdep} if (! ($A_VW & $_VIEW{vdep}) ) ; } $A_VW -= $_VIEW{std} if (($A_VW & $_VIEW{std}) && ! $A_FD ) ; if ($A_VW & $_VIEW{NOPAGE}) { PrRecs() if ($A_VW & $_VIEW{std}) ; PrProj() if (($A_VW & $_VIEW{vdep}) || ($A_FD & $_COLS{vdep})) ; return ; } my $FD=new FileHandle($_[0]) ; while(my $l = <$FD>) { chomp($l) ; if ( $l =~ /(.*)(<[ \t]*![ \t]*--[ \t]*#[ \t]*exec[ \t]*cmd[ \t]*=[ \t]*)"(.*)"([ \t]*--[ \t]*>)(.*)/i ) { my $a=$1; my $b=$2; my $c=$3; my $d=$4; my $e=$5; $c =~ s/\\*\$REMOTE_ADDR/$ENV{REMOTE_ADDR}/ ; $c =~ s/\\//g ; print $a; print `$c` ; print $e ; next ; } elsif ( $l =~ s"(.*)"" ) { print $1 ; ShowData("/tool/www/$2") ; } elsif ( $l =~ s"(.*)"") { print $1 ; PrRecs() if ($A_VW & $_VIEW{std}) ; PrProj() if (($A_VW & $_VIEW{vdep}) || ($A_FD & $_COLS{vdep})) ; } print "$l\n" ; } close($FD) ; return ; } sub GetKeys { my $umlauts = FrUmlaut($_[1]) ; foreach my $k (keys %Pid) { if (defined $Pid{$k}{login} && defined $Pid{$k}{$_[0]}) { my $noumlaut = ToNoUmlaut($Pid{$k}{$_[0]}) ; if ($Pid{$k}{$_[0]} =~ $_[1] || $Pid{$k}{$_[0]} =~ $umlauts || $noumlaut =~ $_[1]) { if (($A_PT != $_TITL{no} && $A_PT != $_TITL{co} && $A_PT != $_TITL{vi} && $A_PT != $_TITL{ys} ) || ! $Pid{$k}{ipd}) { if ($Pid{$k}{pos} eq $_POS{unk} || !defined $Pid{$k}{pos}) { $Pid{$k}{pos} = $_POS{ass} if ($Pid{$k}{status} =~ "no" && (! $Pid{$k}{ipd})); $Pid{$k}{pos} = $_POS{col} if ($Pid{$k}{status} =~ "co") ; $Pid{$k}{pos} = $_POS{vis} if ($Pid{$k}{status} =~ "gu|vi") ; $Pid{$k}{pos} = $_POS{ysp} if ($Pid{$k}{status} =~ "ys") ; } } if ( (($A_VW & $_VIEW{res}) xor ($A_VW & $_VIEW{sup})) ) { if ($A_VW & $_VIEW{res}) { next if ( $Pid{$k}{pos} eq $_POS{gsv} || $Pid{$k}{pos} eq $_POS{sta} || $Pid{$k}{pos} eq $_POS{pro} ) ; } else { next if ( $Pid{$k}{pos} eq $_POS{rsa} || $Pid{$k}{pos} eq $_POS{res} || $Pid{$k}{pos} eq $_POS{ass} || $Pid{$k}{pos} eq $_POS{col} || $Pid{$k}{pos} eq $_POS{vis} || $Pid{$k}{pos} eq $_POS{ysp}) ; } } if (! ($A_VW & $_VIEW{NOAZ})) { next if ( ($A_VW & $_VIEW{AD}) && (lc($Pid{$k}{lname}) !~ /^[a-d]/) ) ; next if ( ($A_VW & $_VIEW{EJ}) && (lc($Pid{$k}{lname}) !~ /^[e-j]/) ) ; next if ( ($A_VW & $_VIEW{KL}) && (lc($Pid{$k}{lname}) !~ /^[k-l]/) ) ; next if ( ($A_VW & $_VIEW{MR}) && (lc($Pid{$k}{lname}) !~ /^[m-r]/) ) ; next if ( ($A_VW & $_VIEW{ST}) && (lc($Pid{$k}{lname}) !~ /^[s-t]/) ) ; next if ( ($A_VW & $_VIEW{UZ}) && (lc($Pid{$k}{lname}) !~ /^[u-z]/) ) ; } push @Found, $k ; push @FProj, split("/", $Pid{$k}{proj}) ; } } } return if (1 > scalar @Found) ; @Found = sort @Found ; for(my $i=1 ; $i <= $#Found ; $i++) { splice(@Found, $i, 1) if ($Found[$i-1] eq $Found[$i]) ; } @Found = sort {$Pid{$a}{fname} cmp $Pid{$b}{fname}} @Found ; @Found = sort {ToNoUmlaut($Pid{$a}{lname}) cmp ToNoUmlaut($Pid{$b}{lname})} @Found ; if ($A_FS == $_SORT{email}) { @Found = sort {$Pid{$a}{login} cmp $Pid{$b}{login}} @Found ; } elsif ($A_FS == $_SORT{ext}) { @Found = sort {$Pid{$a}{ext} cmp $Pid{$b}{ext}} @Found ; } elsif ($A_FS == $_SORT{room}) { @Found = sort ByRoom @Found ; } elsif ($A_FS == $_SORT{proj}) { @Found = sort {$Pid{$a}{proj} cmp $Pid{$b}{proj}} @Found ; } elsif ($A_FS == $_SORT{pos}) { @Found = sort {$Pid{$a}{pos} cmp $Pid{$b}{pos}} @Found ; } @FProj = sort @FProj ; for(my $i=0 ; $i < $#FProj ; $i++) { while ($i < $#FProj && $FProj[$i] eq $FProj[$i+1]) { splice(@FProj, $i+1, 1) ; } } @FProj = sort {$Ipdn{$a}{name} cmp $Ipdn{$b}{name}} @FProj ; } sub ByRoom { my $va = $Pid{$a}{room} ; my $vb = $Pid{$b}{room} ; while (length($va)<4) { $va =~ /([a-z]*)([0-9]*)/ ; $va = $1.'0'.$2 ; } while (length($vb)<4) { $vb =~ /([a-z]*)([0-9]*)/ ; $vb = $1.'0'.$2 ; } $va cmp $vb ; } sub IsFlag { if (defined $_[1]) { $Flags{$_[0]} = $_[1] ; } return((defined $Flags{$_[0]})?$Flags{$_[0]}:0) ; } sub P_Title1 { print '
" ; print "" ; print "" if (!$cvw) ; print "[A-Z]" ; print "" if (!$cvw) ; print " | " ; my $tavw = $avw + $_VIEW{AD} ; print "" ; print "( " ; print "" if ($cvw & $_VIEW{AD}) ; print "[A-D]" ; print "" if ($cvw & $_VIEW{AD}) ; print " | " ; $tavw = $avw + $_VIEW{EJ} ; print "" ; print "" ; print "" if ($cvw & $_VIEW{EJ}) ; print "[E-J]" ; print "" if ($cvw & $_VIEW{EJ}) ; print " | " ; $tavw = $avw + $_VIEW{KL} ; print "" ; print "" ; print "" if ($cvw & $_VIEW{KL}) ; print "[K-L]" ; print "" if ($cvw & $_VIEW{KL}) ; print " | " ; $tavw = $avw + $_VIEW{MR} ; print "" ; print "" ; print "" if ($cvw & $_VIEW{MR}) ; print "[M-R]" ; print "" if ($cvw & $_VIEW{MR}) ; print " | " ; $tavw = $avw + $_VIEW{ST} ; print "" ; print "" ; print "" if ($cvw & $_VIEW{ST}) ; print "[S-T]" ; print "" if ($cvw & $_VIEW{ST}) ; print " | " ; $tavw = $avw + $_VIEW{UZ} ; print "" ; print "" ; print "" if ($cvw & $_VIEW{UZ}) ; print "[U-Z]" ; print "" if ($cvw & $_VIEW{UZ}) ; print " ) | " ; print "
"; } if ($A_FD & $_COLS{name}) { print " | " ;
print "" ;
print "Name | ";
}
if ($A_FD & $_COLS{email})
{
print " " ;
print "" ;
print "EMail/URL | ";
}
if ($A_FD & $_COLS{ext})
{
print " " ;
print "" ;
print "Ext | ";
}
if ($A_FD & $_COLS{room})
{
print " " ;
print "" ;
print "Room | ";
}
if ($A_FD & $_COLS{proj})
{
print " " ;
print "" ;
print "Program | ";
}
if ($A_FD & $_COLS{pos})
{
print " " ;
print "" ;
print "Category | ";
}
print "||
$ln, $fn" ; print $MyURL if (length($MyURL) > 30) ; print " | "; } #============== if ($A_FD & $_COLS{email}) { my $MyFWD = "" ; $pdf = "/u/$u->{login}/.forwardXXX"; ## Not yet because of some idiots.... if ( -f $pdf ) { if (my $PD = new FileHandle($pdf)) { $MyFWD .= "" ; while(my $line = <$PD>) { chomp $line ; $line =~ s/#.*// ; $line =~ s/,/, /g ; $line =~ s/[\'\"|]//g ; $line = " $line " ; $line =~ s/\s+\\*[\w]+,*\s+//g ; $line =~ s/^[\s]*//g ; $line =~ s/[\s*]$//g ; if ($line =~ /[^s]*vacation$/ ) { $MyFWD .= ' $MyEmail" ;
print $MyFWD if (length($MyFWD) > 30) ;
print ' | ';
}
#==============
if ($A_FD & $_COLS{ext})
{
print '', $u->{ext}, ' | ';
}
#==============
if ($A_FD & $_COLS{room})
{
my $r = $u->{room} ;
$r =~ s/[0-9]//g;
my $rn = $u->{room} ;
$rn =~ s/[^0-9]//g ;
if (!length($rn))
{ $rn = 0 ;
}
$rn = 0 + $rn;
my $nr = "all";
if (substr($r,0,1) =~ "s")
{
if (substr($r,1,1) =~ "r")
{
$nr = "rest";
} elsif ($rn >= 1 && $rn <= 51)
{
$nr = "s0";
}
# elsif ($rn == 81)
# {
# $nr = "rest";
# }
elsif ($rn >= 52 && $rn <= 111)
{
$nr = "s1";
} elsif ($rn >= 112 && $rn <= 120)
{
$nr = "bel";
} elsif (($rn > 120 && $rn <= 170) || ($rn >= 245 && $rn <=265))
{
$nr = "pw";
}
} elsif (substr($r,0,1) =~ "g")
{
$nr = "gpb";
} elsif (substr($r,0,1) =~ "t")
{
$nr = "tb";
}
my $rm = "room=$u->{room}" ;
$rm =~ s/-//g ;
print '$u->{room} | "; } #============== if ($A_FD & $_COLS{proj}) { print ''; my @proj = split('/', $u->{proj}); for (my $i=0 ; $i <= $#proj ; $i++) { print "" ; if ($u->{proj} eq $u->{projp}) { print $proj[$i] ; } else { print uc($proj[$i]) ; } print ""; print '/' if ($i < $#proj) ; } print " | \n"; } #============== if ($A_FD & $_COLS{pos}) { print "\ \ $u->{pos} | \n" ; } print "|||
\n$pbiog\n | ||||||||
\n$pbiog\n | ||||||||
There were no results matching your Search Criteria -- Please try again. |
Abbrev | \n";
print "CC | \n";
print "Name | \n";
print "Head | \n";
print "Admin |
\ \ \ $p | \n"; print "\ $Ipdn{$p}{ccn}\ | \n\ "; if ( -f '/tool/www/ifinger/cchome/'.$p.'.htm' ) { print '', $Ipdn{$p}{name}, ""; } else { print $Ipdn{$p}{name}; } print " | \n\ \ "; my $nam = substr($Pid{$Ipdn{$p}{head}}{fname} ,0,1).".\ ". $Pid{$Ipdn{$p}{head}}{lname} ; if (defined $Pid{$Ipdn{$p}{head}}{login}) { print "$nam\ "; } print " | \n\ \ "; $nam = substr($Pid{$Ipdn{$p}{sec}}{fname} ,0,1).".\ ". $Pid{$Ipdn{$p}{sec}}{lname} ; if (defined $Pid{$Ipdn{$p}{sec}}{login}) { print "$nam"; } print " | \n