home *** CD-ROM | disk | FTP | other *** search
- #
- # Create a new message
- #
- # Copyright (C) 1994 Afzal Ballim
-
- ############################################################
- #
- # WFCommandMkmsg:
- #
- sub WFCommandMkmsg {
- require "ctime.pl";
-
- # SPECIAL CASE!!! We want mkmsg to change the $in{subject}
- # to an encoded form, so don't have local %in
- %in=@_;
-
- $date=&ctime(time);chop $date;
- $user=$ENV{"REMOTE_USER"};
- %mb=&WFReadDBFile($user);
-
- if ($in{"forum"} eq "") {return "No forum given";}
- if ($in{"subject"} eq "") {return "No subject given";}
- if ($user eq "guest" && $in{"forum"} ne "WebForum%2ediscussion")
- {return "Guests may not post here";}
-
- local ($subject)=$in{"subject"};
- $in{"subject"}=&WFEncodeDatum($subject);
-
- if (!-d "ABSWFSPOOL/$in{forum}/$in{subject}") {
- mkdir("ABSWFSPOOL/$in{forum}/$in{subject}",0777)
- ||return "Couldn't create the subject $forumdec/$subjectdec";
- }
-
- # work out the article number
- $artno=++$mb{"numposts"};
- if (!&WFWriteDBFile($user,%mb)) {return "Could not update user file\n";}
-
- if ($in{"message"} ne "") {
- $aname=sprintf("$in{message}$user#%6.6d;",$artno);
- } else {
- $aname=sprintf("$user#%6.6d;",$artno);
- }
-
- if ($in{"mtype"} ne "html") {
- # insulate the text by replacing the 3 special characters
- # with their reference entity forms.
- $in{"body"} =~ s/&/&\;/g;
- $in{"body"} =~ s/</<\;/g;
- $in{"body"} =~ s/>/>\;/g;
- $in{"body"} =
- "<pre>
- $in{body}
- </pre>";
- }
-
- $msg{"body"}=$in{"body"};
- $msg{"poster"}="$user ($mb{username})";
- $msg{"email"}="<a href=mailto:$mb{email}>$mb{email}</a>";
- $msg{"hurl"}="<a href=$mb{homeurl}>$mb{homeurl}</a>";;
- $msg{"xref"}=$in{"message"};
- $msg{"date"}=$date;
- $msg{"expiry"}=$in{"expiry"};
-
- # having some weird values passed for expiry, so catch them here
- if ($msg{"expiry"} =~ /([0-9]+) days/) {$msg{"expiry"} = "$1 days";}
- elsif ($msg{"expiry"} =~ /never/) {$msg{"expiry"} = "never";}
- else {$msg{"expiry"} = "7 days";}
-
- &WFPutFile("ABSWFSPOOL/$in{forum}/$in{subject}/$aname",%msg);
-
- print "<b>Message Posted</b><p><hr>";
-
- # now, check to see if the forum has a control file
- # with an aux-post method
- if ($ENV{"REQUEST_NO_AUX_POST"} ne "YES"
- && -r "ABSWFSPOOL/$in{forum}/.control") {
- local (%cf)= &WFReadAVFile("ABSWFSPOOL/$in{forum}/.control");
- local ($cfap) = $cf{"aux-post"};
- if ($cfap ne "") {
- local (*AP);
- open(AP,"|ABSWFCTRLBIN/$cfap") ||
- return "Couldn't execute auxiliary post method $cfap";
-
- $in{"body"} =~ s/<pre>\n?//;
- $in{"body"} =~ s/<\/pre>\n?//;
- print AP $cf{"aux-post-args"},"\n";
- print AP "user=", &WFEncodeDatum($user),"\n";
- print AP "username=", &WFEncodeDatum($mb{"username"}),"\n";
- print AP "email=", &WFEncodeDatum($mb{"email"}),"\n";
- print AP "hurl=", &WFEncodeDatum($mb{"homeurl"}),"\n";
- print AP "xref=", &WFEncodeDatum($in{"message"}),"\n";
- print AP "expiry=", &WFEncodeDatum($mb{"expiry"}),"\n";
- print AP "date=", &WFEncodeDatum($date),"\n";
- print AP "subject=", $in{"subject"},"\n";
- print AP "body=", &WFEncodeDatum($in{"body"}),"\n";
- close(AP);
- }
- }
-
- return "";
- }
-
- 1;
-