diff options
Diffstat (limited to 'cgi-bin/details')
| -rwxr-xr-x | cgi-bin/details | 275 |
1 files changed, 275 insertions, 0 deletions
diff --git a/cgi-bin/details b/cgi-bin/details new file mode 100755 index 0000000..35b34c7 --- /dev/null +++ b/cgi-bin/details @@ -0,0 +1,275 @@ +#!/usr/bin/perl +######################################## +# details +######################################### + +use localbucky; + +$dbh = DBI->connect ($dsn); + +our ($USER, $lastlog) = checkin(); +our $loggedin = ($USER != -1); + +our ($t, $kw, $files, $comments) = details_init(); +details_run($t, $kw, $files, $comments); + +sub details_init + { + $input->{id} ||= $input->{object_from_uri} if defined($input->{object_from_uri}); + my $id = exists($input->{id}) ? $input->{id} : error("No such thread!"); + + my $t = get_thread($id); + error("No such post.") if ($t == -1); + my $kw = get_keyword($t->{keyword}); + + my $files = get_files($t->{id}); + my $comments = get_comments ($t->{id}); + + if ( ! check_privacy($t, $kw) ) # || check_participation($files, $comments) ) + #unless ( check_privacy($t, $kw) || check_participation($files, $comments) ) + { error("No such post!"); } + + # Reset NULL viewed + if ( ! $t->{viewed} ) + { $t->{viewed} = 0; } + + # Increment viewed for this thread + $t->{viewed}++; + # Update thread viewed count + update_thread_viewed( $t->{id}, $t->{viewed} ); + + return ($t, $kw, $files, $comments); + } + +sub details_run + { + my ($t, $kw, $files, $comments) = @_; + my $header_args = + { + title => $t->{title}, + sticky => $t->{keyword}, + color => get_color($t, $kw, $comments) +# participation => check_participation($files, $comments) + }; + + my $age = get_age($t->{lastmodified}); + $age .= " ago" unless $age eq "now"; + + $header_args->{subtitle} = + qq!posted by <a href="$BUCKY/profile/$t->{username}">$t->{username}</a> on ! . + verbosedate($t->{createdate}) . " · active " . $age . + qq! · $t->{viewed} view! . courtesy_s($t->{viewed}); + + if ($t->{username} eq $USER->{username} || check_op($kw) || $header_args->{participation} == 2 || $USER->{ulevel} == 3) + { + $header_args->{subtitle} .= qq! · !; + $header_args->{subtitle} .= qq!<a href="$BUCKY/maintain/$t->{id}">options</a>!; + } +# else +# { +# $header_args->{subtitle} .= +# qq! · <a href="$BUCKY/index">go to <b>index</b></a>!; +# } + + $header_args->{subtitle} .= qq! · !; + $header_args->{subtitle} .= qq!<span class="lite"><a href="scp://$BUCKY_FTP_USER\@$BUCKY_FTP_HOST/var/bucky/$t->{id}">download\!</a></span>!; + + my @participants = get_participants($t, $files, $comments); + + $header_args->{sidetitle} = details_participation(@participants) + if (@participants > 0); + $header_args->{sidesubtitle} = "<small><i>see also:</i> ".details_tags_box($t, $kw)."</small>" + if (@{$t->{tags}}); + + header($header_args); + + # 20070903 - marc - new menu args calling style + my $menu_args; + $menu_args->{keywords} = $kw if $kw; + $menu_args->{ftp} = 1 if ($t->{files}+$t->{comments} + 1); + menu( $menu_args ); + + details_view($t, $kw, $comments, $files); + footer(); + } + + +############################## + +sub details_view + { + my ($t, $kw, $comments, $files) = @_; + my ($many_jpgs, $flagged) = find_jpeg_v2($files, $t->{flagged}); + if ($many_jpgs > 6) + { + print qq(<center><table border=0 cellpadding=0 cellspacing=0 width="100%">); + } + else + { + print qq(<center><table border=0 cellpadding=0 cellspacing=0>); + } + + print qq(<tr><td align=right valign=top width=440>); + print qq(<table class="commentbox" cellpadding=0 cellspacing=0 border=0 width=440>); + + if ($flagged != -1 && $many_jpgs > 1) + { + print qq(<td align=center valign=middle colspan=2>); + print_flagged_jpeg($flagged); + print qq(</td></tr>); + } + + sideshow_comments({ thread => $t, keyword => $kw, comments => $comments }); + print qq(<tr><td align=center valign=top colspan=2>); + reply_form($t->{id}, $t); + print qq(</td></tr>); + print qq(</table>); + + if ($flagged != -1 && $many_jpgs == 1) + { + print qq(<td align=left valign=top colspan=2 style="padding: 10px;">); + print_flagged_jpeg($flagged); + } + elsif ($many_jpgs > 1 || @$files > $many_jpgs) + { + print qq(<td align=left valign=top style="padding-left: 5px;">); + } + else + { + print qq(<td align=left valign=top style="padding-left: 5px;">); + } + if ($many_jpgs > 1) + { + if ($many_jpgs < 6) # && @$files == $many_jpgs) + { image_column($files, $flagged, $many_jpgs); } + else + { image_gallery($files, $flagged, $many_jpgs); } + } + if (@$files > $many_jpgs) + { + if (find_mp3($files)) + { + my $z_playlist = "/cgi-bin/bucky/playlist/$t->{id}"; + my $z_autoplay = "false"; + if (check_key($USER->{boxes}, "autoplay")) + { $z_autoplay = "true"; } + print <<__PLAYLIST__; + <div id='mp3player'>LOADING MP3 PLAYER ...</div> + +<script type="text/javascript" src="/js/swfobject1.js"></script> +<script type="text/javascript"> + var s2 = new SWFObject("/mediaplayer.swf", "playlist", "392", "200", "7"); + s2.addVariable("file","$z_playlist"); + s2.addVariable("shuffle","false"); + s2.addVariable("backcolor","0xEEEEEE"); + s2.addVariable("frontcolor","0x111111"); + s2.addVariable("lightcolor","0x444444"); + s2.addVariable("displayheight","0"); + s2.addVariable("width","392"); + s2.addVariable("height","200"); + s2.addVariable("volume","50"); + s2.addVariable("autostart","$z_autoplay"); + s2.write("mp3player"); +</script> +__PLAYLIST__ + } + if (check_key($t->{display}, "nfl")) # no file list + { ; } + elsif (check_key($t->{display}, "ffl")) # full file list + { + file_list($files, 0, 1, 0); + } + else # "terse" file list + { + file_list($files, 0, 1, $many_jpgs); + } + } + if ($ZIP_BUTTON_ENABLED && @$files > 4) + { + zip_this_button($t); + } + + details_keywords_box($t, $kw); + print "</td>"; + + print qq(</tr></table></center>); + } + +sub find_mp3 + { + my ($q) = @_; + foreach my $f (@$q) + { return 1 if $f->{filename} =~ /mp3$/i; } + return 0; + } + +sub details_tags_box + { + my ($t, $kw) = @_; +# my $tags = $t->{tags}; + return tags_stringify_links ( $t ); +# return join(", ", @$tags); + } + +sub details_participation + { + my (@participants) = @_; + my $pcount = 0; + my $out; + + foreach my $p (@participants) + { + $pcount++; + next if ($pcount > 6); + my $image = get_profile_image($p, $AVATAR_MED_PREFIX); + if ($image != -1) + { + $out .= qq( ); + $out .= qq(<a href="$BUCKY/profile/$p">); + $out .= qq(<img src="$image" width="$AVATAR_MED_WIDTH" height="$AVATAR_MED_WIDTH" border=1">); + $out .= qq(</a>); + } + } + if ($pcount > 6) + { + $out .= "<small> + ".($pcount - 4); + $out .= " $BUCKY_DUDER_NOUN"; + $out .= courtesy_s($pcount - 4); + $out .= "</small>"; + } + return $out; + } + +# get list of unique users posting in thread +sub get_participants + { + my ($t, $files, $comments) = @_; + my %participant; + $participant{$t->{username}} = 1000; + + foreach my $f (@$files) + { $participant{$f->{username}}++; } + foreach my $c (keys %$comments) + { $participant{$comments->{$c}->{username}}++; } + + return (sort { $participant{$b} <=> $participant{$a} } (keys(%participant))); + } + +sub details_keywords_box + { + my ($t, $kw) = @_; + if (defined($t->{keyword}) && !check_key($t->{display}, "kws")) + { + my $t = get_threads_by_keyword($t->{keyword}); + if ($t != -1) + { + print qq(<table border=0 cellpadding=0 cellspacing=0 class="threadmain" width="$width">); + thread_box({ threads => $t, kw => $kw }); + print qq(</table>); + } + } + } + +############################## + +print "Details: " . &report_time() . "\n" if $timer; |
