R
Robin
Ok, here's the thing, when it prints the comments for the blog, it prints
each one twice, it's under sub view after if (url_param ('action2') eq
"showcomment")... I was thinking it was a problem with my getcomments sub,
but that returns the right ammount of comments... the posts in the blog are
put into blog.txt as the same format as the comments except the first string
before $splitstring is a incrementing number, starting at zero, and going
up, the counter is contained in count or counter (I forget) .txt. I dunno
what other information to give.
Why is it printing the comments twice, underneath the posts?
If you need more of this code, let me know.
Thanks.
--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]
www.infusedlight.net
sub view
{
my ($output, $modcommentpost) = @_;
if ($action eq "comment")
{
if (param ('commenttext') and param ('commenttext') !~ /<.*>/ and param
('commenttext') !~ /^\s*$/ and param ('commenttext') !~ /$splitstring/ and
param ('commenttext') ne "Post" and param ('commenttext') ne "Comment")
{
open (BLOG, ">>$blogfile") or print header and print "An error
occured during this operation: <b>$!</b>. Please press the back button on
your browser and try again.<hr>" and exit;
flock (BLOG, LOCK_EX);
print BLOG (url_param('count'), $splitstring, "Comment",
$splitstring, "<strong>Comment:</strong><br>", param ('commenttext'));
print BLOG ("\n");
close (BLOG);
print redirect
("$rootfile?action=view&action2=showcomment&output=Your+comment+has+been+pos
ted+and+is+being+viewed&count=" . url_param ('count'));
exit;
}
else
{
print redirect
("$rootfile?action=view&output=You+did+not+supply+the+post+or+you+used+HTML+
tags+which+are+not+allowed+on+this+system.");
exit;
}
}
if (url_param ('action2') eq "hidecomment")
{
print redirect
("$rootfile?action=view&output=Comment+has+been+hidden");
exit;
}
my @posts;
@posts = getposts();
my $posttotal;
$posttotal = getposttot();
print header;
print @head;
print <<END;
<div align="center">
<p>Blogger $version - $output </p>
<hr>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr> <td width="60%" align="left" valign="top"
bgcolor="#FFFF00"><p><strong>Total posts - $posttotal</strong></p>
END
my $post;
my @postsplit;
my @comments;
my @commentsplit;
my $comment;
if (@posts)
{
if (url_param ('action2') eq "showcomment")
{
my $post1;
@comments = getcomments (url_param ('count'));
foreach $post1 (@posts)
{
@postsplit = split (/$splitstring/, $post1);
print $postsplit[2], "<br>", "[ <a
href=\"$rootfile?action=view&action2=showcomment&count=$postsplit[0]\">Show
comments</a> ] [ <a href=\"$rootfile?action=view&action2=hidecomment\">Hide
comments</a> ] [ <a
href=\"$rootfile?action=newcomment&count=$postsplit[0]\">New comment</a> ]
[ <a href=\"$rootfile?action=printnewpost\">New post</a> ]<br><br>" if
($postsplit[1] eq "Post");
foreach $comment (reverse @comments)
{
@commentsplit = split (/$splitstring/, $comment);
print "<blockquote>", $commentsplit[2], "</blockquote>"
if ($postsplit[0] eq $commentsplit[0]);
}
}
}
else
{
foreach $post (reverse @posts)
{
@postsplit = split (/$splitstring/, $post);
print $postsplit[2], "<br>", "[ <a
href=\"$rootfile?action=view&action2=showcomment&count=$postsplit[0]\">Show
comments</a> ] [ <a href=\"$rootfile?action=view&action2=hidecomment\">Hide
comments</a> ] [ <a
href=\"$rootfile?action=newcomment&count=$postsplit[0]\">New comment</a> ]
[ <a href=\"$rootfile?action=printnewpost\">New post</a> ]<br><br>" if
($postsplit[1] eq "Post");
}
}
}
else
{
print "No posts";
}
print <<END;
<td width="40%" align="left" valign="top">$modcommentpost</td>
</tr>
</table>
<hr><center>[ <a href="$rootfile?action=printnewpost">New
post</a> ]</center>
</div>
END
print @foot;
exit;
}
sub getposts
{
my @poststoreturn;
if (-e $blogfile)
{
open (BLOG, $blogfile) or print header and print "An error occured
during this operation: <b>$!</b>. Please press the back button on your
browser and try again.<hr>" and exit;
flock (BLOG, LOCK_SH);
while (<BLOG>)
{
push (@poststoreturn, $_);
}
close (BLOG);
chomp (@poststoreturn);
return @poststoreturn;
}
else
{
return undef;
}
}
sub getcomments
{
my ($commentcount1) = @_;
my (@comments2, $comm, @commsplit, @commtoret);
@comments2 = getposts ();
foreach $comm (@comments2)
{
@commsplit = split (/$splitstring/, $comm);
if ($commsplit[0] eq $commentcount1 and $commsplit[1] eq "Comment")
{
push (@commtoret, $comm);
}
}
return (@commtoret);
}
each one twice, it's under sub view after if (url_param ('action2') eq
"showcomment")... I was thinking it was a problem with my getcomments sub,
but that returns the right ammount of comments... the posts in the blog are
put into blog.txt as the same format as the comments except the first string
before $splitstring is a incrementing number, starting at zero, and going
up, the counter is contained in count or counter (I forget) .txt. I dunno
what other information to give.
Why is it printing the comments twice, underneath the posts?
If you need more of this code, let me know.
Thanks.
--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]
www.infusedlight.net
sub view
{
my ($output, $modcommentpost) = @_;
if ($action eq "comment")
{
if (param ('commenttext') and param ('commenttext') !~ /<.*>/ and param
('commenttext') !~ /^\s*$/ and param ('commenttext') !~ /$splitstring/ and
param ('commenttext') ne "Post" and param ('commenttext') ne "Comment")
{
open (BLOG, ">>$blogfile") or print header and print "An error
occured during this operation: <b>$!</b>. Please press the back button on
your browser and try again.<hr>" and exit;
flock (BLOG, LOCK_EX);
print BLOG (url_param('count'), $splitstring, "Comment",
$splitstring, "<strong>Comment:</strong><br>", param ('commenttext'));
print BLOG ("\n");
close (BLOG);
print redirect
("$rootfile?action=view&action2=showcomment&output=Your+comment+has+been+pos
ted+and+is+being+viewed&count=" . url_param ('count'));
exit;
}
else
{
print redirect
("$rootfile?action=view&output=You+did+not+supply+the+post+or+you+used+HTML+
tags+which+are+not+allowed+on+this+system.");
exit;
}
}
if (url_param ('action2') eq "hidecomment")
{
print redirect
("$rootfile?action=view&output=Comment+has+been+hidden");
exit;
}
my @posts;
@posts = getposts();
my $posttotal;
$posttotal = getposttot();
print header;
print @head;
print <<END;
<div align="center">
<p>Blogger $version - $output </p>
<hr>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr> <td width="60%" align="left" valign="top"
bgcolor="#FFFF00"><p><strong>Total posts - $posttotal</strong></p>
END
my $post;
my @postsplit;
my @comments;
my @commentsplit;
my $comment;
if (@posts)
{
if (url_param ('action2') eq "showcomment")
{
my $post1;
@comments = getcomments (url_param ('count'));
foreach $post1 (@posts)
{
@postsplit = split (/$splitstring/, $post1);
print $postsplit[2], "<br>", "[ <a
href=\"$rootfile?action=view&action2=showcomment&count=$postsplit[0]\">Show
comments</a> ] [ <a href=\"$rootfile?action=view&action2=hidecomment\">Hide
comments</a> ] [ <a
href=\"$rootfile?action=newcomment&count=$postsplit[0]\">New comment</a> ]
[ <a href=\"$rootfile?action=printnewpost\">New post</a> ]<br><br>" if
($postsplit[1] eq "Post");
foreach $comment (reverse @comments)
{
@commentsplit = split (/$splitstring/, $comment);
print "<blockquote>", $commentsplit[2], "</blockquote>"
if ($postsplit[0] eq $commentsplit[0]);
}
}
}
else
{
foreach $post (reverse @posts)
{
@postsplit = split (/$splitstring/, $post);
print $postsplit[2], "<br>", "[ <a
href=\"$rootfile?action=view&action2=showcomment&count=$postsplit[0]\">Show
comments</a> ] [ <a href=\"$rootfile?action=view&action2=hidecomment\">Hide
comments</a> ] [ <a
href=\"$rootfile?action=newcomment&count=$postsplit[0]\">New comment</a> ]
[ <a href=\"$rootfile?action=printnewpost\">New post</a> ]<br><br>" if
($postsplit[1] eq "Post");
}
}
}
else
{
print "No posts";
}
print <<END;
<td width="40%" align="left" valign="top">$modcommentpost</td>
</tr>
</table>
<hr><center>[ <a href="$rootfile?action=printnewpost">New
post</a> ]</center>
</div>
END
print @foot;
exit;
}
sub getposts
{
my @poststoreturn;
if (-e $blogfile)
{
open (BLOG, $blogfile) or print header and print "An error occured
during this operation: <b>$!</b>. Please press the back button on your
browser and try again.<hr>" and exit;
flock (BLOG, LOCK_SH);
while (<BLOG>)
{
push (@poststoreturn, $_);
}
close (BLOG);
chomp (@poststoreturn);
return @poststoreturn;
}
else
{
return undef;
}
}
sub getcomments
{
my ($commentcount1) = @_;
my (@comments2, $comm, @commsplit, @commtoret);
@comments2 = getposts ();
foreach $comm (@comments2)
{
@commsplit = split (/$splitstring/, $comm);
if ($commsplit[0] eq $commentcount1 and $commsplit[1] eq "Comment")
{
push (@commtoret, $comm);
}
}
return (@commtoret);
}