You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by as...@locus.apache.org on 2000/12/28 02:14:16 UTC
cvs commit: apache-site/dyn closer.cgi
ask 00/12/27 17:14:16
Modified: dyn closer.cgi
Log:
make this actually do something again.
Revision Changes Path
1.8 +7 -4 apache-site/dyn/closer.cgi
Index: closer.cgi
===================================================================
RCS file: /home/cvs/apache-site/dyn/closer.cgi,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- closer.cgi 1998/10/10 19:25:21 1.7
+++ closer.cgi 2000/12/28 01:14:16 1.8
@@ -1,12 +1,16 @@
#!/usr/local/bin/perl
+use Socket;
sub get_dns
{
local($tld, $sld, $cc);
- $tld = $1 if $ENV{'REMOTE_HOST'} =~ /\.([A-Za-z]+)$/;
- $sld = $1 if $ENV{'REMOTE_HOST'} =~ /\.([A-Za-z0-9]+).[A-Za-z]+$/;
+ my $remote_ip = $ENV{REMOTE_ADDR};
+ my $remote_host = gethostbyaddr(inet_aton($remote_ip), AF_INET) || "";
+ $tld = $1 if $remote_host =~ /\.([A-Za-z]+)$/;
+ $sld = $1 if $remote_host =~ /\.([A-Za-z0-9]+)\.[A-Za-z]+$/;
+
if($tld eq "com" || $tld eq "net" || $tld eq "edu" || $tld eq "gov" ||
$tld eq "mil" || $tld eq "org") {
$cc = "us";
@@ -41,7 +45,6 @@
}
else
{
- srand(time);
$start = rand(400) % $count;
$i = $start;
@@ -55,7 +58,7 @@
while(1)
{
$url = $LIST[$i];
-# $url .= "dist/" if $method eq "http";
+ $url .= "dist/" if $method eq "http";
print "\n<A HREF=\"$url\"><STRONG>$LIST[$i]</STRONG></A>";
if ($LOC[$i]) {
print " ($LOC[$i])";