[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Problems with message board script. Won't write to filecorrectly.



I'm working on a message board script.  The script is like a normal message
board except it is password protected, you can't post followup's, and when
you are reading a message, you can see the subject's on the next 5 messages
w/links and the subjects of the previous 5 messages w/links.  The only
problem is, I'm happy trouble with the 5 next messages part.

This part of the script opens up the datafile, which contains a number and
then gets the values of all the next numbers.  $first_prev is also equal to
$num.  The script adds 1 to the datafile after the message is posted.
---
# Get Prev & Next

sub get_prev {
   open(NUMBER,"$basedir/$datafile");
   $first_prev = <NUMBER>;
   close(NUMBER);
		$second_prev = ($first_prev - 1);
		$third_prev = ($first_prev - 2);
		$fourth_prev = ($first_prev - 3);
		$fifth_prev = ($first_prev - 4);
		$first_next = ($num + 1);
		$second_next = ($num + 2);
		$third_next = ($num + 3);
		$fourth_next = ($num + 4);
		$fifth_next = ($num + 5);
}
---
This is part of the subroutine where the message is posted.  It makes a
link to the 5 next messages and prints Not Posted Yet as the text for the
link.
---

	print NEWFILE " <CENTER><BR>\n";
	print NEWFILE " <FONT FACE=ARIAL SIZE=+1><B>Next 5
Messages</B></FONT><HR>\n";
	print NEWFILE " <FONT SIZE=-1 FACE=ARIAL>\n";
	print NEWFILE " <A
HREF=\"http://www.M-D-K.com/wicnnewsboard/messages/$fifth_next\.$ext\">\n";
	print NEWFILE " <!--$fifth_next-->Not Posted Yet\n";
	print NEWFILE " </A><p>\n";
	print NEWFILE " <A
HREF=\"http://www.M-D-K.com/wicnnewsboard/messages/$fourth_next\.$ext\">\n";
	print NEWFILE " <!--$fourth_next-->Not Posted Yet\n";
	print NEWFILE " </A><p>\n";
	print NEWFILE " <A
HREF=\"http://www.M-D-K.com/wicnnewsboard/messages/$third_next\.$ext\">\n";
	print NEWFILE " <!--$third_next-->Not Posted Yet\n";
	print NEWFILE " </A><p>\n";
	print NEWFILE " <A
HREF=\"http://www.M-D-K.com/wicnnewsboard/messages/$second_next\.$ext\">\n";
	print NEWFILE " <!--$second_next-->Not Posted Yet\n";
	print NEWFILE " </A><p>\n";
	print NEWFILE " <A
HREF=\"http://www.M-D-K.com/wicnnewsboard/messages/$first_next\.$ext\">\n";
	print NEWFILE " <!--$first_next-->Not Posted Yet\n";
	print NEWFILE " </A><p>\n";
	print NEWFILE " </FONT>\n";
---
This part of the script opens up the previous messages, where it says Not
Posted Yet, it changes it to the subject of the current message.  The first
subroutine is supposed to open up the previous message and place the
subject where it says <!--$first_next-->Not Posted Yet.  Which should be
the bottom "next" link in that post.  Same with the subroutine
second_prev_page.  Except the subject for that message should be placed as
the second link from the bottom of the "next" links.
---
# Add Subject into Previous Messages

sub first_prev_page {
   open(FIRST,"$basedir/$mesgdir/$first_prev\.$ext") || die $!;
   @first = <FIRST>;
   close(FIRST);

   open(FIRST,">$basedir/$mesgdir/$first_prev\.$ext") || die $!;
   if ($followup == 0) {
      foreach $first_line (@first) {
         if ($first_line =~ /<!--$first_next-->Not Posted Yet/) {
               print FIRST "<!--$first_next-->\n";
               print FIRST "$subject\n";
               print FIRST "<!--end$first_next-->\n";
         } else {
            print FIRST "$first_line";
						}
         }
    }
   close(FIRST);
}
###
sub second_prev_page {
   open(SECOND,"$basedir/$mesgdir/$second_prev\.$ext") || die $!;
   @second = <SECOND>;
   close(SECOND);

   open(SECOND,">$basedir/$mesgdir/$second_prev\.$ext") || die $!;
   if ($followup == 0) {
      foreach $second_line (@second) {
         if ($second_line =~ /<!--$second_next-->Not Posted Yet/) {
			print SECOND "<!--$second_next-->\n";
			print SECOND "$subject\n";
			print SECOND "<!--end$second_next-->\n";
				         } else {
            print SECOND "$second_line";
						}
					}
				}
   close(SECOND);
}
###
sub third_prev_page {
   open(THIRD,"$basedir/$mesgdir/$third_prev\.$ext") || die $!;
   @third = <THIRD>;
   close(THIRD);

   open(THIRD,">$basedir/$mesgdir/$third_prev\.$ext") || die $!;
   if ($followup == 0) {
      foreach $third_line (@third) {
         if ($third_line =~ /<!--$third_next-->Not Posted Yet/) {
		print THIRD "<!--$third_next-->\n";
		print THIRD "$subject\n";
		print THIRD "<!--end$third_next-->\n";

            } else {
            print THIRD "$third_line";
							}
					}
				}
   close(THIRD);
}
###
sub fourth_prev_page {
   open(FOURTH,"$basedir/$mesgdir/$fourth_prev\.$ext") || die $!;
   @fourth = <FOURTH>;
   close(FOURTH);

   open(FOURTH,">$basedir/$mesgdir/$fourth_prev\.$ext") || die $!;
   if ($followup == 0) {
      foreach $fourth_line (@fourth) {
         if ($fourth_line =~ /<!--$fourth_next-->Not Posted Yet/) {
			print FOURTH "<!--$fourth_next-->\n";
			print FOURTH "$subject\n";
			print FOURTH "<!--end$fourth_next-->\n";
         } else {
            print FOURTH "$fourth_line";
						}
					}
				}
   close(FOURTH);
}
###
sub fifth_prev_page {
   open(FIFTH,"$basedir/$mesgdir/$fifth_prev\.$ext") || die $!;
   @fifth = <FIFTH>;
   close(FIFTH);

   open(FIFTH,">$basedir/$mesgdir/$fifth_prev\.$ext") || die $!;
   if ($followup == 0) {
      foreach $fifth_line (@fifth) {
         if ($fifth_line =~ /<!--$fifth_next-->Not Posted Yet/) {
			print FIFTH "<!--$fifth_next-->\n";
			print FIFTH "$subject\n";
			print FIFTH "<!--end$fifth_next-->\n";

         } else {
            print FIFTH "$fifth_line";
						}
					}
				}
   close(FIFTH);
}
---
Does anyone get this?  If you go to http://www.M-D-K.com/testboard/ you can
see an example of this.  Open up one of the messages.  Then look at a
previous message.  Also, the next/previous messages links do not work.
Where the URL says wicnnewsboard, replace it with testboard.  This is just
because as soon as it works I'm going to move it to the wicnnewsboard
directory.

Matt Kraft
MDK@M-D-K.com



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch