#!/usr/local/bin/perl require '/httpd/cgi-bin/headfoot.pl'; if ($ENV{'SERVER_PORT'} eq "443") { print "Location:http://www.flash.net/domains\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; $serveralias = $in{'serveralias'}; $logging = $in{'logging'}; $logging = "n" unless $logging; if ($domain) { &get_info; } else { &startup; } sub print_header { print "Content-type: text/html \n\n"; print "$header"; } sub startup { &print_header; print <<_EOF_;

- IP address to Add

- rootdir

- server name

enable logging


$footer _EOF_ exit; } sub get_info { &print_header; $nslookup = `/usr/sbin/nslookup $domain`; #unless ($nslookup =~ /209\.30\.0\.12/) { # print <<_EOF_; #

$domain

#
#This domain does not appear to be hosted by FlashNet and therefore will not #be added to the DB. #
#$nslookup
#
#_EOF_ #&printfooter; #} $rootdir = $in{'rootdir'}; unless (-e $rootdir) { print "

$domain

\n
\n"; print "Sorry, can't do it.... I do not show that the root directory
\n"; print "$rootdir
\n"; print "actually exists, therefore I will not add the domain....\n"; &printfooter; } print "

$domain


"; $db_file = "/httpd/conf/domains.db"; $db_obj = tie(%data, 'DB_File', $db_file, O_RDWR, 0666) or print $!; if ($data{$domain}) { print "I show that the domain, $domain, already exists on our server."; print "If you need to make a change, go there..."; } else { print "OK, looks like you have a good one...."; print " I have added the domain with the following info, if it isn't correct"; print " try the Change Domain link."; $h = $domain; $host; $serveraliases = $domain; $first = substr($h,0,1); $log_name = "${h}_log"; $access_log = "domain_logs/$first/$log_name"; #$serveralias = (split(' ',$serveraliases))[0]; if ($h =~ /\d+\.\d+\.\d+\.\d+/) { $host = $serveralias; } else { $host = $h; } print ""; print ""; print ""; print ""; print ""; print ""; print "
VirtualHost $h
SeverAdmin webmaster\@$host
DocumentRoot $rootdir
ServerName $host
ServerAlias $serveraliases www.$serveralias
TransferLog "; if($logging eq "y"){ print "$access_log"; }else{ print "n/a"; } print "
ErrorLog logs/error_log
"; $data{$domain} = "$rootdir||$serveralias||$logging"; print "$domain=$rootdir||$serveralias||$logging"; } undef $db_obj; untie(%data); &printfooter; } sub printfooter { print "$footer"; exit; }