#!/usr/bin/perl $| = 1; print "Content-type: text/html\n\n"; print "This section has been disabled because of spamming. Click here"; return; # Last change: PFB 16 Mar 2000 0:01 am ############################################################################# # POD Documentation =head1 PROGRAM NAME AND AUTHOR futureforum.cgi FutureForum v1.31 - build date: March 15, 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.31'; # for display purposes # set up file #$home='$ENV{DOCUMENT_ROOT}'; require './futureforum_include.cgi'; &print_top_page; ################################################################################### # 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; #$home='$ENV{DOCUMENT_ROOT}'; #&html_header; #&print_top_page; &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 { local($db)=@_ if @_; # Initialize variables and objects. my $db = "indianscifi_com_-_1"; my $user = "indiansc"; my $password = "indiansc123"; #$db = "egreetings"; #my $user = "rajiv"; #my $password= "rajiv"; my $hostname = "localhost"; my $data_source = "DBI:mysql:$db:$hostname"; use DBI; # Connect to the database. $dbh = DBI->connect($data_source, $user, $password) or &ErrorMsg("Fai led to connect to host:$host: $DBI::errstr\n",__FILE__,__LINE__); #$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~ #
#
#
# ~; # $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 "
|
Alert!~; } # 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})
$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.
~; #........................................ $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 "
|