#!/usr/local/bin/perl
require '/httpd/cgi-bin/headfoot.pl';
if ($ENV{'SERVER_PORT'} eq "443") {
print "Location: http://www.flash.net/~domain/tools\n\n";
}
use Fcntl;
use DB_File;
read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
$in[$i] =~ s/\+/ /g;
($key, $val) = split(/=/,$in[$i],2);
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val;
foreach (keys %in) {
$in{$_} =~ tr/"/ /;
}
}
$in{'domain'} =~ /(^.+)/;
$domain = $1;
$user = $in{'user'};
if ($domain) { &get_info; } elsif ($user) { &user; } else { &startup; }
########################################################################
sub print_header {
print "Content-type: text/html \n\n";
print "$header";
}
########################################################################
sub startup {
&print_header;
print <<_EOF_;
$footer
_EOF_
exit;
}
########################################################################
sub get_info {
&print_header;
print <<_EOF_;
$domain
_EOF_
$db_file = "/home/httpd/conf/domains.db";
$db_obj = tie(%data, 'DB_File', $db_file, O_RDONLY, 0444) or print $!;
if (!$data{$domain}) {
print "It is not in the httpd.conf
";
} else {
$h = $domain;
($rootdir,$serveraliases,$logging) = split(/\|\|/,$data{$h});
$first = substr($h,0,1);
$log_name = "${h}_log";
$access_log = "/httpd/logs/domain_logs/$first/$log_name";
$serveralias = (split(' ',$serveraliases))[0];
if ($h =~ /\d+\.\d+\.\d+\.\d+/) { $host = $serveralias; } else { $host = $h; }
print "| VirtualHost | $h |
";
print "| SeverAdmin | webmaster\@$host |
";
print "| DocumentRoot | $rootdir |
";
print "| ServerName | $host |
";
print "| ServerAlias | $serveraliases www.$serveralias |
";
print "| TransferLog | ";
if($logging eq "y"){
print "$access_log";
}else{
print "n/a";
}
print " |
";
print "| ErrorLog | /httpd/logs/error_log |
";
if (! $rootdir) {
print "Sorry, that domain is not hosted by FlashNet Communications\n\n";
}
}
undef $db_obj;
untie(%data);
if ($in{'nslookup'}) {
$nslookup = `/usr/sbin/nslookup $domain`;
print "";
print "
\nNSLookUp
\n";
print "$nslookup";
print "
";
}
if ($in{'who_is'}) {
print "";
print "
\nWhoIs Record
\n";
print `whois -h whois.crsnic.net $domain`;
print "
";
}
print "";
print "$footer";
exit;
}
########################################################################
sub user {
&print_header;
print <<_EOF_;
$user
_EOF_
$frst = substr($user,0,1);
$scnd = substr($user,1,1);
$rootdir = "/home/$frst/$scnd/$user/www";
$db_file = "/home/httpd/conf/domains.db";
$db_obj = tie(%data, 'DB_File', $db_file, O_RDONLY, 0444) or print $!;
for (keys %data) {
if ($data{$_} =~ /$rootdir\/?/) {
print "$_
";
$h = $domain = $_;
($rootdir,$serveraliases,$logging) = split(/\|\|/,$data{$h});
$first = substr($h,0,1);
$log_name = "${h}_log";
$access_log = "/httpd/logs/domain_logs/$first/$log_name";
$serveralias = (split(' ',$serveraliases))[0];
if ($h =~ /\d+\.\d+\.\d+\.\d+/) { $host = $serveralias; } else { $host = $h; }
print "| VirtualHost | $h |
";
print "| SeverAdmin | webmaster\@$host |
";
print "| DocumentRoot | $rootdir |
";
print "| ServerName | $host |
";
print "| ServerAlias | $serveraliases www.$serveralias |
";
print "| TransferLog | ";
if($logging eq "y"){
print "$access_log";
}else{
print "n/a";
}
print " |
";
print "| ErrorLog | logs/error_log |
";
}
}
undef $db_obj;
untie(%data);
print "$footer";
exit;
}