#!/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 '
IIASA '; my $t=0; if ($A_PT & $_TITL{no}) { print "Staff"; $t=1; } if ($A_PT & $_TITL{co}) { if ($t) { print $A_PT<4 ? " and " : ", " ; } print "Collaborator"; $t=1; } if ($A_PT & $_TITL{vi}) { if ($t) { print $A_PT<8 ? " and " : ", " ; } print "Visitor"; $t = 1; } if ($A_PT & $_TITL{ys}) { if ($t) { print " and " ; } print "YSSP"; } print " Information
\n"; my $avw = $A_VW ; my $cvw = 0 ; if ($avw & $_VIEW{AD}) { $cvw = $_VIEW{AD} ; $avw -= $cvw ; } elsif ($avw & $_VIEW{EJ}) { $cvw = $_VIEW{EJ} ; $avw -= $cvw ; } elsif ($avw & $_VIEW{KL}) { $cvw = $_VIEW{KL} ; $avw -= $cvw ; } elsif ($avw & $_VIEW{MR}) { $cvw = $_VIEW{MR} ; $avw -= $cvw ; } elsif ($avw & $_VIEW{ST}) { $cvw = $_VIEW{ST} ; $avw -= $cvw ; } elsif ($avw & $_VIEW{UZ}) { $cvw = $_VIEW{UZ} ; $avw -= $cvw ; } if (! ($avw & $_VIEW{NOAZ})) { print "\n" ; print "" ; my $tavw = $avw + $_VIEW{AD} ; print "" ; $tavw = $avw + $_VIEW{EJ} ; print "" ; $tavw = $avw + $_VIEW{KL} ; print "" ; $tavw = $avw + $_VIEW{MR} ; print "" ; $tavw = $avw + $_VIEW{ST} ; print "" ; $tavw = $avw + $_VIEW{UZ} ; print "" ; print "
" ; print "" ; print "" if (!$cvw) ; print "[A-Z]" ; print "" if (!$cvw) ; print "    " ; print "( " ; print "" if ($cvw & $_VIEW{AD}) ; print "[A-D]" ; print "" if ($cvw & $_VIEW{AD}) ; print "" ; print "" ; print "" if ($cvw & $_VIEW{EJ}) ; print "[E-J]" ; print "" if ($cvw & $_VIEW{EJ}) ; print "" ; print "" ; print "" if ($cvw & $_VIEW{KL}) ; print "[K-L]" ; print "" if ($cvw & $_VIEW{KL}) ; print "" ; print "" ; print "" if ($cvw & $_VIEW{MR}) ; print "[M-R]" ; print "" if ($cvw & $_VIEW{MR}) ; print "" ; print "" ; print "" if ($cvw & $_VIEW{ST}) ; print "[S-T]" ; print "" if ($cvw & $_VIEW{ST}) ; print "" ; print "" ; print "" if ($cvw & $_VIEW{UZ}) ; print "[U-Z]" ; print "" if ($cvw & $_VIEW{UZ}) ; print " )
\n" ; } print "
\n" ; } sub P_Title2 { my $p=$Pid{$Found[0]}{proj}; foreach my $pt ( split("/", $p) ) { if ($pt =~ $A_Key) { $p = $pt ; } } print "
", uc($p), " - "; if (-f "/tool/www/ifinger/cchome/$p.htm") { print "$Ipdn{$p}{name}"; } else { print $Ipdn{$p}{name}; } print '  ' . (($Ipdn{$p}{flag} =~ "d") ? 'Department' : 'Program') . "" ; if ($A_PT != 15) { my $cma = ""; print "
("; if ($A_PT & $_TITL{no}) { print "Staff"; $cma = ((($A_PT & $_TITL{vi}) xor ($A_PT & $_TITL{ys})) xor ( $A_PT & $_TITL{co})) ? " and " : ", " ; } if ($A_PT & $_TITL{co}) { print $cma, "Collaborators"; $cma = (($A_PT & $_TITL{vi}) xor ($A_PT & $_TITL{ys})) ? " and " : ", " ; } if ($A_PT & $_TITL{vi}) { print $cma, "Visitors"; $cma = " and " if ($A_PT & $_TITL{ys}) ; } if ($A_PT & $_TITL{ys}) { print $cma, "YSSP"; } print " only)

