#!/usr/bin/perl # Last change: PFB 2 Aug 2000 9:41 pm ############################################################################# # POD Documentation =head1 PROGRAM NAME AND AUTHOR futureforum.cgi FutureForum v1.32 - build date: August 2, 2000 by Peter F. Brown - peterbrown@futurerealm.com FutureRealm Productions - futurerealm.com =head1 COPYRIGHT Copyright 1999-2000 Peter F. Brown (FutureRealm Productions) and complies with the GNU GENERAL PUBLIC LICENSE and is released as "Open Source Software". NO WARRANTY IS OFFERED FOR THE USE OF THIS SOFTWARE =head1 BUG REPORTS AND SUPPORT Send bug reports to peterbrown@futurerealm.com. Visit the author's web site at 'worldcommunity.com' to view information about support, customer quotes, a resume link, and fees for custom Perl/MySQL programming. =head1 OBTAINING THE LATEST VERSION ==> Get the most recent version of this program at: http://futurerealm.com/opensource =head1 QUICK INSTALL INSTRUCTIONS 1. Set up a MySQL database called 'forum' 2. Create a table called 'forum' with the specs at the end of this script => see the MySQL GRANT TABLE notes at the end of the script. 3. Place this script in your web tree and make it executable (755) 4. Edit the variables in the 'futureforum_include.cgi' file, and CHECK the variables below. ==> Get the most recent version of this program at: http://futurerealm.com/forum/futureforum.htm =head1 REQUIREMENTS MySQL (www.mysql.com) - built initially with version 3.22.20a ===> field 'branch_no' is a 'text' (blob) field, and is sorted. thus, 'max_sort_length' (a MySQL option) should be set to at least its default of '1024'. Each branch_no uses 8+1 digits, so this would provide for sorting on 113 branches (more than enough, one would think, in a typical forum) DBI:DBD (at the MySQL site) - built with version 1.06 CGI.pm - built with version 2.50 Perl 5 (of course) See the TODO LIST, PARTIAL LIST OF CURRENT FEATURES and HISTORY LIST at the end of the setup file =cut # end of POD Documentation ############################################################################# print "Content-type: text/html\n\n"; $version = 'v1.32'; # for display purposes # set up file require './futureforum_include.cgi'; ################################################################################### # SYSTEM VARIABLES - edit these at your own risk! # used to display all records, or only new records # plug the one of your choice into the default view $now = time(); # this gets set each time the script is called $new_seconds = $new_days * 86400; # $new_seconds = number of days (in seconds) # that a message is considered 'new' # message will have $new_gif displayed as bullet # 1 day = 86400 seconds # 7 days = 604800 seconds # (don't put a comma , in the number) $now_str = "($now - seconds) <= $new_seconds"; $all_str = "message_no > 0"; $limit_str = ''; # $limit_str MUST be set to '', since it's not # used except under the following circumstances: # $minimum_new and $limit_num are in the setup file $default_str = $now_str; # menu hash # DON'T change the KEYS. You can change # the descriptive text values, if you wish. #............................................... %menu = ( 's', 'Simple Menu', 'a', 'Advanced Menu', 'n', 'No Menu' ); @menu = ( 's', 'a', 'n' ); %last = ( '30', '30 Days', '60', '60 Days', '90', '90 Days', '120', '120 Days', '180', '180 Days', '365', '365 Days' ); @last = ( '30', '60', '90', '120', '180', '365' ); $last_days = '30'; # DON'T CHANGE THIS WITHOUT READING THE NOTE TO THE RIGHT!!! ################################################################################### # CRITICAL SYSTEM VARIABLE: !!!!!! $branch_length = 8; $max_messages = 99999999; #!!! $max_messages MUST # MAX length of 'max_messages' in characters # NOT BE LONGER THAN # (specified in 'branch_length') # $branch_length digits # sets number of digits in each branch, # e.g: a branch length of 8 # thus, determines the number of messages # will use a $max_messages var # in each branch, and thus determines the # consisting of 8 digit 9's. # the number of messages in the forum. # e.g: '8' digits maxes out at '99,999,999'. ## $max_messages CAN be # the level 1 branch number is set to the ## shorter than $branch_length # current message ID number, with 0's padding ## if you want to limit # the front, e.g: '009999' or '000999'. ## forum messages # # => NOTE: # the system will not accept messages if # the count(*) value is >= $max_messages # (if records are deleted, the max value # could actually be over the limit!) # => thus, after years of use, I suppose that # the 100,000,000 number could be reached... # (who thought the Y2K problem would happen?) # # => the message_no is incremented NOT just # from the level 1 messages, but also the # branch messages... thus: # ================================================ # 1,000,000 level 1 messages * 100 branch msgs # equals 100,000,000 total messages # (minus 1 = 99,999,999) => 8 digits # Are 8 digits enough? I hope so! :-) # (Who wants to scroll through that many?) # ================================================ # If not, CHANGE IT BEFORE YOU START THE FORUM, # OR THE SORTING OF YOUR BRANCH NUMBERS WILL # BE ENTIRELY TRASHED. YOU HAVE BEEN WARNED! :-) ################################################################################### ################################################################################### use DBI; use CGI qw(:all); $q = new CGI; &html_header; &connect_to_db; # get params if ( param('action') eq "" ) {&top_index($q);} if ( param('action') eq "display" ) {&display_msg($q);} if ( param('action') eq "preview" ) {&preview_msg($q);} if ( param('action') eq "save_msg" ) {&save_msg($q);} exit; ################################################################## # connect_to_db sub connect_to_db { $dbh = DBI->connect("DBI:mysql:$db_main:$db_host" . ";mysql_read_default_file=$cnf_file" . ";mysql_read_default_group=$user_group", $user, $password) || die print qq~


