#! /srvtools/http/bin/perl
#############################################################################
#  
#   File:          PreviewConf.pl
#
#   Author:        Jungmin Kim
#
#   Created:       04/26/95
#   Modified:      
#   Version: 
#
#   Input:         
#                  
#                  
#                  
#                  
#   Output:        
#          
#
#   Description:   
#                  
#                  
#               
#   Usage:         
#                  
#
#
#############################################################################

sub PreviewConf{
    local($conf, $path, $title, $message, $user, $subdir) = @_;

    #### save message and titel to modify them
    $html_message = $message;
    $html_title = $title;

    #### replace HTML reserved characters
    $title =~ s/&/&amp;/g;
    $title =~ s/>/&gt;/g;
    $title =~ s/</&lt;/g;
    $title =~ s/\"/&quot;/g;
    $title =~ s/&/&amp;/g;
    $message =~ s/&/&amp;/g;
    $message =~ s/>/&gt;/g;
    $message =~ s/</&lt;/g;
    $message =~ s/\"/&quot;/g;
    $message =~ s/&/&amp;/g;

    print "Content-type\: text/html\n\n";
    print "\n";
    if ($subdir eq "") {
	print "<TITLE> PREVIEW THE FORUM </TITLE>\n";
	print "<H1> Preview the Title of the Forum </H1>\n";
    }
    else {
	print "<TITLE> PREVIEW INITIAL MESSAGE </TITLE>\n";
	print "<H1> Preview the Initial Message </H1>\n";
    }
    print "<H3>FORUM\: $conf </H3>\n";
    print "<HR>\n";
    print "<B>DIRECTORY\: </B>$path <P>\n";
    print "<IMG SRC=\"$gif/pointer.xbm\" ALIGN=\"left\" ALT=\"\">";
    print "<B><A HREF=\"$action/$subdir\:select\:$path\:\:$user\">\n";
    print "CANCEL this entry and return to the index of forums</A></B>\n";
    print "<HR>\n";

    print "<FORM METHOD=\"POST\" ACTION=\"$change/$subdir\:saveconf\:$user\">\n";
    print "<P>\n";
    print "<DL><DT><B>Choose one of the following</B>\:\n";
    print "<DD>\n";
    print "<I>\n";
    print "<INPUT TYPE=\"radio\" NAME=\"edit\" VALUE=\"no\" CHECKED>\n";
    print " Create the forum<BR>\n";
    print "<INPUT TYPE=\"radio\" NAME=\"edit\" VALUE=\"yes\">\n";
    print " Edit the forum <BR>\n";
    print "</I></DL>\n";

    #### hidden fields
    print "<INPUT TYPE=\"hidden\" NAME=\"newconf\" VALUE=\"$conf\">\n";
    print "<INPUT TYPE=\"hidden\" NAME=\"newdir\" VALUE=\"$path\">\n";
    print "<INPUT TYPE=\"hidden\" NAME=\"title\" VALUE=\"$title\">\n";
    print "<INPUT TYPE=\"hidden\" NAME=\"message\" VALUE=\"$message\">\n";

    print "<INPUT TYPE=\"submit\" VALUE=\"SUBMIT\">\n";
    print "<B>\n";

    print " Press this button to create or edit the forum. \n";
    print "</B>\n";
    print "</FORM>\n";

    print "<HR><P>\n";

    #### replace all double CR and LF characters with <P>
    $html_title =~ s/(\r\n\r\n|\n\n|\r\r)/\<P\>\n/g;
    $html_message =~ s/(\r\n\r\n|\n\n|\r\r)/\<P\>\n/g;

    if ($subdir eq "") {
	print "<B>Title\: </B> $html_title \n";
    }
    else {
	print "<B>Subject\: </B> $html_title \n";
	print "<P><B>Message\: </B><P>\n";
	print "$html_message <P>\n";

	$user =~ s/\+/ /g;
	($username, $userid) = split(/\:/, $user);
	print "<I>\n";
	print $username, ", ", $userid,"\n";
	print "</I>\n";
    }


    print "<P><HR><p>\n";
}
1;