"; } if ($Ipdn{$p}{ccn} =~ '^[0-9][0-9]*$') { print '
Cost Center: ', $Ipdn{$p}{ccn}, '  '; my $u=$Pid{$Ipdn{$p}{head}}; if (defined $u) { print "Head: ", $u->{pfname}, " ", $u->{plname},'   '; } $u=$Pid{$Ipdn{$p}{sec}}; if (defined $u) { print "Administrator: ", $u->{pfname}, " ", $u->{plname},''; } print '
 
'; } } sub ToHtmlUmlaut { my $hu = $_[0] ; $hu =~ s/Ä/Ä/g; $hu =~ s/Ö/Ö/g; $hu =~ s/Ü/Ü/g; $hu =~ s/ß/ß/g; $hu =~ s/á/á/g; $hu =~ s/ä/ä/g; $hu =~ s/ö/ö/g; $hu =~ s/ü/ü/g; $hu ; } sub ToNoUmlaut { my $hu = $_[0] ; $hu =~ s/Ä/A/g; $hu =~ s/Ö/O/g; $hu =~ s/Ü/U/g; $hu =~ s/ß/S/g; $hu =~ s/á/a/g; $hu =~ s/ä/a/g; $hu =~ s/ö/o/g; $hu =~ s/ü/u/g; $hu =~ s/Ä/a/g; $hu =~ s/Ö/o/g; $hu =~ s/Ü/u/g; $hu =~ s/ß/s/g; $hu =~ s/á/a/g; $hu =~ s/ä/a/g; $hu =~ s/ö/o/g; $hu =~ s/ü/u/g; $hu ; } sub FrUmlaut { my $hu = $_[0] ; $hu =~ s/Ä/Ae/g; $hu =~ s/Ö/Oe/g; $hu =~ s/Ü/Ue/g; $hu =~ s/ß/ss/g; $hu =~ s/ä/ae/g; $hu =~ s/ö/oe/g; $hu =~ s/ü/ue/g; $hu ; } sub PrRecs { if (! ($A_VW & $_VIEW{NOPAGE})) { if ($A_Sel =~ "gr|de|pr" && scalar @Found && $A_Key =~ /\w/ && !defined $A_Key_nohead) { P_Title2() ; } else { P_Title1() ; } print "\n\n"; } my $Have_Hdr = 0; if (scalar @Found) { for (my $i = 0 ; $i <= $#Found ; $i++) { my $u = $Pid{$Found[$i]}; if (!$Have_Hdr) { if (! ($A_VW & $_VIEW{NOHDR})) { my $key = UrlEncode($A_Key) ; my $tit = "title='Click on this header to sort in ascending order'" ; print "\n"; if ($A_FD & $_COLS{photo}) { print " "; } if ($A_FD & $_COLS{name}) { print " "; } if ($A_FD & $_COLS{email}) { print " "; } if ($A_FD & $_COLS{ext}) { print " "; } if ($A_FD & $_COLS{room}) { print " "; } if ($A_FD & $_COLS{proj}) { print " "; } if ($A_FD & $_COLS{pos}) { print " "; } print "\n"; } $Have_Hdr=1; } my $bgc = "" ; $bgc = " bgcolor='".(( $i % 2 ) ? $CLR_EVN : $CLR_ODD)."'" if ( $A_VW & $_VIEW{evenodd}) ; print "\n"; if ($A_FD & $_COLS{photo}) { my $pic = "/Admin/PE/faces/" . $u->{login} . ".gif"; if ((! -f "/tool/www".$pic) || ($u->{pic} == 0 && $is_internal == 0)) { $pic = "/ifinger/img/unknown.gif"; } print ""; } ##### my $pdf = "/u/$u->{login}/.myurl"; my $MyEmail = "" ; my $MyURL .= "\ " ; if ( -f $pdf ) { if (my $PD = new FileHandle($pdf)) { while(my $line = <$PD>) { chomp $line ; $line =~ s/#.*// ; $line =~ s/^[\s]*//g ; $line =~ s/[\s*]$//g ; if ($line =~ /^mailto:\s*/i) { $line =~ s/^mailto:\s*//i ; if (length($line)) { $MyEmail .= "
 " if (length($MyEmail)) ; $MyEmail .= "$line" ; } } else { if (length($line)) { my $icon = 'info.gif' ; my $info = "Additional Information" ; if ($line =~ /skype:/) { $icon = 'skype.gif' ; $info = "Skype Link" ; } $MyURL .= "\ " ; } } } close($PD); } } ### Now for the Books if ($u->{pos} !~ /^[gp]/i) { my $l = "http://www.iiasa.ac.at/cgi-bin/ifp?$u->{lname},".substr($u->{fname},0,1)."." ; $l .= "\&$u->{publn},".substr($u->{fname},0,1)."." if (defined $u->{publn}) ; $l =~ s/\s/+/g ; my $t = "IIASA Publications" ; $MyURL .= "\ \n" ; } $MyURL .= "