Error connecting to the Forum.
Please contact $forum_admin

~; $sth_s = $dbh->prepare("select count(*) from $db_table") or die "Can't do select: $DBI::errstr\n"; $rv = $sth_s->execute or die "Can't execute the query: $DBI::errstr\n"; ( $count_of_forum ) = $sth_s->fetchrow_array; warn $DBI::errstr if $DBI::err; } ################################################################## # logout sub logout { warn $DBI::errstr if $DBI::err; $rc = $sth_s->finish; $rcdb1 = $dbh->disconnect; } ################################################################### # top_index sub top_index { my($q) = @_; $o_ = param('o_'); # order $d_ = param('d_'); # show date yes or no $t_ = param('t_'); # show time yes or no $tp_ = param('tp_'); # show topic yes or no $s_ = param('s_'); # sql select string $m_ = param('m_'); # menu type $ms_ = param('ms_'); # menu_select option if ( !$o_ ) {$o_ = 'orderval_desc';} if ( !$d_ ) {$d_ = $show_date;} if ( !$t_ ) {$t_ = $show_time;} if ( !$tp_ ) {$tp_ = $show_topic;} if ( !$m_ ) {$m_ = 's';}# n,s,a (simple,advanced,none) # (options for display of menu) # these go together if ( !$ms_ ) {$ms_ = $default_view;} if ( !$s_ ) {$s_ = $default_str;} $since_year = param('since_year'); $since_month = param('since_month'); $since_day = param('since_day'); $topic = param('topic'); $last_days = param('last_days'); if ( !$last_days ) {$last_days = '30';} if ( ( $since_year or $since_month or $since_day ) and ( $since_year !~ /\d{4,4}/ or $since_month !~ /\d{2,2}/ or $since_day !~ /\d{2,2}/ ) ) { print qq~

Sorry...
You must type a 4 digit year,
a 2 digit month, and a 2 digit day.

Hit Back and try again.

