home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / www / mirrors / acheron / cgi-bin / discus / board-post.cgi < prev    next >
Text File  |  1999-01-26  |  27KB  |  614 lines

  1. #!/usr/bin/perl
  2. $discus_conf = '/usr/local/www/www.acheron.org/discus_admin_245059122/discus.conf';
  3. #Discus board post script (board-post.cgi)
  4. #-------------------------------------------------------------------------------
  5. # This script is copyright (c) 1998 by DiscusWare, LLC, all rights reserved.
  6. # Its use is subject to the license agreement that can be found at the following
  7. # URL:  http://www.chem.hope.edu/discus/license
  8. #-------------------------------------------------------------------------------
  9. #######################################################
  10. # Reply by e-mail: some people have been given a script
  11. # to intercept incoming mail messages and process them
  12. # as Discus messages.  To permit this, the following
  13. # variable must be set to 1.
  14. # 1=On                  0=Off [Default]
  15. $reply_by_email = 0;
  16. #######################################################
  17. # SCRIPT BEGINS HERE...
  18. $double_post_threshold = 120;
  19. if (open (FILE, "$discus_conf")) {
  20.     @file = <FILE>;
  21.     close (FILE);
  22.     $evals = "";
  23.     foreach $line (@file) {
  24.         if ($line =~ /^(\w+)=(.*)/) {
  25.             $varname = $1;
  26.             $value = $2;
  27.             $value =~ s/'/\\'/g; $value =~ s/\r//g;
  28.             $evals .= "\$$varname='$value'; ";
  29.         }
  30.     }
  31.     eval($evals);
  32.     require "$admin_dir/source/src-board-subs-common";
  33. } else {
  34.     print "Content-type: text/html\n\n";
  35.     print "<HTML><HEAD><TITLE>Script Execution Error</TITLE></HEAD>\n";
  36.     print "<BODY BGCOLOR=#ffffff TEXT=#000000>\n";
  37.     print "<H1>Script Execution Error</H1>\n";
  38.     print "Discus scripts could not execute because the discus.conf file\n";
  39.     print "could not be opened.";
  40.     print "<P>Reason: <FONT COLOR=#ff0000><B>$!</B></FONT>" if $!;
  41.     print "<P>This generally indicates a setup error of some kind.\n";
  42.     print "Consult the <A HREF=\"http://www.chem.hope.edu/discus/rc\">Discus ";
  43.     print "Resource Center</A> for troubleshooting information.</BODY></HTML>\n";
  44.     exit(0);
  45. }
  46. require "$admin_dir/source/src-board-subs-admin";
  47. &parse_form;
  48. &read_cookie;
  49. $FORM{'name'} = $FORM{'username'} if $FORM{'username'} ne "";
  50. $FORM{'number'} = $FORM{'passwd'} if $FORM{'passwd'} ne "";
  51. $adminappend = "?username=$FORM{'name'}";
  52. $adminappend .= "&HTTP_REFERER=$FORM{'HTTP_REFERER'}&action=page_editor#Messages";
  53. if ($GLOBAL_OPTIONS{'posting'} == 0 && $GLOBAL_OPTIONS{'options_used'} == 1) {
  54.     &error_message($L{BPAUTHERROR}, $L{AUTHERROR_CLOSED}, 0, 1);
  55. }
  56. if ($ENV{'HTTP_REFERER'} =~ /(.*)\.$cgi_extension/i || $FORM{'HTTP_REFERER'}) {
  57.     $_ = $FORM{'HTTP_REFERER'};
  58.     s/#(.*)//g;
  59. } else {
  60.     $_ = $ENV{'HTTP_REFERER'};
  61.     $FORM{'HTTP_REFERER'} = $_;
  62.     s/#(.*)//g;
  63. }
  64. &extract ($_) if $_ ne "";
  65. $FORM{'name'} =~ s/[\(\)]//g;
  66. $username_input = $FORM{'name'};
  67. $password_input = $FORM{'number'};
  68. ($auth, $passwordline, $poster_type) = &ex('verify_postread_privileges', $topic_number, $username_input, $password_input, $password_input, "posting", 1);
  69. if ($pro) {
  70.     &ex('get_preferences', "*", "*", $passwordline);
  71. }
  72. undef @file; undef $line;
  73. open (FILE, "$admin_dir/postoptions.txt"); @file = <FILE>; close (FILE);
  74. ($line) = grep(/^$topic_number:/, @file); chop $line if $line =~ /\n$/;
  75. ($tn, $anonymous_forbidden, $stamp_forbidden, $email_forbidden) = split(/:/, $line);
  76. if ($passwordline ne "") {
  77.     $passwordline =~ s/\s+$//;
  78.     ($file, $user, $pass, $email, $full, $foo1, $foo2, $foo3, $group) = split(/:/, $passwordline);
  79.     $full = "\u$user" if ($full eq "fullname" || $full eq "" || $stamp_forbidden || ($GLOBAL_OPTIONS{'fullnames'} == 0 && $GLOBAL_OPTIONS{'options_used'} == 1));
  80.     $full .= " (\u$user)" if $GLOBAL_OPTIONS{'user_paren'} eq "";
  81.     $full .= " (\u$user)" if $GLOBAL_OPTIONS{'user_paren'} == 1;
  82.     if ($group !~ /\S/) {
  83.         $group_hold = "MODERATOR";
  84.     } else {
  85.         $group_hold = $group;
  86.     }
  87.     if ($pro) {
  88.         if (($GLOBAL_OPTIONS{'anonymous'} == 1 || $GLOBAL_OPTIONS{'options_used'} == 0) && $FORM{'Anon'} && !$anonymous_forbidden) {
  89.             $postby = $L{BPANONYMOUS};
  90.         } else {
  91.             $warn_anon = 1 if $FORM{'Anon'};
  92.             $filename = "$user-$group_hold.txt";
  93.             $filename = &getfn($filename);
  94.             if (-e "$admin_dir/profiles/$filename" && !$email_forbidden && ($GLOBAL_OPTIONS{'email_on_post'} == 1 || $GLOBAL_OPTIONS{'options_used'} == 0)) {
  95.                 $postby = "<A HREF=\"$script_url/board-profile.$cgi_extension?action=display_profile&profile=$user-$group_hold\">$full</A>";
  96.             } else {
  97.                 $postby = "<A HREF=mailto:$email>$full</A>" if ($PREF{'noemail'} == 0 && $email ne "" && $email ne "email" && !$email_forbidden && ($GLOBAL_OPTIONS{'email_on_post'} == 1 || $GLOBAL_OPTIONS{'options_used'} == 0));
  98.                 $postby = $full if ($PREF{'noemail'} == 1 || $email eq "" || $email eq "email" || $email_forbidden || !($GLOBAL_OPTIONS{'email_on_post'} == 1 || $GLOBAL_OPTIONS{'options_used'} == 0));
  99.             }
  100.         }
  101.     } else {
  102.         if (($GLOBAL_OPTIONS{'anonymous'} == 1 || $GLOBAL_OPTIONS{'options_used'} == 0) && $FORM{'Anon'} && !$anonymous_forbidden) {
  103.             $postby = $L{BPANONYMOUS};
  104.         } else {
  105.             $warn_anon = 1 if $FORM{'Anon'};
  106.             $postby = "<A HREF=mailto:$email>$full</A>" if ($email ne "" && $email ne "email" && !$email_forbidden && ($GLOBAL_OPTIONS{'email_on_post'} == 1 || $GLOBAL_OPTIONS{'options_used'} == 0));
  107.             $postby = $full if ($email eq "" || $email eq "email" || $email_forbidden || !($GLOBAL_OPTIONS{'email_on_post'} == 1 || $GLOBAL_OPTIONS{'options_used'} == 0));
  108.         }
  109.     }
  110.     $username = $user;
  111. } else {
  112.     $postby = $username_input;
  113.     if (($GLOBAL_OPTIONS{'anonymous'} == 1 || $GLOBAL_OPTIONS{'options_used'} == 0) && $FORM{'Anon'} && !$anonymous_forbidden) {
  114.         $postby = $L{BPANONYMOUS};
  115.         $username_input = $L{BPANONYMOUS} if $username_input eq "";
  116.     } else {
  117.         $warn_anon = 1 if $FORM{'Anon'};
  118.         if ($FORM{'email'} ne "") {
  119.             $FORM{'email'} = &remove_html($FORM{'email'});
  120.             $postby = "<A HREF='mailto:$FORM{'email'}'>$username_input</A>";
  121.         }
  122.     }
  123.     $username = "PUBLIC"; $group_hold = "PUBLIC";
  124. }
  125. if ($GLOBAL_OPTIONS{'ip_on_post'}) {
  126.     $rh = $ENV{'REMOTE_HOST'};
  127.     $rh =~ s/[<>]//g;
  128.     $ra = $ENV{'REMOTE_ADDR'};
  129.     $ra =~ s/[<>]//g;
  130.     $postby .= " ($rh - $ra)" ;
  131. }
  132. $FORM{'message'} =~ s/\s+$//;
  133. $FORM{'message'} =~ s/^\s+//;
  134. $FORM{'message'} =~ s/\n{3,}/\n\n\n/g;
  135. if ($FORM{"message"} =~ m|^\{\\rtf| && $pro && $GLOBAL_OPTIONS{'RTF'}) {
  136.     ($FORM{"message"}) = &ex('rtf_to_webtags', $FORM{"message"});
  137.     ($lint, $newmessage) = &ex('webtags', $FORM{"message"}, 0, 1);
  138. }
  139. $remove_swearing = 1 if ($GLOBAL_OPTIONS{'profanity'});
  140. if ($FORM{"message"} !~ /\\(\S+)\{/ && $FORM{"message"} =~ m|<(\s*)([^>]*)(\s*)>| && $GLOBAL_OPTIONS{'html'}) {
  141.     ($message_html) = &ex('html_to_webtags', $FORM{"message"});
  142.     $NEW_SOURCE = $message_html;
  143.     $message_html =~ s/<([^>]*)>//g;
  144.     ($message_html) = &ex('remove_swearing', $message_html) if ($remove_swearing);
  145.     ($lint, $newmessage) = &ex('webtags', $message_html, 0, 1);
  146. } else {
  147.     $NEW_SOURCE = "";
  148.     if ($FORM{"message"} !~ /\\(\S+)\{/ && $GLOBAL_OPTIONS{'active_links'}) {
  149.         $FORM{"message"} = join("", " ", $FORM{"message"}, " ");
  150.         $m = ""; $after = $FORM{"message"};
  151.         while ($after =~ m|(http://)([\w\-\.\+/~\%\?\&\=\:\,]+)|i) {
  152.             $url = join("", $1, $2); $b4 = $`; $after = $';
  153.             if ($url =~ m|([\.\:\;\,])$|) {
  154.                 $url = $`; $after = "$1$after";
  155.             }
  156.             $url_link = $url;
  157.             $url_link =~ s/,(.)/\%2C$1/g;
  158.             $m .= join("", $b4, "\\topurl\{$url_link,$url}");
  159.         }
  160.         $FORM{"message"} = $m . $after;
  161.         $m = ""; $after = $FORM{"message"};
  162.         while ($after =~ m|([\w\-\+\.]+)\@([\w\-\+\.]+)|i) {
  163.             $url = join("", $1, "\@", $2); $b4 = $`; $after = $';
  164.             if ($url =~ m|([\.\:\;\,])$|) {
  165.                 $url = $`; $after = "$1$after";
  166.             }
  167.             $url_link = $url;
  168.             $url_link =~ s/,(.)/\%2C$1/g;
  169.             $m .= join("", $b4, "\\mail\{$url_link,$url}");
  170.         }
  171.         $FORM{"message"} = $m . $after;
  172.     }
  173.     $message_temp = $FORM{"message"};
  174.     ($message_temp) = &ex('remove_swearing', $FORM{"message"}) if ($remove_swearing);
  175.     ($lint, $newmessage) = &ex('webtags', $message_temp, 0, 1);
  176.     $error_observed = 1;
  177. }
  178. if ($FORM{'subject'} ne "") {
  179.     $newsubject = "";
  180.     ($newsubject) = &ex('remove_swearing', $FORM{"subject"}, 3) if ($remove_swearing);
  181.     $newsubject = $FORM{'subject'} if $newsubject eq "";
  182.     ($lint_subj, $newsubject) = &ex('webtags', $FORM{"subject"}, 3, 1);
  183.     $newsubj = 1;
  184.     $newsubject = "\u$newsubject" if $GLOBAL_OPTIONS{'capitalize'};
  185. }
  186. ($postby) = &ex('remove_swearing', $postby, 0, 1) if ($remove_swearing);
  187. if ($auth == 0) {
  188.     $newmessage = "<H3>$L{BPAUTHERROR}</H3>$L{BPAUTHERRORINVALID}";
  189. } elsif ($auth == 2) {
  190.     $newmessage = "<H3>$L{BPAUTHERROR}</H3>$L{AUTHERROR_BANNED}";
  191. } elsif ($auth == 3) {
  192.     $newmessage = "<H3>$L{BPAUTHERROR}</H3>$L{AUTHERROR_CLOSED}";
  193. } elsif ($postby eq "") {
  194.     $newmessage = "<H3>$L{BPAUTHERROR}</H3>$L{BPAUTHERRORNONAME}";
  195. } elsif ($username_input !~ /\S/) {
  196.     $newmessage = "<H3>$L{BPAUTHERROR}</H3>$L{BPAUTHERRORNONAME}";
  197. } elsif ($FORM{"message"} !~ /\S/) {
  198.     $newmessage = "<H3>$L{BPADDMSGERROR}</H3>$L{BPADDMSGERRORDESC}";
  199. } elsif ($FORM{"new_conversation"} == 1 && $FORM{"subject"} !~ /\S/) {
  200.     $newmessage = "<H3>$L{BPCREATEERROR}</H3>$L{BPCREATEERRORDESC}";
  201. } elsif ($poster_type == 8 && (length($FORM{'message'})/1000) > $GLOBAL_OPTIONS{'public_msgsize'} && $GLOBAL_OPTIONS{'options_used'} && $GLOBAL_OPTIONS{'public_msgsize'}) {
  202.     $newmessage = "<H3>$L{BPADDMSGERROR}</H3>";
  203.     $toolong = $L{BP_MESSAGE_EXCEEDED_MAXLENGTH};
  204.     $mxs = $GLOBAL_OPTIONS{'public_msgsize'}; $toolong =~ s/\%maxsize/$mxs/g;
  205.     $ys = length($FORM{'message'})/1000; $toolong =~ s/\%yoursize/$ys/g;
  206.     $newmessage .= $toolong;
  207. } elsif ($poster_type != 8 && (length($FORM{'message'})/1000) > $GLOBAL_OPTIONS{'registered_msgsize'} && $GLOBAL_OPTIONS{'options_used'} && $GLOBAL_OPTIONS{'registered_msgsize'}) {
  208.     $newmessage = "<H3>$L{BPADDMSGERROR}</H3>";
  209.     $toolong = $L{BP_MESSAGE_EXCEEDED_MAXLENGTH};
  210.     $mxs = $GLOBAL_OPTIONS{'registered_msgsize'}; $toolong =~ s/\%maxsize/$mxs/g;
  211.     $ys = length($FORM{'message'})/1000; $toolong =~ s/\%yoursize/$ys/g;
  212.     $newmessage .= $toolong;
  213. } else {
  214.     $error_observed = 0;
  215. }
  216. $error_observed = 1 if $lint eq "!Error";
  217. $error_observed = 1 if $lint_subj eq "!Error";
  218. $newmessage = $newsubject if $lint_subj eq "!Error";
  219. $message_hold = $FORM{'message'}; $message_hold =~ s/&/&/g;
  220. $message_hold =~ s/>/>/g; $message_hold =~ s/</</g; $message_hold =~ s/"/"/g;
  221. $subject_hold = $FORM{'subject'}; $subject_hold =~ s/&/&/g;
  222. $subject_hold =~ s/>/>/g; $subject_hold =~ s/</</g; $subject_hold =~ s/"/"/g;
  223. $p1 = $L{PREVIEW}; $p2 = $L{PREVIEW2};
  224. $p1 = "x" x 100 if $L{PREVIEW} eq "";
  225. $p2 = "x" x 100 if $L{PREVIEW2} eq "";
  226. $p1 =~ s/^\s+//; $p1 =~ s/\s+$//;
  227. $p2 =~ s/^\s+//; $p2 =~ s/\s+$//;
  228. if ($pro) {
  229.     $FORM{'submit'} = "" if ($PREF{'skip_preview'} == 1);
  230. }    
  231. if ($FORM{'submit'} =~ /$p1/i || $FORM{'submit'} =~ /$p2/i || $error_observed == 1) {
  232.     &header;
  233.     ($bgcolor, $text, $link, $vlink, $alink, $face, $size, $image) = &ex('extract_colorsonly', 1);
  234.     $str = "$L{BPNORMALTITLE}";
  235.     &ex('printuntil', 1, 1, $topic_number, "$L{BPNORMALTITLE}");
  236.     print "<FONT SIZE=+1><CENTER><B>$L{BPNORMALTITLE}</B></CENTER></FONT>\n" if $newsubj == 0;
  237.     print "<FONT SIZE=+1><CENTER><B>$L{BPCREATETITLE}</B></CENTER></FONT>\n" if $newsubj == 1;
  238.     print "<HR>\n";
  239.     &ex('printuntil', 3, 3, $topic_number, $title, 0, 1);
  240.     $file = "$message_dir/$topic_number/$me_number.$ext" if -e "$message_dir/$topic_number/$me_number.$ext";
  241.     if (!-e "$message_dir/$topic_number/$me_number.$ext") {
  242.         $file = "$secdir/$topic_number/$me_number.$ext";
  243.         $secure = 1;
  244.     } 
  245.     open (FILE, $file);
  246.     @file = <FILE>;
  247.     close (FILE);
  248.     if ($FORM{'isitok'} ne "okiedokie") {
  249.         ($navbar) = &ex('prepare_navbar', @file);
  250.         $navbar =~ m|^(.*)</A>: |;
  251.         $pre = join("", $1, "</A>: ");
  252.         $url = "$message_url/$topic_number/$me_number.$ext" if !$secure;
  253.         $url = "$script_url/board-auth.$cgi_extension?file=/$topic_number/$me_number.$ext" if $secure;
  254.         $newsubj = 1 if $FORM{'new_conversation'} == 1;
  255.         $javastr = &JavaScript_prepare($me_name);
  256.         $pre .= "<A HREF=\"$url\" onMouseOver=\"return setStatus('$L{RETURNTO}$javastr')\"><FONT COLOR=$vlink>$me_name</FONT></A>: ";
  257.     } else {
  258.         &extract("$FORM{'HTTP_REFERER'}");
  259.         local (@array) = ("$topic_number:$topic_name");
  260.         foreach $key (sort by_number keys(%level_number)) {
  261.             push (@array, "$level_number{$key}:$level_name{$key}");
  262.         }
  263.         $pre = "<A HREF=\"$cgiurlm?username=$FORM{'name'}&action=mgr_1";
  264.         $pre .= "&HTTP_REFERER=$page_referer\" onMouseOver=\"return setStatus('";
  265.         $pre .= "Return to topic selection screen')\"><FONT COLOR=$link>Page Manager</FONT></A>: \n";
  266.         foreach $line (@array) {
  267.             ($number,$name) = split(/:/, $line, 2);
  268.             $pre .= "<A HREF=\"$cgiurlm?username=$FORM{'name'}&action=page_editor";
  269.             $pre .= "&HTTP_REFERER=//$topic_number/$number.$ext\" onMouseOver=\"return ";
  270.             $str = &JavaScript_prepare($name);
  271.             $pre .= "setStatus('Return to editing $str')\"><FONT COLOR=$link>$name</FONT></A>: ";
  272.         }
  273.     }
  274.     $pre .= "$L{BPCREATEDISPLAY}" if $newsubj == 1;
  275.     $pre .= "$L{BPNORMALDISPLAY}" if $newsubj == 0;
  276.     &ex('printuntil', 5, 9, $topic_number, $title, 0, 1);
  277.     print "<strong>$pre</strong>\n";
  278.     print "<HR>\n";
  279.     if (!($error_observed)) {
  280.         print "<FONT SIZE=-1>$L{BPMESSAGEPOST}</FONT>" if $newsubj == 0;
  281.         print "<FONT SIZE=-1>$L{BPCREATEPOST}</FONT>" if $newsubj == 1;
  282.         print "<P>";
  283.         if ($warn_anon == 1) {
  284.             print "$L{BPWARNANONYMOUS}<P>\n";
  285.         }
  286.         if ($lint ne "") {
  287.             print "<FONT SIZE=+1><B>$L{BPPOSSIBLEFORMATTINGERRORS}</B></FONT><P>";
  288.             print "<FONT SIZE=-1>$L{BPPOSSIBLEFORMATTINGERRORSDESC}";
  289.             print "<P>\n";
  290.             print "<OL>$lint</OL><P></FONT>\n";
  291.         }
  292.         if ($pro && $PREF{'spellcheck'} == 1 && $dictionary ne "") {
  293.             ($newmessage, $scmessage) = &ex('spellcheck', $newmessage);
  294.             if ($scmessage ne "") {
  295.                 print $scmessage;
  296.             }
  297.         }        
  298.         &ex('printuntil', 11, 11, $topic_number, $title, 0, 1);
  299.         print "<TABLE BORDER=1 WIDTH=97% HEIGHT=40%><TR><TD VALIGN=TOP><BASEFONT SIZE=$size><FONT FACE=\"$face\" SIZE=\"$size\" COLOR=$text>\n";
  300.         if ($newsubj == 1) {
  301.             print "<B>$L{BPSUBJECTTAG}</B> $newsubject<HR SIZE=0>\n";
  302.         }
  303.         $pb = $L{POSTBY};
  304.         $postby = join("", "<BLINK>", $postby, "</BLINK>") if $warn_anon == 1;
  305.         ($datetime) = &ex('get_date_time', "long");
  306.         $pb =~ s/\%name/$postby/g;
  307.         $pb =~ s/\%date/$datetime/g;
  308.         print "$pb<P>\n";
  309.     }
  310.     print "$newmessage";
  311.     if (!$error_observed) {
  312.         print "</FONT></TD></TR>\n";
  313.         print "</TABLE>\n";
  314.         print "<FORM Method=Post Action=\"$script_url/board-post.$cgi_extension\">\n";
  315.         print "<INPUT Type=hidden name=\"HTTP_REFERER\" value=\"$FORM{'HTTP_REFERER'}\">\n";
  316.         print "<INPUT TYPE=HIDDEN NAME=\"new_conversation\" value=\"1\">\n" if $FORM{'new_conversation'} == 1;
  317.         print "<INPUT Type=hidden name=\"isitok\" value=\"okiedokie\">\n" if $FORM{'isitok'} eq "okiedokie";
  318.         print "<HR>\n";
  319.         print "<CENTER>\n";
  320.         print "<INPUT Type=\"submit\" Name=submit VALUE=\"$L{BPPOSTTHISMESSAGE}\">\n" if !$error_observed;
  321.         print "<INPUT TYPE=\"button\" VALUE=\"$L{BPCANCELPOST}\" onClick=\"window.location=";
  322.         if ($FORM{'isitok'} ne 'okiedokie') {
  323.             $url = "$message_url/$topic_number/$me_number.$ext" if !$secure;
  324.             $url = "$script_url/board-auth.$cgi_extension?file=/$topic_number/$me_number.$ext" if $secure;
  325.             print "'$url'\"> ";
  326.         } else {
  327.             print "'$cgiurlm$adminappend'\"> ";
  328.         }
  329.         print "</CENTER>\n";
  330.     } else {
  331.         print "<BR><BR>\n";
  332.         print "<FORM Method=Post Action=\"$script_url/board-post.$cgi_extension\">\n";
  333.         print "<INPUT Type=hidden name=\"HTTP_REFERER\" value=\"$FORM{'HTTP_REFERER'}\">\n";
  334.         print "<INPUT TYPE=HIDDEN NAME=\"new_conversation\" value=\"1\">\n" if $FORM{'new_conversation'} == 1;
  335.         print "<INPUT Type=hidden name=\"isitok\" value=\"okiedokie\">\n" if $FORM{'isitok'} eq "okiedokie";
  336.     }
  337.     print "<HR>\n";
  338.     &ex('printuntil', 13, 13, $topic_number, $title, 0, 1);
  339.     open (POST, "$admin_dir/posting.txt"); @post = <POST>; close (POST);
  340.     ($line) = grep(/^$topic_number:/, @post);
  341.     ($t, $ip) = split(/:/, $line);
  342.     if ($ip eq "") {
  343.         $privpub = "private";
  344.     } else {
  345.         $privpub = "public";
  346.     }
  347.     open (POST, "$admin_dir/postoptions.txt"); @post = <POST>; close (POST);
  348.     ($line) = grep(/^$topic_number:/, @post);
  349.     ($t, $af) = split(/:/, $line);
  350.     $af = 1 if ($GLOBAL_OPTIONS{'anonymous'} == 0 && $GLOBAL_OPTIONS{'options_used'} == 1);
  351.     if (open(FILExx, "$message_dir/$topic_number/addmessage.conf")) {
  352.         @file = <FILExx>;
  353.     } elsif (open(FILExx, "$secdir/$topic_number/addmessage.conf")) {
  354.         @file = <FILExx>;
  355.     } else {        
  356.         open (FILExx, "$admin_dir/addmessage-$privpub.conf");
  357.         @file = <FILExx>;
  358.     }
  359.     close (FILExx);
  360.     foreach $line (@file) {
  361.         $line =~ s/<!-FONT-!>/<FONT FACE="$face" SIZE="$size">/g;
  362.         $line = "" if $line =~ m|FORM>|;
  363.         $line = "" if ($af && $line =~ m|^<!-Anon-!>|);
  364.     }
  365.     $am = $L{ADDMESSAGE};
  366.     if ($newsubj == 1) {
  367.         $flag = 0;
  368.         foreach $line (@file) {
  369.             if ($line =~ m|$am|i && $flag == 0) {
  370.                 print join("", $`, "$L{BPREVISESUBJECT}", $');
  371.                 $flag = 1;
  372.             }
  373.         }
  374.         print "<H3>$L{BPREVISESUBJECT}</H3>\n" if $flag == 0;
  375.         print "$L{BPFSUBJECT}<BR><BR>\n";
  376.         print "<TABLE><TR><TD><INPUT TYPE=TEXT NAME=\"subject\" VALUE=\"$subject_hold\" SIZE=53></TD></TR></TABLE><P>\n";
  377.         print "<HR>\n";
  378.     }
  379.     $flag = 0;
  380.     $message_hold =~ s/^\s+//;
  381.     $message_hold =~ s/\s+$//;
  382.     foreach $line (@file) {
  383.         if ($line =~ /<!-Conversation - LEAVE THIS HERE!-!>/) {
  384.             $flag = 1;
  385.         } elsif ($line =~ /<!-\/Identification/) {
  386.             $flag = 0;
  387.         } elsif ($line =~ /<!-Skip next line-!>/) {
  388.             $flag = 2+$flag;
  389.         } elsif ($flag >= 2) {
  390.             $flag -= 2;
  391.         } elsif ($line =~ /<!-Submit button included-!>/) {
  392.             $submit_included = 1;
  393.         } elsif ($flag == 1) {
  394.             if ($line =~ /NAME="name" VALUE=""/i) {
  395.                 $line = join("", $`, "NAME=\"name\" VALUE=\"$username_input\"", $');
  396.             } elsif ($line =~ /NAME="number" VALUE=""/i) {
  397.                 $line = join("", $`, "NAME=\"number\" VALUE=\"$FORM{'number'}\"", $');
  398.                 $line = "" if $FORM{'isitok'} eq "okiedokie";
  399.             } elsif ($line =~ /NAME="Anon"/i) {
  400.                 $line = join("", $`, "NAME=\"Anon\" CHECKED", $') if $FORM{'Anon'} eq "on";
  401.             } elsif ($line =~ /NAME="username" VALUE=""/i) {
  402.                 $line = join("", $`, "NAME=\"username\" VALUE=\"$username_input\"", $');
  403.             } elsif ($line =~ /NAME="passwd" VALUE=""/i) {
  404.                 $line = join("", $`, "NAME=\"passwd\" VALUE=\"$FORM{'number'}\"", $');
  405.                 $line = "" if $FORM{'isitok'} eq "okiedokie";
  406.             } elsif ($line =~ /NAME="email" VALUE=""/i) {
  407.                 $line = join("", $`, "NAME=\"email\" VALUE=\"$FORM{'email'}\"", $');
  408.             } elsif ($line =~ /$am/i) {
  409.                 $line = join("", $`, "$L{BPREVISEMESSAGE}", $');
  410.             }
  411.             if ($line =~ m|</TEXTAREA>|i) {
  412.                 $line = join("", $`, $message_hold, $&, $');
  413.             }
  414.             print $line;
  415.         }
  416.     }
  417.     print "<HR>\n";
  418.     if ($submit_included == 0) {
  419.         print "<CENTER>\n";
  420.         print "<INPUT TYPE=\"submit\" Name=submit VALUE=\"$L{BPPREVIEWPOST}\">\n";
  421.         print "</CENTER><HR></FORM>\n";
  422.     }
  423.     &ex('printuntil', 15, 17, $topic_number, $title, 0, 1);
  424.     exit(0);
  425. }
  426. undef $!;
  427. &error_message ("Error", "This page ($me_number) does not allow for public posting of messages!") if $param !~ /Add/ && $newsubj == 0 && $FORM{'isitok'} ne "okiedokie";
  428. &error_message ("Error", "This page does not allow for public creation of conversations!") if $param !~ /Create/ && $newsubj == 1;
  429. &error_message ("Error", "Your username/password combination was invalid, or you are not allowed to post to this topic.") if $passwordline eq "invalid";
  430. if ($GLOBAL_OPTIONS{'double_post'}) {
  431.     open (LOG, "$admin_dir/log.txt");
  432.     @LOG = <LOG>;
  433.     close (LOG);
  434.     $now = time;
  435.     $mh = $newmessage; $mh = &JavaScript_prepare($mh); 
  436.     $mh =~ s/^\s+//; $mh =~ s/\s+$//;
  437.     $mh = &escape($mh);
  438.     foreach $line (reverse(@LOG)) {
  439.         ($index,$by,$time,$where,$addr,$host,$mt,$who2) = split(/;/, $line);
  440.         last if ($now - $double_post_threshold) > $time;
  441.         $mt =~ s/\s+$//;
  442.         ($by2) = ($by =~ m|^(.*):|);
  443.         if ($by2 eq $username && substr($mh, 0, length($mt)) eq $mt) {
  444.             if ($where eq "$topic_number/$me_number" || $newsubj == 1) {
  445.                 if ($FORM{'isitok'} ne 'okiedokie') {
  446.                     $url = "$message_url/$where.$ext";
  447.                     ($ts) = &ex('extract_lastmodified', "$topic_number:$me_number");
  448.                     $url .= "?$ts" if !$noqm;
  449.                 } else {
  450.                     $url = "$cgiurlm$adminappend";
  451.                 }
  452.                 ($head, $color, $lm, $ann, $ann_src, $sublist, $about, $about_src, $message, $message_src) = &get_page(split(/\//, $where));
  453.                 $flag = 0; $source = ""; @msgsrc = split(/\n/, $message_src);
  454.                 foreach $line2 (@msgsrc) {
  455.                     if ($line2 =~ m|<!-Source: $index-!>|) {
  456.                         $flag = 1;
  457.                     } elsif ($line2 =~ m|<!-/Source: (\d+)-!>|) {
  458.                         $flag = 0;
  459.                     } elsif ($flag == 1) {
  460.                         $source .= $line2;
  461.                     }
  462.                 }
  463.                 if ($NEW_SOURCE ne "") {
  464.                     $message_hold = $NEW_SOURCE;
  465.                 }
  466.                 $message_hold =~ s/\s+$//; $message_hold =~ s/^\s+//;
  467.                 $source = &unescape($source);
  468.                 $source =~ s/\s+$//; $source =~ s/^\s+//;
  469.                 if ($source eq $message_hold) {
  470.                     &error_message("$L{BPALREADYPOSTED}", "$L{BPALREADYPOSTEDDESC}<P><B><A HREF=\"$url\">$L{BPCLICKCONTINUE}</A></B><P>", 0, 1);
  471.                 }
  472.             }
  473.         }
  474.     }
  475. }
  476. $message_hold = $message_html if $message_html;
  477. if ($pro) {
  478.     ($queue) = &ex('check_queue_status', $topic_number, $poster_type);
  479. }
  480. if ($newsubj == 1 && !$queue) {
  481.     ($num) = &ex('get_number', 1);     $newnum = $num;
  482.     $pagetitle = $newsubject;
  483.     ($dt) = &ex('get_date_time', "long");     $dt =~ s/\W//g;
  484.     $me_number_hold = $me_number;
  485.     &ex('new_file', $topic_number, $num, $me_number, $owner, $pagetitle);
  486.     &ex('change_layout', $topic_number, $num, "MessagesAdd");
  487.     $url = "$message_url/$topic_number/$num.$ext";
  488.     $url .= "?$dt" if !$noqm;
  489.     $newpage = $newsubject;
  490.     $str = &JavaScript_prepare($newpage);
  491.     $strg = "onMouseOver=\"return setStatus('$str')\"";
  492.     ($ts) = &ex('get_date_time', "short");
  493.     $linex = "<!-Top: $num-!><LI><A HREF=\"$url\" $strg>$newpage</A> <FONT SIZE=\"-1\">";
  494.     $linex .= "$ts</FONT></LI><P>\n";
  495.     &lock("$message_dir/$topic_number/$me_number.$ext");
  496.     ($head, $color, $lm, $ann, $ann_src, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic_number, $me_number);
  497.     @rs = split(/,/, $GLOBAL_OPTIONS{'reverse_subs'});
  498.     if (!grep(/^$topic_number$/, @rs)) {
  499.         $sublist = join("",$sublist,$linex);
  500.     } else {
  501.         $sublist = join("",$linex,$sublist);
  502.     }
  503.     @sublist = split(/\n/, $sublist);
  504.     @as = split(/,/, $GLOBAL_OPTIONS{'alphabet_subs'});
  505.     if (grep(/^$topic_number$/, @as)) {
  506.         @sublist = sort alphabetical_sort @sublist;
  507.         @sublist = reverse @sublist if grep(/^$topic_number$/, @rs);
  508.     }
  509.     @sublist = grep(/\S/, @sublist);
  510.     $sublist = join("\n", @sublist);    
  511.     &set_page($topic_number, $me_number, $head, $color, $lm, $ann, $ann_src, $sublist, $about, $about_src, $message, $message_src);
  512.     &unlock("$message_dir/$topic_number/$me_number.$ext");
  513.     &extract("//$topic_number/$num.$ext");
  514. } elsif ($newsubj == 1 && $queue) {
  515.     $subject_line = $newsubject;
  516. }
  517. if (!$queue) {
  518.     ($postindex, $source_out) = &ex('post_message',$topic_number,$me_number,$message_hold,$newmessage,$postby,$username,$group_hold);
  519.     ($dt) = &ex('get_date_time', "short");
  520.     ($ts) = &ex('get_date_time',"long"); $ts =~ s/\W//g;
  521.     &ex('update_time', $topic_number, $newnum_number, $me_number, $ts, $dt, 0);
  522.     &ex('email_notification', $topic_number, $me_number, $postby, $newmessage, $username, $group_hold) if ($GLOBAL_OPTIONS{'email'} && !$pro);
  523.     &ex('email_notification_pro', $topic_number, $me_number, $postby, $newmessage, $username, $group_hold, 0) if ($GLOBAL_OPTIONS{'email'} && $pro);
  524. } else {
  525.     ($queue_id, $source_out) = &ex('send_message_to_queue', $topic_number, $me_number, $message_hold, $newmessage, $postby, $username, $group_hold, $subject_line);
  526.     &ex('email_notification_pro', $topic_number, $me_number, $postby, $newmessage, $username, $group_hold, 1) if ($GLOBAL_OPTIONS{'email'} && $pro);
  527. }
  528. $url = "$message_url/$topic_number/$me_number.$ext" if !$secure;
  529. $url = "$script_url/board-auth.$cgi_extension?file=/$topic_number/$me_number.$ext&lm=$ts" if $secure;
  530. $url .= "?$ts" if (!$noqm && !$secure);
  531. if ($source_out =~ m|\\image_notuploaded\{| || $source_out =~ m|\\attachment_notuploaded\{|) {
  532.     $string = $source_out;
  533.     &header;
  534.     ($bgcolor, $text, $link, $vlink, $alink, $face, $size, $image) = &ex('extract_colorsonly', 1);
  535.     &ex('printuntil', 1, 1, $topic_number, "$L{BPIMGUPLOADTITLE3_00}");
  536.     print "<FONT SIZE=+1><CENTER><B>$L{BPIMGUPLOADTITLE3_00}</B></CENTER></FONT>\n<HR>\n";
  537.     for ($i = 3; $i <= 9; $i += 2) {
  538.         &ex('printuntil', $i, $i, $topic_number, "$L{BPIMGUPLOADTITLE3_00}");
  539.     }
  540.     print "$L{BPIMGUPLOADINSTR3_00}<P>\n";
  541.     print "<FORM ACTION=\"$script_url/board-image.$cgi_extension\" METHOD=POST ENCTYPE=\"multipart/form-data\">\n";
  542.     print "<HR>\n";
  543.     for ($i = 11; $i <= 13; $i += 2) {
  544.         &ex('printuntil', $i, $i, $topic_number);
  545.     }
  546.     $message = $string;
  547.     while ($source_out =~ m|\\image_notuploaded\{(\d+),([^\}]*)\}|g) {
  548.         $ctr = $1; $descr = $2;
  549.         print "$L{BPPROVIDEFILE} <B>$descr</B>:<P>\n";
  550.         print "<TABLE><TR><TD><INPUT TYPE=FILE NAME=\"Image$ctr\" SIZE=40></TD></TR></TABLE>\n";
  551.         print "<HR>\n";
  552.     }
  553.     while ($source_out =~ m|\\attachment_notuploaded\{(\d+),([^\}]*)\}|g) {
  554.         $ctr = $1; $descr = $2;
  555.         print "$L{BPPROVIDEFILE} <B>$descr</B>:<P>\n";
  556.         print "<TABLE><TR><TD><INPUT TYPE=FILE NAME=\"Attachment$ctr\" SIZE=40></TD></TR></TABLE>\n";
  557.         print "<HR>\n";
  558.     }
  559.     print "<INPUT TYPE=SUBMIT VALUE=\"$L{BPIMGUPLOADBUTTON}\">\n";
  560.     print "<INPUT TYPE=HIDDEN NAME=name VALUE=\"$username_input\">\n";
  561.     print "<INPUT TYPE=HIDDEN NAME=number VALUE=\"$FORM{'number'}\">\n";
  562.     print "<INPUT TYPE=HIDDEN NAME=HTTP_REFERER VALUE=\"//$topic_number/$me_number.$ext\">\n";
  563.     print "<INPUT TYPE=HIDDEN NAME=postindex VALUE=\"$postindex\">\n";
  564.     print "<INPUT Type=hidden name=\"isitok\" value=\"okiedokie\">\n" if $FORM{'isitok'} eq "okiedokie";
  565.     print "<INPUT TYPE=HIDDEN NAME=queue VALUE=\"$queue_id\">\n";
  566.     print "<HR>\n";
  567.     print "</FORM>\n";
  568.     if ($FORM{'isitok'} ne "okiedokie") {
  569.         print "$L{BPIMGUPLOADCANCEL13_00} <A HREF=\"$url\">\n";
  570.     } else {
  571.         print "$L{BPIMGUPLOADCANCEL13_00} <A HREF=\"$cgiurlm$adminappend\">\n";
  572.     }
  573.     print "$L{BPIMGUPLOADCANCEL2}</A>. ";
  574.     print "$L{BPIMGUPLOADCANCEL33_00}\n";
  575.     print "<BR></FONT>\n";
  576.     for ($i = 15; $i <= 17; $i += 2) {
  577.         &ex('printuntil', $i, $i, $topic_number);
  578.     }
  579.     exit(0);
  580. } else {
  581.     &ex('queue_submitted', $topic_number, $me_number, $adminappend, $FORM{'isitok'}) if $queue;
  582.     &seturl("$url") if $FORM{'isitok'} ne "okiedokie";
  583.     &seturl("$cgiurlm$adminappend") if $FORM{'isitok'} eq "okiedokie";
  584. }
  585. sub verify_owner {
  586.     local ($owner, $username) = @_;
  587.     local (@group_data, $group, $usernames, @username, $groupname);
  588.     open (GROUP, "$admin_dir/groups.txt") || &error_message("File Error", "Cannot open group file (groups.txt)!");
  589.     @group_data = <GROUP>;
  590.     close (GROUP);
  591.     foreach $group (@group_data) {
  592.         chop ($group) if $group =~ /\n$/;
  593.         ($groupname, $usernames) = split(/:/, $group);
  594.         if ($groupname eq $owner) {
  595.             @username = split(/,/, $usernames);
  596.             if (grep (/^$username$/, @username)) {
  597.                 return 1;
  598.             } else {
  599.                 return 0;
  600.             }
  601.         }
  602.     }
  603.     return 0;
  604. }
  605. sub alphabetical_sort {
  606.     $a =~ m|<A[^>]+>(.*)</A>|i; $subnamea = $1;
  607.     $b =~ m|<A[^>]+>(.*)</A>|i; $subnameb = $1;
  608.     $subnamea =~ tr/A-Z/a-z/;
  609.     $subnameb =~ tr/A-Z/a-z/;
  610.     return 1 if $subnamea gt $subnameb;
  611.     return -1 if $subnamea lt $subnameb;
  612.     return 0;
  613. }
  614.