" ; #============== if ($A_FD & $_COLS{name}) { 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 .= '
 (vacation forwarded)' ; } else { $line .= '@iiasa.ac.at' if (! ($line =~ /@/)) ; $MyFWD .= "
 ($line)" if (length($line)) ; } } close($PD); $MyFWD .= "
" ; $MyFWD =~ s/\@/\@/g ; $MyFWD =~ s/mailto:/ma\ilto:/g ; } } if (!length($MyEmail)) { $MyEmail = $u->{login} . '@iiasa.ac.at' if (!length($MyEmail)) ; # $MyEmail = "$MyEmail" ; $MyEmail = "$MyEmail" ; } $MyEmail =~ s/\@/\@/g ; $MyEmail =~ s/mailto:/ma\ilto:/g ; print "'; } #============== if ($A_FD & $_COLS{ext}) { print ''; } #============== 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 '"; } #============== if ($A_FD & $_COLS{proj}) { print '\n"; } #============== if ($A_FD & $_COLS{pos}) { print "\n" ; } print "\n"; if ($A_FD & $_COLS{extbio}) { my $pbiog = "" ; my $pdf = "/p/idb/mis/biog/".$u->{login}.".html"; if ( -f $pdf) { $pbiog = PrBiog($pdf) ; } else { $pdf = "/p/idb/mis/biog_alternate/".$u->{login}.".html"; if ( -f $pdf) { $pbiog = PrBiog($pdf) ; } } print "\n" if (length($pbiog)) ; } if (($A_FD & $_COLS{intbio})) { my $pbiog = "" ; my $pdf = "/u/".$u->{login}."/.project"; if (-f "$pdf.html") { $pbiog = PrBiog("$pdf.html") ; } elsif ( -f $pdf ) { $pbiog = PrBiog($pdf) ; } elsif ( -f "$pdf.txt") { $pbiog = PrBiog("$pdf.txt") ; } if (length($pbiog)) { print "\n"; } } } } else { print "\n"; } print "
 
" ; print "" ; print "Name
" ; print "" ; print "EMail/URL
" ; print "" ; print "Ext
" ; print "" ; print "Room
" ; print "" ; print "Program
" ; print "" ; print "Category

  $ln, $fn" ; print $MyURL if (length($MyURL) > 30) ; print "
 $MyEmail" ; print $MyFWD if (length($MyFWD) > 30) ; print '
', $u->{ext}, '
     $u->{room}   '; 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 "\ \ $u->{pos}
\n$pbiog\n
\n$pbiog\n

There were no results matching your Search Criteria -- Please try again.
 
\n" if (! ($A_VW & $_VIEW{NOPAGE})) ; } sub PrBiog { my $PD = new FileHandle($_[0]) or return ; my $biog="" ; while(my $line = <$PD>) { $biog .= $line ; } close($PD); $biog =~ s/.*<\s*body[^>]*>//is ; $biog =~ s/<\s*html[^>]*>//i ; $biog =~ s/<\s*\/html[^>]*>//i ; $biog =~ s/<\s*\/body[^>]*>.*//is ; $biog =~ s/^[\r\n]*//s ; $biog =~ s/\r\n/\n/g ; $biog =~ s/<[\s\/]*t[dr][^>]*>//gi ; $biog =~ s/<[\s\/]*table[^>]*>//gi ; $biog =~ s/(<[^>]*)bgcolor=[^\s]*/$1/gi ; $biog .= "\n" ; $biog =~ s/[\n]*$/\n/s ; my $isempty = $biog ; $isempty =~ s/<[^>]*>//g ; $isempty =~ s/[\s\n\W]*//g ; $biog = "" if (!length($isempty)) ; return $biog ; } sub PrProj { if (! ($A_VW & $_VIEW{NOPAGE})) { print '