~; exit; } $since_date = "$since_year\-$since_month\-$since_day"; $search_by_author = param('search_by_author'); $search_by_text = param('search_by_text'); # selection criteria # all must be mutually exclusive # note that external quote marks are placed on same line as expression, # so that there won't be any spaces at the beginning or end of the # expression on the html page (caused by line breaks in this code.) #.............................................................................. if ( ($ms_ eq 'date') and ($since_year and $since_month and $since_day) ) { $select_crit = "seconds >= unix_timestamp('$since_date')"; } elsif ( $ms_ eq 'new' ) { $select_crit = $now_str; # check for new records; if less than minimum, display more $new_count = 0; $sth_s = $dbh->prepare("select count(*) from $db_table where $select_crit ") or die "Can't do select: $DBI::errstr\n"; $rv = $sth_s->execute or die "Can't execute the query: $DBI::errstr\n"; ( $new_count ) = $sth_s->fetchrow_array; if ( $new_count < $minimum_new ) { $select_crit = $all_str; $limit_str = "limit $limit_num"; # $ms_ = 'all'; # $s_ = $all_str; } # end of check for new records } elsif ( $ms_ eq 'all' ) { $select_crit = $all_str; } elsif ( $ms_ eq 'top_level' ) { $select_crit = "level = 1"; } elsif ( $ms_ eq 'last' ) { $select_crit = "seconds >= ($now - ($last_days * 86400))"; } elsif ( $ms_ eq 'branch' and $s_ ) { $select_crit = $s_; } elsif ( $ms_ eq 'author' and $search_by_author ) { $select_crit = "author like '%$search_by_author%'"; } elsif ( $ms_ eq 'text' and $search_by_text ) { $select_crit = "body like '%$search_by_text%' or subject like '%$search_by_text%'"; } elsif ( $ms_ eq 'author_text' and $search_by_author and $search_by_text ) { $select_crit = "author like '%$search_by_author%' and (body like '%$search_by_text%' or subject like '%$search_by_text%')"; } elsif ( $ms_ eq 'topic' and $topic ) { $select_crit = "topic = '$topic'"; } else { $select_crit = $s_; } $s_ = $select_crit; $s_no_esc = $s_; # changed this because \W didn't accomodate foreign letters # $s_ =~ s/(\W)/sprintf("%%%x", ord($1))/eg; $s_ =~ s/([^a-zA-Z0-9])/sprintf('%%%02x', ord($1))/ge; $order_expr = "branch_no"; # concatenating '-top' forces the sort order to be correctly reversed if ( $o_ eq "orderval_desc" ) { $order_expr = "concat(branch_no,'-top')"; } $sort_order = $o_; $sort_order =~ s/\_/ /g; # display menu and header #..................................................... &top_page_header; #..................................................... if ( $ms_ eq 'top_level' ) { print qq~ Click on a [+] sign to view that branch.

