
$base_dir        = $ENV{SERVER_WWW_HOME}; 
$base_href       = $ENV{SERVER_WWW_URL};
$SERVER_COMMENTS = $ENV{SERVER_COMMENTS};
$SERVER_COMMENTS =~ s/\@/\\@/g; 
$SERVER_NAME     = $ENV{SERVER_NAME}; 
$SERVER_HOME     = $ENV{SERVER_HOME}; 
$ENV{BACKGROUND} = "BGCOLOR='$ENV{SERVER_WWW_BACKGROUND}'";

$TOKEN = "\U$ARGV[0]";
($type, $solver) = split(/:/, $TOKEN);

if (-s "$ENV{SERVER_SOLVERS}/$TOKEN/config") {
  chop(@config = `cat $ENV{SERVER_SOLVERS}/$TOKEN/config`);
}

$COUNT = 1;
foreach (@config) {
  $CONFIG .= "\$config[$COUNT] = \"$_\";\n";
  $COUNT++;
}

$TEMPLATE = `cat $ENV{SERVER_LIB}/cgi/nph-solver-www.cgi`;
$TEMPLATE =~ s/<WEB_PERL>/$ENV{SERVER_WEB_PERL}/g;
$TEMPLATE =~ s/<SOFTWARE_TYPE>/$type/g;
$TEMPLATE =~ s/<SOLVER>/$solver/g;
$TEMPLATE =~ s/<CONFIG_FILE>/$CONFIG/g;
$TEMPLATE =~ s/<SERVER_NAME>/$SERVER_NAME/g;
$TEMPLATE =~ s/<BASE_DIR>/$base_dir/g;
$TEMPLATE =~ s/<BASE_HREF>/$base_href/g;
$TEMPLATE =~ s/<SERVER_HOME>/$SERVER_HOME/g;
$TEMPLATE =~ s/<SERVER_BIN>/$ENV{SERVER_BIN}/g;
$TEMPLATE =~ s/<SERVER_CGIS>/$ENV{SERVER_CGI_HOME}/g;
$TEMPLATE =~ s/<SERVER_VAR>/$ENV{SERVER_VAR}/g;
$TEMPLATE =~ s/<SERVER_CGI_LIB>/$ENV{SERVER_CGI_LIB}/g;
$TEMPLATE =~ s/<SERVER_CGI_URL>/$ENV{SERVER_CGI_URL}/g;
$TEMPLATE =~ s/<SERVER_COMMENTS>/$SERVER_COMMENTS/g;
$TEMPLATE =~ s/<HOSTNAME>/$hostname/g;
$TEMPLATE =~ s/BGCOLOR/$ENV{BACKGROUND}/g;
$email = $ENV{SERVER_EMAIL};
$email =~ s/\@/\\@/g;
$TEMPLATE =~ s/<SERVER_EMAIL>/$email/g;
$admail = $ENV{SERVER_ADMIN};
$admail =~ s/\@/\\@/g;
$TEMPLATE =~ s/<SERVER_ADMIN>/$admail/g;
print $TEMPLATE;


