#!/usr/bin/perl ######################################### # comment # redundant w/ post: add a comment/files to a thread ######################################### use localbucky; my $pid; $dbh = DBI->connect ($dsn); our ($USER, $lastlog) = checkin(); logout() unless ($USER != -1); $input->{id} ||= $input->{object_from_uri} if defined($input->{object_from_uri}); $input->{id} =~ s/\D*//g; if ($input->{c} eq "edit") { my $header_args; my $comment = get_comment($input->{id}); error("No such comment!") if ($comment == -1); my $thread = get_thread($comment->{thread}); my $keyword = get_keyword($thread->{keyword}); error("Cannot edit comment!") unless ($USER->{username} eq $BUCKY_ADMINISTRATOR || $USER->{username} eq $comment->{username} || (check_key($thread->{display}, "editable") && check_privacy($thread, $keyword))); $header_args->{title} = qq(editing comment . . .); $header_args->{subtitle} = qq(back to post · $thread->{title}), $header_args->{color} = "ivory"; header ($header_args); menu(); print <
duh curt_post_form($comment); print qq!\n!; footer(); } elsif ($input->{c} eq "delete") { my $header_args; my $comment = get_comment($input->{id}); error("No such comment!") if ($comment == -1); my $thread = get_thread($comment->{thread}); my $keyword = get_keyword($thread->{keyword}); error("Cannot delete comment!") unless ($USER->{username} eq $BUCKY_ADMINISTRATOR || $USER->{username} eq $comment->{username} || (check_key($thread->{display}, "editable") && check_privacy($thread, $keyword))); if ($input->{ok} eq "yes") { delete_comment($comment->{id}); redirect("$BUCKY/".details_link($thread)."/$comment->{thread}".get_revision($thread)); } else { $header_args->{title} = qq(delete comment?); $header_args->{subtitle} = qq(back to post ($thread->{title})); $header_args->{color} = "ivory"; header ($header_args); menu(); print qq!

Are you sure you want to !; print qq!delete this comment?

\n!; my $subcomment = substr($comment->{comment}, 0, 64); $subcomment =~ s//>/g; $subcomment =~ s/"/"/g; print "

".$subcomment."

"; print qq!
!; print qq(\n); print qq(\n); print qq(\n) if ($DEBUG); print qq(\n); print qq(
); print qq(\n); footer(); } } elsif ($input->{c} eq "reply") { my $header_args; my $comment = -1; my $thread = -1; my $keyword = -1; if (exists($input->{id})) { $comment = get_comment($input->{id}); error("No such comment!") if ($comment == -1); $thread = get_thread($comment->{thread}); } elsif (exists($input->{thread})) { $thread = get_thread($input->{thread}); } my $keyword = get_keyword($thread->{keyword}); error("Cannot see comment!") unless (check_privacy($thread) || check_op($keyword)); $header_args->{title} = qq(reply to comment . . .); $header_args->{subtitle} = qq(back to post · $thread->{title}); $header_args->{color} = "ivory"; header ($header_args); menu(); print <
duh curt_reply_form($comment, $thread, $keyword); print qq!\n!; footer(); } elsif ($input->{c} eq "update") { my $comment = get_comment($input->{id}); error("No such comment!") if ($comment == -1); my $thread = get_thread($comment->{thread}); my $keyword = get_keyword($thread->{keyword}); error("Cannot edit comment!") unless ($USER->{username} eq $BUCKY_ADMINISTRATOR || $USER->{username} eq $comment->{username} || (check_key($thread->{display}, "editable") && check_privacy($thread, $keyword))); update_comment($input->{id}, $input->{comment}) if ($input->{comment}); touch_thread($thread); if ($comment->{thread} == 1) { redirect("$BUCKY/index"); } else { redirect("$BUCKY/".details_link($thread)."/$comment->{thread}".get_revision($thread)); } } elsif ($input->{id} == 1) { add_comment($input->{id}, -1, $USER->{username}, $input->{comment}) if ($input->{comment}); redirect("$BUCKY/index"); } else { my $pid; my $t; my $keyword; if ($DEBUG) { header ("adding message to $input->{id}"); print "adding message to $input->{id}:

"; } $t = get_thread($input->{id}); if ($t == -1) { flush_files(); redirect("$BUCKY/".details_link($t)."/$comment->{thread}".get_revision($t)); } $keyword = get_keyword($thread->{keyword}); # error("No such thread!") unless ($t != -1 && check_privacy($t, $keyword)); if (exists($input->{parent_id})) { my $headc = get_comment($input->{parent_id}); error("No such comment!") if ($headc == -1); if ($headc->{parent_id} != -1) { $pid = $headc->{parent_id}; } else { $pid = $headc->{id}; } } else { $pid = -1; } add_comment($t->{id}, $pid, $USER->{username}, $input->{comment}) if ($input->{comment}); situate_files($t->{id}, $USER->{username}); touch_thread($t); redirect("$BUCKY/".details_link($t)."/$t->{id}".get_revision($t)); switch_file_privacy($t->{id}, $t->{private}); } if ($DEBUG) { footer (); } $dbh->disconnect (); print "Comment: " . &report_time() . "\n" if $timer;