~; } # get records #..................................................... $sth_s = $dbh->prepare("select message_no,parent_no,branch_no,level,topic, subject,author,email,date,time,seconds, responses, $order_expr as orderval from $db_table where $select_crit order by $sort_order $limit_str ") or die "Can't do select: $DBI::errstr\n"; $rv = $sth_s->execute or die "Can't execute the query: $DBI::errstr\n"; $found_query = 'no'; # record display #................................................. while ( $hr = $sth_s->fetchrow_hashref ) { $found_query = 'yes'; print "
"; $i = 1; while ( $i < $hr->{level} ) { print "
$tab"; $i++; } # create form buttons, if ( $ms_ eq 'top_level' ) #.......................................................... if ( $ms_ eq 'top_level' ) { $branch_no = $hr->{branch_no}; $branch_crit = "branch_no like '$branch_no%'"; $branch_crit =~ s/([^a-zA-Z0-9])/sprintf('%%%02x', ord($1))/ge; print qq~ [+] ~; } #.......................................................... # test for 'new' # $new_gif # $new_seconds if ( ($now - $hr->{seconds}) <= $new_seconds ) { # then record is 'new' - display new img $img = $new_gif; print qq~ ~; } else { $gif_num = ($hr->{level} % $gif_limit); if ( $gif_num == 0 ) {$img = $gif[$gif_limit-1];} else {$img = $gif[$gif_num-1];} print qq~ ~; } print qq~ $hr->{subject} ~; if ( $tp_ eq "y" ) { print qq~ - $hr->{topic} ~; } print qq~ - $hr->{author} ~; if ( $d_ eq "y" ) { print qq~ - $hr->{date} ~; } if ( $t_ eq "y" ) { print qq~ - $hr->{time} ~; } print qq~ - ($hr->{responses})
~; $i = 1; while ( $i < $hr->{level} ) { print "
"; $i++; } } # end of record display #................................................. $parent_no = 0; $branch_no = '0000'; $responses = 0; $level = 1; $topic = ""; $subject = ""; $author = ""; $email = ""; $body = ""; if ( $found_query eq 'no' ) { print qq~

Alert!
$count_of_forum messages
are currently in the forum...
~; if ( $ms_ eq 'new' ) { print qq~ but there are no NEW messages, within the last $new_days days. ~; } else { print qq~ but there are no messages matching the query category of
[$ms_]
(based on the specific query text used) ~; } print qq~

Please select "Top Level" or a different type of query, from the menu above.

~; } # display footer, after messages #..................................................... &top_page_footer; #..................................................... &logout; } ################################################################### # display_msg sub display_msg { my($q) = @_; $msg_page = 'true'; # this is set so that the add a message section # will use the word 'Follow Up' $o_ = param('o_'); $d_ = param('d_'); $t_ = param('t_'); $tp_ = param('tp_'); if ( !$o_ ) {$o_ = 'orderval_desc';} if ( !$d_ ) {$d_ = $show_date;} if ( !$t_ ) {$t_ = $show_time;} if ( !$tp_ ) {$tp_ = $show_topic;} $s_ = param('s_'); $m_ = param('m_'); $ms_ = param('ms_'); # menu_select option if ( !$ms_ ) {$ms_ = $default_view;} if ( !$s_ ) {$s_ = $default_str;} $s_no_esc = $s_; $s_ =~ s/([^a-zA-Z0-9])/sprintf('%%%02x', ord($1))/ge; if ( !$m_ ) {$m_ = 'n';} $msg = param('msg'); $branch_no = param('branch_no'); # get parent branch, if exists #.................................................... if ( $branch_no =~ /\-/ ) { # get current level based on elements in branch_no @current_level = split(/\-/, $branch_no); $current_level = @current_level; $parent_branch_no = $branch_no; # chop off last x characters to get parent branch no # this is predicated on x digit branch_no's and 1 dash # set variable at top of script $chop_branch = ($branch_length + 1); $minus_chop = $chop_branch - ($chop_branch * 2); # e.g: substr($parent_branch_no, -8, 8 ) = ''; substr($parent_branch_no, $minus_chop, $chop_branch ) = ''; $select_str = "select message_no, branch_no, parent_no, level, topic, subject, author, email, date, time, responses from $db_table where branch_no like '$parent_branch_no%' order by branch_no "; $sth_s = $dbh->prepare("$select_str") or die "Can't do select: $DBI::errstr\n"; $rv = $sth_s->execute or die "Can't execute the query: $DBI::errstr\n"; $thread_msgs = ''; while ( $hr = $sth_s->fetchrow_hashref ) { # knock out lower level threads # we're only looking for the parent msg and # msgs on the same level (the current 'thread') if ( $hr->{level} > $current_level ){next;} $thread_msgs .= qq~ ~; if ( $hr->{level} == ($current_level - 1) ) { $thread_msgs .= qq~ (parent message) $hr->{subject} ~; } elsif ( $hr->{message_no} == $msg ) { $thread_msgs .= qq~ (current message) - $hr->{subject} ~; } else { $thread_msgs .= qq~ $hr->{subject} ~; } if ( $tp_ eq "y" ) { $thread_msgs .= qq~ - $hr->{topic} ~; } $thread_msgs .= qq~ - $hr->{author} ~; if ( $d_ eq "y" ) { $thread_msgs .= qq~ - $hr->{date} ~; } if ( $t_ eq "y" ) { $thread_msgs .= qq~ - $hr->{time} ~; } $thread_msgs .= qq~ - ($hr->{responses})
~; } } else { $thread_msgs = qq~ [no thread messages]
~; } # print message page header #................................... &print_msg_page_header; #................................... # now get message data $select_str = "select message_no, branch_no, parent_no, level, topic, subject, author, email, date, time, responses, seconds, send_email from $db_table where branch_no like '$branch_no%' order by branch_no "; $sth_s = $dbh->prepare("$select_str") or die "Can't do select: $DBI::errstr\n"; $rv = $sth_s->execute or die "Can't execute the query: $DBI::errstr\n"; $has_follow_ups = 'no'; while ( $hr = $sth_s->fetchrow_hashref ) { # this method will only work if the branch_no's are sorted # correctly, with the current message FIRST!!! # Otherwise, follow up messages will be listed first if ( $hr->{message_no} == $msg ) { # get body here, using $select_str2 # do it this way so we don't have to select a lot of messages # with the body field -- which might be a lot of data $select_str2 = "select body from $db_table where message_no = $msg "; $sth_s2 = $dbh->prepare("$select_str2") or die "Can't do select: $DBI::errstr\n"; $rv2 = $sth_s2->execute or die "Can't execute the query: $DBI::errstr\n"; ( $display_body ) = $sth_s2->fetchrow_array; $display_body =~ s/\n/
/g; $topic = $hr->{topic}; $subject = $hr->{subject}; $email = $hr->{email}; $author = $hr->{author}; $date = $hr->{date}; $time = $hr->{time}; $parent_topic = $hr->{topic}; $parent_subject = $hr->{subject}; $parent_email = $hr->{email}; $parent_date = $hr->{date}; $parent_send_email = $hr->{send_email}; # print text of message #............................. &print_msg_text; #............................. # end of main message display # now, loop through responses #........................................ # first, print $thread_msgs print qq~ Same Level Message Threads
$thread_msgs

