#!/usr/athena/bin/perl
# Zlocate Gateway
# $Id: zlocate,v 1.9 2004/07/29 19:24:44 root Exp $
# Matthew Gray (mkgray@mit.edu) June '93
# Matthew Gray (mkgray@mit.edu) June '94 Converted to CGI

$query=$ENV{'QUERY_STRING'};

print("Content-Type: text/html\n\n");
$query =join(' ', @ARGV) if $ARGV[0];
print("\n");
&do_zlocate($query);

sub do_zlocate {
    local($name, $zl, *ZL) = @_;

    if($name =~ /[A-Za-z0-9_+\s]{2,}/){
	open(ZL, "-|") || (open(STDERR, ">&STDOUT"),
		 exec '/usr/athena/bin/zlocate', '-d', split(/[\+\s]+/,$name));
	while($_ = <ZL>) {$zl .= $_;}

    ($host, @rest) =split(' ', $zl);
	$zl =~ s/^([^ \tH]+)/<a href="\/finger\?$name\@$host">\1<\/a>/;
    	$zl =~ s/>deathtongue/>deatht&ouml;ngue/i;

	print <<"end_msg";
<html><head><title>Zlocate $name</title><body>
<h1>Zlocate $name</h1>
<isindex prompt="Enter the username of the person you wish to locate: ">
<pre>$zl</pre>
</body>
end_msg
    }
    else{
	print <<"end_msg";
<html><head><title>Zlocate (information)</title></head><body>
<h1>Zlocate Gateway</h1>
<isindex prompt="Enter the username of the person you wish to locate: ">

<p>Zlocate is a program used by MIT's Zephyr message system.
You can use it to find out where someone is logged in.
However, if they wish to be hidden, it is not possible to locate them.</p>

<p>Click <a href="zlocate?mkgray+nocturne+yonah+fubob+leira+annmarie+tlai">here</a>
to see if any of the Webmasters are on line.</p>

<p>In order to be locateable by the web zlocate gateway, you must set your
zephyr exposure to be net-announced using the command</p>

<p><code>zctl set exposure net-visible</code></p>

<p><em>Note</em>: This will make you realm-announced as well, so you
will appear in the znols of people who have you in their .anyone
file. For more information on
<a href="/afs/sipb/project/doc/izephyr/html/section3.html">exposure</a>
and other aspects of zephyr, check
<a href="/afs/sipb/project/doc/izephyr/html/izephyr.html">Inessential
Zephyr</a>.</p>

</body></html>
end_msg
    }
}

1;
