#!/usr/bin/perl ######################################### # post # - create a new thread/post from an initial file # - form: append multiple files ######################################### use localbucky; my $pid; $dbh = DBI->connect ($dsn); our ($USER, $lastlog) = checkin(); logout() unless ($USER != -1); if ($input->{c} eq 'new') { new_post_action(); } elsif ($input->{c} eq 'reply') { reply_post_action(); } else { long_post_form(); } ################################# sub long_post_form { my $t = -1; my $k = -1; if ( exists($input->{thread}) ) { my $header_args; $t = get_thread( $input->{thread} ); $k = get_keyword( $t->{keyword} ); error("No such post!") unless ($t != -1); error("No such keyword!") unless ($k == -1 || ($k->{public} || check_op($k))); $header_args->{title} = qq(reply to $t->{title}); $header_args->{subtitle} = qq(return to post); header ($header_args); } elsif ( exists($input->{keyword}) ) { my $header_args; $k = get_keyword( $input->{keyword} ); if ($k != -1 && (($k->{public} || check_op($k)))) { $header_args->{title} = qq(new $k->{keyword}); $header_args->{subtitle} = qq(return to $BUCKY_LEXICON_KEYWORD); header ($header_args); } else { header("Creating a new post..."); } } else { header("Creating a new post..."); } menu(); print "

\n\n"; my $checked = ''; print qq(

\n); print qq!\n\n! if ($DEBUG); print <
FORMmid if ($t != -1) { print qq!!; print qq!!; print qq!
replying to:$t->{title}
posted !.verbosedate($t->{createdate}).qq! by $t->{username}
!; } else { print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!
!; print qq!title: !; print qq!!; print qq!
\n!; print qq!
!; print "category: "; print qq!!; if ($k->{public} || check_op($k)) { keyword_pulldown($k->{keyword}); $checked = $k->{public} ? "" : " checked"; } else { keyword_pulldown(); } print qq!
!; print qq!tags: !; print qq!!; print qq!
\n!; print qq!
!; print qq!publicity:!; print qq!!; # don't need this # print qq!! privacy_select("private", $checked); print qq!
!; print qq!(can be changed at any time via post settings)\n!; print qq!
!; print qq!
!; print qq!!; } print qq!
!; print qq!

\n!; if (! check_key($t->{display}, "no-upload")) { print <

FORMEND } print qq(
); # if ($t != -1) # { print qq(remember! you can always use ftp to upload files . . .); } # else # { print qq(remember! you can always use ftp to upload files . . .); } print " "; print <

FORMEND footer(); } sub new_post_action { my $files; my $title = ''; my $private = 0; my $k; $k = get_keyword($input->{keyword}) if (exists($input->{keyword}) && ($input->{keyword} ne "NONE")); if ($input->{title}) { $title = $input->{title}; $title =~ s/^\s+//; $title =~ s/\s+/ /g; $title =~ s/_/ /g; } else { for (my $i = 1; $i < 10; $i++) { if ($input->{"file".$i} ne "temp_") { $title = $input->{"file".$i}; $i = 11; } } if ($title) { $title =~ s/^temp_//i; $title =~ s/\.....?$//; $title =~ s/^\s+//; $title =~ s/\s+/ /g; $title =~ s/_/ /g; } elsif ($$input{"comment"}) { $title = "dER buCKYiSt ***cHaTTEN**** AUF ZZem *AwL**"; } else { error ("No title specified!"); } } if ($DEBUG) { header("new post"); print "attempting to make a new post: $title

"; } $private = $input->{private} if ($input->{private}); $thread_id = add_thread($title, $USER->{username}, $private); print "id: $thread_id

" if ($DEBUG); add_comment($thread_id,-1,$USER->{username},$$input{comment}); situate_files($thread_id, $USER->{username}); switch_thread_privacy($thread_id, $private); if ($k->{public} || check_op($k)) { keyword_assign_mechanism($k->{keyword}, $thread_id, $k); } # Check for any supplied tags if (exists($input->{tags}) && (length(trim($input->{tags}) ) > 0) ) { # Unpack tags from the form text field (remove delimiters, retrieve already existing tags, # create new tags my $tags = get_tags_from_string( $input->{tags} ); # Loop through each tag foreach my $tag (@$tags) { # should we even get this?? # next unless ($tag->{public} || check_op($tag)); # Associate this tag with this thread tag_assign_mechanism( $tag, $thread_id ); } } if ($DEBUG) { print qq{this way to your new post: link!}; footer(); } if ($k != -1) { redirect("$BUCKY/".details_link($k)."/$thread_id"); } else { redirect("$BUCKY/$BUCKY_LEXICON_DETAILS/$thread_id"); } } sub reply_post_action { if ($DEBUG) { header("posting to $input->{thread}"); } my $thread = (exists($input->{thread})) ? get_thread($input->{thread}) : error("No such thread!"); my $keyword = ($thread->{keyword}) ? get_keyword($thread->{keyword}) : -1; error("Cannot see comment!") unless (check_privacy($thread) || check_op($keyword)); print "id: $thread->{id}

" if ($DEBUG); add_comment($thread->{id}, -1, $USER->{username}, $input->{comment}) if ($input->{comment} ne undef); situate_files($thread->{id}, $USER->{username}); switch_thread_privacy($thread->{id}, $thread->{private}); redirect("$BUCKY/".details_link($thread)."/$thread->{id}"); } $dbh->disconnect (); print "Post: " . &report_time() . "\n" if $timer;