Follow Ups (Responses)

~; #........................................ $parent_no = $hr->{message_no}; $branch_no = $hr->{branch_no}; $responses = $hr->{responses}; $level = $hr->{level}; $author = ""; $email = ""; $body = ""; } else { $has_follow_ups = 'yes'; print "
"; $i = 1; while ( $i < $hr->{level} ) { print "
$tab"; $i++; } #.......................................................... # test for 'new' # $new_gif # $new_seconds if ( ($now - $hr->{seconds}) <= $new_seconds ) { # then record is 'new' - display new img $img = $new_gif; print qq~ ~; } else { $gif_num = ($hr->{level} % $gif_limit); if ( $gif_num == 0 ) {$img = $gif[$gif_limit-1];} else {$img = $gif[$gif_num-1];} print qq~ ~; } print qq~ $hr->{subject} ~; if ( $tp_ eq "y" ) { print qq~ - $hr->{topic} ~; } print qq~ - $hr->{author} ~; if ( $d_ eq "y" ) { print qq~ - $hr->{date} ~; } if ( $t_ eq "y" ) { print qq~ - $hr->{time} ~; } print qq~ - ($hr->{responses})
~; $i = 1; while ( $i < $hr->{level} ) { print "
"; $i++; } } } if ( $has_follow_ups eq 'no' ) { print qq~ [no follow ups] ~; } &add_msg_form; print qq~

Back to Forum Top Page

~; } ################################################################### # preview_msg sub preview_msg { my($q) = @_; $o_ = param('o_'); $d_ = param('d_'); $t_ = param('t_'); $tp_ = param('tp_'); if ( !$o_ ) {$o_ = 'orderval_desc';} if ( !$d_ ) {$d_ = $show_date;} if ( !$t_ ) {$t_ = $show_time;} if ( !$tp_ ) {$tp_ = $show_topic;} $s_ = param('s_'); $m_ = param('m_'); $ms_ = param('ms_'); # menu_select option if ( !$ms_ ) {$ms_ = $default_view;} if ( !$s_ ) {$s_ = $default_str;} $s_no_esc = $s_; $s_ =~ s/([^a-zA-Z0-9])/sprintf('%%%02x', ord($1))/ge; if ( !$m_ ) {$m_ = 'n';} $parent_no = param('parent_no'); $branch_no = param('branch_no'); $responses = param('responses'); $level = param('level'); $parent_topic = param('parent_topic'); $parent_subject = param('parent_subject'); $parent_email = param('parent_email'); $parent_send_email = param('parent_send_email'); $parent_date = param('parent_date'); &check_secure_fields; $author = param('author'); $email = param('email'); $topic = param('topic'); $subject = param('subject'); $body = param('body'); $send_email = param('send_email'); if ( length($email) < 5 or $email !~ /\@/ or $email !~ /\./ ) { print qq~