IIASA Programs and Departments

'; print "\n"; } if (! ($A_VW & $_VIEW{NOHDR})) { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } my $i= 1 ; foreach my $p ( @FProj ) { next if (! defined $Ipdn{$p}{name}) ; $i += 1 ; my $bgc = " bgcolor='".(( $i % 2 ) ? $CLR_EVN : $CLR_ODD)."'" if ( $A_VW & $_VIEW{evenodd}) ; print "\n\n"; print "\n\n\n\n\n"; } print "
Abbrev
CC
Name
Head
Admin
\ \ \ $p
\ $Ipdn{$p}{ccn}\ 
\ "; if ( -f '/tool/www/ifinger/cchome/'.$p.'.htm' ) { print '', $Ipdn{$p}{name}, ""; } else { print $Ipdn{$p}{name}; } print "\ \ "; 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 "\ \ "; $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" if (! ($A_VW & $_VIEW{NOPAGE})) ; } sub Pre { print STDERR "\nPRE: ", @_, "\n" ; } sub DoGroupAlias { my $dgf = "$IF_DIR/$IF_GALIAS" ; if (my $GPD = new FileHandle($dgf)) { while(my $line = <$GPD>) { chomp $line ; $line =~ s/^\s*// ; $line =~ s/\s*$// ; next if (! length($line) || substr($line,0,1) eq '#') ; my @gal = split(':', $line) ; $gal[0] =~ s/\s*$// ; $gal[1] =~ s/^\s*// ; $gal[1] .= " " ; $gal[1] =~ s/[,\s]/ /g ; $gal[1] =~ s/ */ /g ; $gal[1] =~ s/(\w\w*)\s\s*/\^$1\$\|\^$1\[\^a-z\]\|\[\^a-z\]$1\$\|/g ; $gal[1] =~ s/\|$// ; if ($gal[0] eq $A_Key) { $A_Key = $gal[1] ; last ; } } close($GPD) ; } } sub UrlEncode { my($toencode) = shift; $toencode =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg; return $toencode; } 1; # --------------------------------------------------------------- DoArgv(); if (!$A_Key) { print "Location: /ifinger/ifinger.htm\n\n" ; exit(0); } print "Content-type: text/html\n\n" if (! ($A_VW & $_VIEW{NOPAGE})) ; RdIpdname(); RdPasswd(); RdIpdstaff(); if ($A_Sel =~ "na") { $A_Key =~ s/\s*//g ; GetKeys("name", $A_Key); } elsif ($A_Sel =~ "lo|us") { GetKeys("login", $A_Key); } elsif ($A_Sel =~ "gr|de|pr") { if ($A_Key !~ '[^a-z0-9\s]') { if (length($A_Key) <= 4 && $A_Key !~ /\s/) { DoGroupAlias() ; $A_Key = '^'.$A_Key.'$' .'|'. '^'.$A_Key.'[^\w]' .'|'. '[^\w]'.$A_Key.'$' .'|'. '[^\w]'.$A_Key.'[^\w]' ; GetKeys("proj", $A_Key); } else { $A_Key =~ s/\s\s+/ /g ; $A_Key = lc(".*$A_Key.*") ; GetKeys("lproj", $A_Key); $A_Key_nohead = 1 ; } } else { GetKeys("proj", $A_Key); } } elsif ($A_Sel =~ "ex|te|ph") { GetKeys("ext", $A_Key); } elsif ($A_Sel =~ "of|ro") { $A_Key =~ s/-//g; if ($A_Key =~ /elis/) { $A_Key = 's77' ; } elsif($A_Key =~ /raif/) { $A_Key = 's75' ; } elsif($A_Key =~ /gvi/) { $A_Key = 's58' ; } elsif($A_Key =~ /wod/) { $A_Key = 's111' ; } if ($A_Key =~ '[^\W]') { $A_Key = "\^$A_Key\$|\^$A_Key\/|\/$A_Key\/|\/$A_Key\$" ; } GetKeys("room", $A_Key); } else { print "Bad Selector\n"; } ShowData("$IF_DIR/$IF_USER");