summaryrefslogtreecommitdiff
path: root/cgi-bin/comment
diff options
context:
space:
mode:
Diffstat (limited to 'cgi-bin/comment')
-rwxr-xr-xcgi-bin/comment186
1 files changed, 186 insertions, 0 deletions
diff --git a/cgi-bin/comment b/cgi-bin/comment
new file mode 100755
index 0000000..01a763b
--- /dev/null
+++ b/cgi-bin/comment
@@ -0,0 +1,186 @@
+#!/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(<span class="lite"><a href="$BUCKY/).details_link($thread).qq(/$comment->{thread}">back to post</a> &middot; $thread->{title}</span>),
+ $header_args->{color} = "ivory";
+
+ header ($header_args);
+ menu();
+ print <<duh;
+<table width=100% border=0 cellpadding=0 cellspacing=5>
+<tr><td align=center valign=top width=100%><div style="width: 399px;">
+duh
+ curt_post_form($comment);
+ print qq!</td></tr></table>\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(<span class="lite"><a href="$BUCKY/).details_link($thread).qq(/$comment->{thread}">back to post</a> ($thread->{title})</span>);
+ $header_args->{color} = "ivory";
+
+ header ($header_args);
+ menu();
+ print qq!<center><p><div class="bluebox" style="width: 320px; padding: 10px;"><big><b>Are you sure you want to !;
+ print qq!delete this comment?</b></big><hr noshade color="$BUCKY_COLOR_HR"><p>\n!;
+ my $subcomment = substr($comment->{comment}, 0, 64);
+ $subcomment =~ s/</&lt;/g;
+ $subcomment =~ s/>/&gt;/g;
+ $subcomment =~ s/"/&quot;/g;
+ print "<p>".$subcomment."</p>";
+ print qq!<form action="$BUCKY/comment" method="post" enctype="multipart/form-data">!;
+ print qq(<input type=hidden name="c" value="delete">\n);
+ print qq(<input type=hidden name="id" value="$comment->{id}">\n);
+ print qq(<input type=hidden name="debug" value="1">\n) if ($DEBUG);
+ print qq(<input type=hidden name="ok" value="yes">\n);
+
+ print qq(<br><input type="submit" value="DELETE" class="clicky"></form></div></center>);
+ print qq(</td></tr></table>\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(<span class="lite"><a href="$BUCKY/).details_link($thread).qq(/$comment->{thread}">back to post</a> &middot; $thread->{title}</span>);
+ $header_args->{color} = "ivory";
+
+ header ($header_args);
+ menu();
+ print <<duh;
+<table width=100% border=0 cellpadding=0 cellspacing=5>
+<tr><td align=center valign=top width=100%><div style="width: 399px;">
+duh
+ curt_reply_form($comment, $thread, $keyword);
+ print qq!</td></tr></table>\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}:<p><tt>";
+ }
+
+ $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;