#Discus board posting form script
#-------------------------------------------------------------------------------
#This script is copyright (c) 1997-98 by Kevin W. Paulisse and William F. Polik,
#all rights reserved.  You may not modify or delete this copyright header.
#The use of this product is subject to a license agreement.  Contact Kevin
#Paulisse (paulisse@mulliken.chem.hope.edu) for further information.
#-------------------------------------------------------------------------------

open (FILE, "$discus_conf");
@file = <FILE>;
close (FILE);
$evals = "";
foreach $line (@file) {
	if ($line =~ /^(\w+)=(.*)/) {
		$varname = $1;
		$value = $2;
		$value =~ s/'/\\'/g;
		$evals .= "\$$varname='$value'; ";
	}
}
eval($evals);
require "$admin_dir/source/src-board-subs-common";

&parse_form;
&read_cookie;

if ($ENV{'HTTP_REFERER'} =~ /\.$cgi_extension/i) {
	$_ = $FORM{'HTTP_REFERER'};
} else {
	$_ = $ENV{'HTTP_REFERER'};
}

&extract($_);
&header;

($bgcolor,$text,$link,$vlink,$alink,$face,$size,$image) = &ex('extract_colorsonly', 1);
$strg = &JavaScript_prepare ($topic_name);
$str = "$L{BPFCREATETITLE}";
&ex('printuntil', 1, 1, $topic_number, $str);
print "<FORM Action=\"$script_url/board-post.$cgi_extension\" Method=Post>\n";
print "<CENTER><FONT SIZE=+1><B>$str</B></FONT></CENTER>\n<HR>\n";
eval '&printuntil(3, 3, $topic_number, "$str");';
print "<strong><A HREF=\"$message_url/board-topics.html\" onMouseOver=\"window.status = '$L{NBRETURN} ", "$titlej $L{NBMAINPAGE}'; return true\">$title</A>: <A HREF=\"$message_url/$topic_number/$topic_number.$ext\" onMouseOver=\"window.status = '$L{NBRETURN}", "$strg'; return true\">$topic_name</A>: ";
foreach $key (keys(%level_number)) {
	$strg = "$L{NBRETURN} " . &JavaScript_prepare ($level_name{$key});
	print "<A HREF=\"$message_url/$topic_number/$level_number{$key}.$ext";
	print "\" onMouseOver=\"window.status = '$strg'; return true\">$level_name{$key}</A>: \n";
}
eval '&printuntil(5, 5, $topic_number, "$str");';

print <<End_Of_File;
$L{BPFCREATETITLE}
</strong>
<HR><BR>
$L{BPFSUBJECT}
<P>
<TABLE><TR><TD>
<Input Type="Text" Name="subject" Size=53>
</TD></TR></TABLE><BR>
<INPUT type=hidden name="HTTP_REFERER" value="$ENV{'HTTP_REFERER'}">
<INPUT type=hidden name="new_conversation" value="1">
<P>
<HR>
End_Of_File

$privpub = "private";
open (USER, "$admin_dir/users.txt");
@users = <USER>;
close (USERS);
@valid = grep(/:$owner\n?$/, @users);
$privpub = "public" if grep(/^PUBLIC:/, @valid);

for ($i = 7; $i <= 13; $i += 2) {
	eval '&printuntil($i, $i, $topic_number, "$L{BPFCREATETITLE}");';
}

if (open (INPUT, "$admin_dir/addmessage-$privpub.txt")) {
	@add = <INPUT>;
	close (INPUT);
	$flag = 0;
	foreach $line (@add) {
		$line =~ s/<!-FONT-!>/<FONT FACE="$face" SIZE="$size">/g;
		if ($line =~ /<!-Conversation/) {
			$flag = 1;
		} elsif ($line =~ /<!-\/Identification/) {
		} elsif ($flag == 1) {
			if ($line =~ /NAME="name" VALUE=""/i) {
				$line = join("", $`, "NAME=\"name\" VALUE=\"$username_input\"", $');
			} elsif ($line =~ /NAME="number" VALUE=""/i) {
				$line = join("", $`, "NAME=\"number\" VALUE=\"$FORM{'number'}\"", $');
				$line = "" if $FORM{'isitok'} eq "okiedokie";
			} elsif ($line =~ /NAME="Anon"/i) {
				$line = join("", $`, "NAME=\"Anon\" CHECKED", $') if $FORM{'Anon'} eq "on";
			} elsif ($line =~ /NAME="username" VALUE=""/i) {
				$line = join("", $`, "NAME=\"username\" VALUE=\"$COOKIE{'user'}\"", $');
			} elsif ($line =~ /NAME="passwd" VALUE=""/i) {
				$line = join("", $`, "NAME=\"passwd\" VALUE=\"$COOKIE{'rpwd'}\"", $');
				$line = "" if $FORM{'isitok'} eq "okiedokie";
			}
			print $line;
		}
	}
}

for ($i = 15; $i <= 17; $i += 2) {
	eval '&printuntil($i, $i, $topic_number, "$L{BPFCREATETITLE}");';
}

exit(0);