Sorry...

You're email address is incorrect.

Please hit your back button and try again.

~; exit; } $len_body = length($body); if ( $len_body > $max_body_length ) { print qq~

Sorry...

Messages can't be longer than $max_body_length characters.

Your message is $len_body characters long.

Please hit your back button and shorten it.

~; exit; } # add bad word check here #............................................. if ( $badwordcheck eq 'yes' ) { foreach $badword ( @badwords ) { if ( $body =~ /$badword/i ) { print qq~

Sorry... you must have typed a word that we don't allow...

Please hit BACK and edit your post. ~; exit; } } } # end of bad word check #............................................................ $display_body = $body; $display_body =~ s/\n/
/g; print qq~

~; # print preview text #................................... &print_preview_text; #................................... print qq~

(Hit BACK to edit your message)

~; } ################################################################## # save_msg sub save_msg { my($q) = @_; $o_ = param('o_'); $d_ = param('d_'); $t_ = param('t_'); $tp_ = param('tp_'); if ( !$o_ ) {$o_ = 'orderval_desc';} if ( !$d_ ) {$d_ = $show_date;} if ( !$t_ ) {$t_ = $show_time;} if ( !$tp_ ) {$tp_ = $show_topic;} $s_ = param('s_'); $m_ = param('m_'); $ms_ = param('ms_'); # menu_select option # force ms_ and s_ to view new messages # otherwise, user may not see his message and hit submit again and again #=> change these two items to force to 'new' #=> if ( !$ms_ ) {$ms_ = $default_view;} #=> if ( !$s_ ) {$s_ = $default_str;} $ms_ = 'new'; $s_ = $now_str; #.................................................. $s_no_esc = $s_; $s_ =~ s/([^a-zA-Z0-9])/sprintf('%%%02x', ord($1))/ge; if ( !$m_ ) {$m_ = 'n';} # pull out subject and body for email use (preserving <> chars) $mail_subject = param('subject'); $mail_body = param('body'); # replace other chars in mail_subject and mail_body $mail_subject =~ s/"/'/g; $mail_subject =~ s/`/'/g; $mail_subject =~ s/\|/[PIPE SYMBOL]/g; $mail_body =~ s/"/'/g; $mail_body =~ s/`/'/g; $mail_body =~ s/\|/[PIPE SYMBOL]/g; # clean up all fields for web processing &check_secure_fields; $author = param('author'); $email = param('email'); $subject = param('subject'); $body = param('body'); $topic = param('topic'); $send_email= param('send_email'); $mail_topic = $topic; $mail_author = $author; $mail_email = $email; $parent_topic = param('parent_topic'); $parent_subject = param('parent_subject'); $parent_email = param('parent_email'); $parent_send_email = param('parent_send_email'); $parent_date = param('parent_date'); $parent_no = param('parent_no'); $branch_no = param('branch_no'); $responses = param('responses'); $level = param('level'); $author = quotemeta($author); $email = quotemeta($email); $topic = quotemeta($topic); $subject = quotemeta($subject); $body = quotemeta($body); # block duplicate records from being submitted &check_for_dupes; $seconds = time(); $field_str = "parent_no,branch_no,level,topic,subject, author,email,date,time,seconds,body,responses,send_email"; if ( $parent_no == 0 ) { $value_str = "'$parent_no', '0000', '1', '$topic', '$subject', '$author', '$email', curdate(), curtime(), '$seconds', '$body', 0, '$send_email' "; $sth_s = $dbh->do("insert into $db_table ($field_str) values ($value_str)") or die "Can't save data: $DBI::errstr\n"; $last_insert_id = $dbh->func("_InsertID"); # using 'x' for the length of the padded string # thus, each branch can increment to max digits # (in variable $branch_length) $update_str = "UPDATE $db_table SET branch_no = lpad($last_insert_id,$branch_length,'0') where message_no=last_insert_id()"; $sth_s = $dbh->do("$update_str") or die print "Can't save data: $DBI::errstr\n"; } else { $level++; $new_branch_no = $responses + 1; $new_parent_responses = $responses + 1; # using $branch_length $lenp = length("$new_branch_no"); $lenbal = $branch_length - $lenp; $i = 0; while ( $i < $lenbal ) { $new_branch_no = "0" . $new_branch_no; $i++ } $fin_branch_no = "$branch_no\-$new_branch_no"; $value_str = "'$parent_no', '$fin_branch_no', '$level', '$topic', '$subject', '$author', '$email', curdate(), curtime(), '$seconds', '$body', 0, '$send_email' "; $sth_s = $dbh->do("insert into $db_table ($field_str) values ($value_str)") or die "Can't save data: $DBI::errstr\n"; $last_insert_id = $dbh->func("_InsertID"); # insert data into parent record $update_str = "UPDATE $db_table SET responses = $new_parent_responses where message_no=$parent_no"; $sth_s = $dbh->do("$update_str") or die print "Can't save data: $DBI::errstr\n"; if ( $parent_send_email eq 'y' ) { &mail_to_parent; } } # print_save_text #................................... &print_save_text; #................................... warn $DBI::errstr if $DBI::err; $rcdb1 = $dbh->disconnect; &mail_to_host; } ################################################################## # check_for_dupes sub check_for_dupes { $sth_s = $dbh->prepare("select count(*) from $db_table where topic = '$topic' and subject = '$subject' and author = '$author' and email = '$email' and body = '$body' ") or die "Can't do select: $DBI::errstr\n"; $rv = $sth_s->execute or die "Can't execute the query: $DBI::errstr\n"; ( $count_of_msg ) = $sth_s->fetchrow_array; if ( $count_of_msg > 0 ) { print qq~


