#!/usr/bin/perl # # NOTE: The Perl script will display the forum's new messages # based on the administrators' settings within this script. # # Usage: # # # # NEW FEATURE - HELP NEEDED! # # Each forum category has a database file (database.txt) which appears like this: # Forum fields: $num,$type,$lauthor,$date,$ltime,$name,$subject,$caption,$lock,$read,$topic_rating,$replies # ***** $name field is the author who started the forum message, $lname is the last person who posted within that message. # # 189|0|JohnDoe|04/25/2010|20:31:02|JohnDoe|Title of Forum Message Here......|Caption of Forum Message here......||130||0 # 183|0|JaneDoe|01/31/2010|19:15:00|JohnDoe|Title of Forum Message Here Again|Caption of Forum Message here again||160||5 # 157|0|JeffDoe|04/05/2011|06:12:29|JohnDoe|Title of Forum Message Here Again|Caption of Forum Message here again||472||2 # # New feature to select only moderator(s) posted messages. # This function and fields have not been implemented. I would like to find the latest three (3) messages # posted by the moderator(s) from the forums selected below and display them together with the moderator's picture. # In summary, the moderator's photo then his 3 messages from the forums, followed by the next moderator and his 3 messages... # # $moderator1 = "JohnDoe"; # $moderator1photo = "JohnDoe.jpg"; # # $moderator2 = "JohnDoe2"; # $moderator2photo = "JohnDoe2.jpg"; # # $moderator3 = "JohnDoe3"; # $moderator3photo = "JohnDoe3.jpg"; # # # Program start... # $cgidir is the location of forum.setup $cgidir = "/home/sites/www.domain.com/web/cgi-bin/forums"; # Requirements... require "$cgidir/forum.setup"; require "$cgilib/forumlib.pl"; # Message select mode # # 0 - randomly choose a forum and display $num_topics # 1 - select limited number of forums... you must define @select_forums # 2 - select from all forums $select_mode = 1; # Which forums? # The forum ID you want to read messages from @select_forums = qw( education history news ); # Select how many topics per forum? $num_topics = 3; # Selection of topics based on? # 0 - Latest date, default # 10 - Most active $sort_by_field = 0; # If most active is chosen, then limit # number of current topics to choose from $num_current = 20; #>>>>>>>>>>>>>>> NO NEED TO EDIT ANYTHING BELOW THIS LINE <<<<<<<< # unbuffer output $| = 1; # initialize some internal variables... # Need to change this for speed improvement $r_setup = initialize(); require "$cgilib/global.pl"; foreach (@{$r_setup->{'forums'}}) { if ($r_setup->{'forum_status'}->{$_} eq "on" and $r_setup->{'forum_type'}->{$_} ne 'Private') { push(@all_forums,$_); } } if ($select_mode == 0) { my $num_forums = @all_forums; srand; my $random_number = int(rand $num_forums) + 1; @select_forums = ($all_forums[$random_number]); } elsif ($select_mode == 2) { @select_forums = @all_forums; } print_header(); print_header_end(); # printing table and messages... print qq~
~; toggle_color("reset"); toggle_color(); # Default header display... print qq~
Most recent:
~; # Read from public forums foreach (@select_forums) { my $r_data = readdata("$maindir/$_/$database"); # chop some topics my @data = @{$r_data}[0..$num_current-1]; # sort topics if ($sort_by_field == 10) { $r_data = sort_topics(\@data,$sort_by_field); } else { $r_data = \@data; } for ($j=0;$j<$num_topics;$j++) { toggle_color(); my $topic = $r_data->[$j]; chomp($topic); my ($num,$type,$lauthor,$date,$ltime,$name,$subject,$caption,$lock, $read,$topic_rating,$replies) = split(/$split_delim/,$topic); $subject = decode($subject); $caption = decode($caption); $caption = substr($caption,0,50); if ($type == 0) { $image = "icon_general.gif"; $imagealt = "Member message"; } elsif ($type == 1) { $image = "icon_poll.gif"; $imagealt = "Poll"; } elsif ($type == 2) { $image = "icon_question.gif"; $imagealt = "Question"; } elsif ($type == 3) { $image = "icon_help.gif"; $imagealt = "Help"; } elsif ($type == 4) { $image = "icon_looking.gif"; $imagealt = "Searching"; } elsif ($type == 5) { $image = "icon_news.gif"; $imagealt = "News"; } else { $image = "icon_anchor.gif"; $imagealt = "Moderator message"; } # Display other information $ltime = time_format($ltime); $datelong = $date; $date = date_format($date); print qq~