diff options
Diffstat (limited to 'cgi-bin/post')
| -rwxr-xr-x | cgi-bin/post | 267 |
1 files changed, 267 insertions, 0 deletions
diff --git a/cgi-bin/post b/cgi-bin/post new file mode 100755 index 0000000..fd2de78 --- /dev/null +++ b/cgi-bin/post @@ -0,0 +1,267 @@ +#!/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(<span class="lite"><a href="$BUCKY/).details_link($t).qq($t->{id}">return to post</a></span>); + + 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(<span class="lite"><a href=").keyword_link($k).qq(">return to $BUCKY_LEXICON_KEYWORD</a></span>); + header ($header_args); + } + else + { + header("Creating a new post..."); + } + } + else + { + header("Creating a new post..."); + } + + menu(); + print "<p>\n\n"; + my $checked = ''; + + print qq(<form action="$BUCKY/post" method="post" enctype="multipart/form-data">\n); + print qq!<input type="hidden" name="debug" value="$DEBUG">\n\n! if ($DEBUG); + + print <<FORMmid; +<center> +<table cellpadding=0 cellspacing=0 border=0> +<tr><td class="bluebox" style="padding: 20px 40px 20px 40px;"> +FORMmid + + if ($t != -1) + { + print qq!<input type="hidden" name="c" value="reply">!; + print qq!<input type="hidden" name="thread" value="$t->{id}">!; + print qq!<table border=0 width=100%><tr><td style="text-align: right; vertical-align: center;">replying to:</td><td align="center"><b><big><a href="$BUCKY/!.details_link($t).qq!/$t->{id}">$t->{title}</a></big></b><br>posted !.verbosedate($t->{createdate}).qq! by <a href="$BUCKY/profile/$t->{username}">$t->{username}</a></td></tr></table>!; + } + else + { + print qq!<table cellpadding=2 border=0>!; + print qq!<tr><td align="right" valign="baseline">!; + print qq!title: !; + print qq!</td><td align="left" valign="baseline">!; + print qq!<input name="title" value="" size=48 maxlength=48><br>\n!; + print qq!</tr>!; + print qq!<tr><td align="right" valign="baseline">!; + print "category: "; + print qq!</td><td align="left" valign="baseline">!; + if ($k->{public} || check_op($k)) + { + keyword_pulldown($k->{keyword}); + $checked = $k->{public} ? "" : " checked"; + } + else + { keyword_pulldown(); } + print qq!</tr>!; + print qq!<tr><td align="right" valign="baseline">!; + print qq!tags: !; + print qq!</td><td align="left" valign="baseline">!; + print qq!<input name="tags" value="" size=30 maxlength=48><br>\n!; + print qq!</tr>!; + print qq!<tr><td align="right" valign="middle">!; + print qq!publicity:!; + print qq!</td><td align="left" valign="middle">!; + # don't need this + # print qq!<input type=checkbox name="private" value="1"$checked>! + privacy_select("private", $checked); + print qq!</td></tr>!; + print qq!<tr><td></td><td align="left" valign="top">!; + print qq!<small>(can be changed at any time via post settings)</small>\n!; + print qq!</td></tr>!; + print qq!<tr><td align="right" valign="baseline">!; + print qq!</table>!; + print qq!<input type="hidden" name="c" value="new">!; + } + + print qq!<hr color="$BUCKY_COLOR_HR" size=1>!; + print qq!<p><textarea name="comment" cols="52" rows="16"></textarea><p>\n!; + + if (! check_key($t->{display}, "no-upload")) + { + print <<FORMEND; +<input type="file" name="file1" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /> <input type="file" name="file2" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /> <input type="file" name="file3" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /><br> +<input type="file" name="file4" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /> <input type="file" name="file5" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /> <input type="file" name="file6" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /><br> +<input type="file" name="file7" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /> <input type="file" name="file8" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /> <input type="file" name="file9" size="12" maxlength="192" style="font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;" /><p> +FORMEND + } + print qq(<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td width=90% align="center"><small>); +# if ($t != -1) +# { print qq(remember! you can always use <a href="$BUCKY/import?id=$t->{id}"><u><b>ftp</b></u></a> to upload files . . .); } +# else +# { print qq(remember! you can always use <a href="$BUCKY/import"><u><b>ftp</b></u></a> to upload files . . .); } + print " "; + print <<FORMEND; +</small></td> +<td align="left"><input type="submit" value="POST" class="clicky"></td></tr></table> +</form> +</td></tr></table> +</center> +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<p>"; + } + + $private = $input->{private} if ($input->{private}); + + $thread_id = add_thread($title, $USER->{username}, $private); + print "id: $thread_id<p>" 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: <a href="$BUCKY/details/$thread_id">link!</a>}; + 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}<p>" 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; |