Error!

This message already exists.

This probably happened because you hit the Submit button more than once, or it may have happened because you hit the Reload button at the "Saved Message Response" Screen.



Back to Forum Top Page

~; exit; } } ################################################################## # sub mail_to_host sub mail_to_host { open (MAIL, "|$mailprog") || die "Can't open $mailprog!\n"; print MAIL ">Return-Path: $forum_admin\n"; print MAIL "To: $forum_admin\n"; print MAIL "From: $mail_email\n"; print MAIL "Subject: $forum_title - $mail_subject\n"; print MAIL "Reply-To: $mail_email\n"; print MAIL "Errors-To: $forum_admin\n"; print MAIL "\n"; print MAIL "Entered from $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'}) with $ENV{'SERVER_PROTOCOL'}.\n"; print MAIL "\n"; print MAIL "$mail_author posted Message \#$last_insert_id\n"; print MAIL "in the $forum_title\n\n"; print MAIL "Topic: $mail_topic\n"; print MAIL "Subject: $mail_subject\n"; print MAIL "........................................................................\n"; print MAIL "\n"; print MAIL "$mail_body"; print MAIL "\n"; close (MAIL); } ################################################################## # sub mail_to_parent sub mail_to_parent { open (MAIL, "|$mailprog") || die "Can't open $mailprog!\n"; print MAIL ">Return-Path: $forum_admin\n"; print MAIL "To: $parent_email\n"; print MAIL "From: $mail_email\n"; print MAIL "Subject: RESPONSE: $forum_title - $mail_subject\n"; print MAIL "Reply-To: $mail_email\n"; print MAIL "Errors-To: $forum_admin\n"; print MAIL "\n"; print MAIL "Entered from $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'}) with $ENV{'SERVER_PROTOCOL'}.\n\n"; print MAIL "in response to your message\n\n"; print MAIL "\"$parent_subject\" on \"$parent_date\"\n"; print MAIL "\n"; print MAIL "$mail_author posted Message \#$last_insert_id\n"; print MAIL "in the $forum_title\n\n"; print MAIL "Topic: $mail_topic\n"; print MAIL "Subject: $mail_subject\n"; print MAIL "........................................................................\n"; print MAIL "\n"; print MAIL "$mail_body"; print MAIL "\n"; close (MAIL); } ################################################################## # check_secure_fields sub check_secure_fields { @secure_fields = ( 'author', 'email', 'subject', 'body' ); foreach $field (@secure_fields) { $tmp = param($field); $tmp =~ s/"/'/g; $tmp =~ s/`/`/g; $tmp =~ s//>/g; $tmp =~ s/\|/|/g; param($field,$tmp); } } ################################################################## # display_menu sub display_menu { print qq~

~; #........................................ if ( $m_ eq 's' or $m_ eq 'a' ) { print qq~ ~; } if ( $m_ eq 'a' ) { print qq~ ~; } print qq~
FutureForum $version © 1999 FutureRealm Productions. Open Source Software.
~; print $q->radio_group(-name=>'m_', -values=>\@menu, -default=>$m_, -labels=>\%menu); print qq~    
Select: All Messages
Top Level
New (Last $new_days Days)
Last ~; print $q->popup_menu(-name=>'last_days', -values=>\@last, -default=>$last_days, -labels=>\%last); print qq~
Select from Topic
 ~; print $q->popup_menu(-name=>'topic', -values=>\@topics, -default=>$topic); print qq~  
 Select by: Author Subject or Msg
(Author) AND (Subject OR Message) (type text in both fields above)  
Select Messages Since Date: YYYY MM DD
Sort by: Message Thread (first to last) Reverse Thread (last to first)
 (messages stay in "thread groups")
Reverse Date Author Subject
 (messages are broken out of "thread groups")
 Show: ~; if ( $d_ eq 'y' ) { print qq~ Date No Date ~; } else { print qq~ Date No Date ~; } print qq~      ~; if ( $t_ eq 'y' ) { print qq~ Time No Time ~; } else { print qq~ Time No Time ~; } print qq~      ~; if ( $tp_ eq 'y' ) { print qq~ Topic No Topic ~; } else { print qq~ Topic No Topic ~; } print qq~
~; #........................................ print qq~ $count_of_forum messages are currently in the forum

\~ displaying messages based on [$ms_] \~ ~; if ( $ms_ eq 'new' and length($limit_str) < 1 ) { print qq~ (messages posted within last $new_days days)
~; } elsif ( $ms_ eq 'new' and length($limit_str) > 0 ) { print qq~ (messages posted within last $new_days days)
** plus some older messages ** (since there aren't enough new ones)
~; } elsif ( $ms_ eq 'last' ) { print qq~ (messages posted within last $last_days days)
~; } elsif ( $ms_ eq 'all') { } elsif ( $ms_ eq 'top_level' ) { } else { print qq~ ($s_no_esc)
~; } if ( $sort_order eq 'orderval asc' ) { print qq~ (sorted by message thread) ~; } elsif ( $sort_order eq 'orderval desc' ) { print qq~ (sorted by reverse message thread) ~; } else { print qq~ (sorted by $sort_order) ~; } print qq~

$help_url_text

[ Go to Message Posting Form Below ]

~; } ################################################################## # print_msg_page_header sub print_msg_page_header { &message_page_header; print qq~
$help_url_text
[Back to Forum Top Page]      [Go to Message Posting Form Below]

~; } ################################################################## # print_msg_text sub print_msg_text { print qq~
/ $topic /

$subject

Posted by $author on $date at $time

$display_body

~; } ################################################################## # print_preview_text sub print_preview_text { &message_page_header; print qq~
$help_url_text
[Back to Forum Top Page]

Preview of Message
Preview your message and then hit "Save",
or hit your browser's Back button to edit your message.

/ $topic /
$subject

Posted by $author

$display_body

~; } ################################################################## # print_save_text sub print_save_text { &message_page_header; print qq~

$help_url_text
[Back to Forum Top Page]

Your Message Has Been Saved

The top page view has been forced to 'NEW',
so that you can see your message when you return to the top page.
(Just in case your current "filter" (selection criteria) of the top page did not include new messages.)

Back to Forum Top Page


~; } ################################################################## # end of script ##################################################################