summaryrefslogtreecommitdiff
path: root/cgi-bin/tag
diff options
context:
space:
mode:
Diffstat (limited to 'cgi-bin/tag')
-rwxr-xr-xcgi-bin/tag290
1 files changed, 290 insertions, 0 deletions
diff --git a/cgi-bin/tag b/cgi-bin/tag
new file mode 100755
index 0000000..6af4520
--- /dev/null
+++ b/cgi-bin/tag
@@ -0,0 +1,290 @@
+#!/usr/bin/perl
+#########################################
+# index
+# - do all index stuff, also deal with keyword admin
+#########################################
+
+use localbucky;
+
+$dbh = DBI->connect ($dsn);
+
+our ($USER, $lastlog) = checkin();
+
+my $k;
+my $tag;
+
+# check name of the calling script: index, tag, keyword
+$input->{script} ||= $input->{script_from_uri} if defined($input->{script_from_uri});
+
+# load the tag or keyword into the input params, if they don't exit already
+if ( $input->{script} eq $BUCKY_LEXICON_TAG )
+ {
+ $input->{tag} ||= $input->{object_from_uri} if defined($input->{object_from_uri});
+ }
+elsif ( $input->{script} eq $BUCKY_LEXICON_KEYWORD )
+ {
+ $input->{keyword} ||= $input->{object_from_uri} if defined($input->{object_from_uri});
+ }
+
+# Get keyword
+if (exists($input->{keyword}) && $input->{keyword} ne "new" && $input->{keyword} ne "unsorted")
+ {
+ $k = get_keyword($input->{keyword});
+ }
+
+
+# Create New Keyword? FORM
+if (exists($input->{keyword}) && $input->{keyword} eq "new")
+ {
+ my $t;
+ header("add new category");
+ if (exists($input->{thread}))
+ {
+ $t = get_thread($input->{thread});
+ }
+ menu();
+ print "<br><br>";
+ my %faek =
+ (
+ keyword => $input->{keyword},
+ thread => $input->{thread}
+ );
+ keyword_form($input->{keyword}, \%faek, $t);
+ footer();
+ }
+
+# Edit settings for keyword
+elsif ($input->{c} eq "edit" && (check_op($k) || $USER->{ulevel} == 3))
+ {
+ header(
+ {
+ title => "settings for category '$input->{keyword}'",
+ sticky => $input->{keyword}
+ } );
+ # 20070903 - marc - new menu args calling style
+ my $menu_args;
+ $menu_args->{keywords} = $k if $k;
+ menu( $menu_args );
+# menu($k);
+ print "<br><br>";
+
+ keyword_form($k->{keyword}, $k);
+
+ print qq!<center><table border=0 cellpadding=0 cellspacing=0 class="threadmain" width="580">!;
+ my $threads = get_threads_by_keyword($k->{keyword});
+ thread_box({ threads => $threads, kw => $k });
+
+ print qq!</table>!;
+ footer();
+ }
+
+# Create new keyword? Process form results
+elsif ($input->{c} eq "create")
+ {
+ if (!defined($input->{keyword}))
+ { error("no keyword specified!"); }
+ if (get_keyword($input->{keyword}) != -1)
+ { error("keyword already exists!"); }
+ my %nk =
+ (
+ keyword => $input->{keyword},
+ threads => " $input->{thread} ",
+ owner => $USER->{username},
+ public => $input->{public},
+ agglutinate => $input->{agglutinate},
+ color => $input->{color},
+ ops => (make_whitelist())
+ );
+ if ($DEBUG)
+ {
+ header("Creating keyword $input->{keyword}");
+ menu();
+ foreach my $ky (keys %nk)
+ { print "$ky => $nk{$ky}<br>\n"; }
+ }
+ add_keyword(\%nk);
+ update_thread_keyword($input->{thread}, $input->{keyword});
+ redirect("$BUCKY/$BUCKY_LEXICON_KEYWORD/$input->{keyword}");
+ }
+
+# Edit settings for keyword? Process form results
+elsif ($input->{c} eq "update")
+ {
+ if (!defined($input->{keyword}))
+ { error("no keyword specified!"); }
+ my %nk =
+ (
+ threads => " $input->{thread} ",
+ public => (exists($input->{public}) ? 1 : 0),
+ agglutinate => (exists($input->{agglutinate})) ? $input->{agglutinate} : 0,
+ color => $input->{color}
+ );
+ if (!exists($input->{public}))
+ {
+ $nk{ops} = make_whitelist();
+ }
+ if ($DEBUG)
+ {
+ header("Updating keyword $input->{keyword}");
+ menu();
+ foreach my $ky (keys %nk)
+ { print "$ky => $nk{$ky}<br>\n"; }
+ }
+ update_keyword($input->{keyword}, \%nk);
+ redirect("$BUCKY/$BUCKY_LEXICON_KEYWORD/$input->{keyword}");
+ }
+
+# Assign keyword processing form action
+elsif ($input->{c} eq "assign")
+ {
+ keyword_assign_mechanism($input->{keyword}, $input->{thread}, $k);
+ redirect("$BUCKY/maintain/$input->{thread}");
+ # redirect("$BUCKY/index?keyword=$input->{keyword}");
+ }
+
+# Detach keyword action
+elsif ($input->{c} eq "detach")
+ {
+ my $t;
+
+ if (!defined($input->{thread}))
+ { error("no post specified!"); }
+ $t = get_thread($input->{thread});
+ $k = get_keyword($t->{keyword});
+
+ my %nk = ( threads => delete_key($k->{threads}, $input->{thread}) );
+
+ if ($DEBUG)
+ {
+ header("Detaching post from $t->{keyword}");
+ menu();
+ foreach my $ky (keys %nk)
+ { print "$ky => $nk{$ky}<br>\n"; }
+ print "keyword ==> $t->{keyword}<br>\n";
+ print "detaching <b>$t->{title}</b> from <b>$t->{keyword}</b><br>\n";
+ }
+ update_keyword($t->{keyword}, \%nk);
+ update_thread_keyword($t->{id}, "NULL");
+ redirect("$BUCKY/maintain/$t->{id}");
+ }
+
+# Display main index page
+else
+ {
+ my $tag = exists($input->{tag}) ? $input->{tag} : undef;
+ my $keyword = exists($input->{keyword}) ? $input->{keyword} : "all";
+ my $limit = exists($input->{limit}) ? int($input->{limit}) : 40;
+ my $date = exists($input->{start}) ? int($input->{start}) : "now";
+
+ header({ title => get_random_line("titles"), sticky => $input->{keyword} });
+ my $keywords = get_keywords();
+ my $tags = get_tags();
+
+ my $menu_args;
+ $menu_args->{keywords} = $keywords->{$keyword} if $keywords->{$keyword};
+ menu( $menu_args );
+
+ print qq(<table width="100%" cellpadding=0 cellspacing=0 border=0>);
+ print qq(<tr>);
+#############################
+# KEYWORD LIST
+ print qq(<td align=center valign=top width="100">\n);
+ print qq(<div class="bluebox"><span style="line-height: 1.5em;"><nobr>);
+ my $p = ''; my $l = '';
+ my $with_letter = 0;
+ my $s = '';
+my $pre = '';
+ my $start = '';
+ foreach my $k (sort { lc($a) cmp lc($b) } keys %$keywords)
+ {
+ my $style;
+ $l = substr($k,0,1);
+ $start ||= $l;
+ if ($p && lc($l) ne lc($p))
+ {
+ if ($with_letter > 3)
+ {
+ print qq(<big><big><b>$start - $pre</b></big></big><br> );
+ print $s;
+ print qq(</nobr></span></div>);
+ print qq(<div class="bluebox"><span style="line-height: 1.5em;"><nobr>);
+ $s = '';
+ $with_letter = 1;
+ $p='';
+ $start = $l;
+ }
+ }
+ $with_letter += 1;
+ $p||=$l;
+ $pre=$l;
+ $s .= qq(<a style="$css" href="$BUCKY/category/$k">$k</a><br>);
+ }
+if ($s)
+ {
+ print qq(<big><big><b>$start - $pre</b></big></big><br> );
+ print $s;
+ print qq(</div>);
+ print qq(<div class="bluebox"><small><span style="line-height: 1.5em;"><nobr>);
+ }
+ print qq(</div>);
+ print qq(<div class="bluebox"><small><span style="line-height: 1.5em;"><nobr>);
+ print qq(.: <a href="$BUCKY/category/unsorted"><i>unsorted</i></a> :.<br>);
+ print qq(</nobr></span></small></div></td>\n);
+
+ print qq(<td width="300" align=right valign=top>\n);
+
+ alerts();
+ if ($USER == -1)
+ {
+ bPod_box();
+ print qq(</td></tr>);
+ }
+ else
+ {
+ welcome_box() if (check_key($USER->{boxes}, "welcome"));
+ bPod_box() if (check_key($USER->{boxes}, "bPod"));
+ radio_box() if (check_key($USER->{boxes}, "radio"));
+ upload_form($keyword) if (check_key($USER->{boxes}, "postform"));
+ hoot_box() if (check_key($USER->{boxes}, "hootbox"));
+ }
+
+ print qq(</td><td align=left valign=top>\n);
+
+ if (check_key($USER->{boxes}, "photostream") || ($USER == -1) )
+ {
+ if ( $keyword ne "all" )
+ { photostream({ keyword => $keyword, vertical => 0, count => 4 }); }
+ elsif ( $tag )
+ { photostream({ tag => $tag, vertical => 0, count => 4 }); }
+ else
+ { photostream({ user => 1, vertical => 0, count => 4 }); }
+ }
+
+ print qq(<center><table border=0 cellpadding=0 cellspacing=0 class="threadmain" width="580">);
+
+ if ($keyword ne "all")
+ {
+ my $threads = throttle_threads({ keyword => $keyword, newest => $date });
+ thread_box({ threads => $threads, kw => $keywords->{$keyword} });
+ }
+ elsif ($tag)
+ {
+ my $threads = throttle_threads({ tag => $tag, newest => $date });
+ thread_box({ threads => $threads, tag => $tags->{$tag} });
+ }
+ else
+ {
+ alpha_index($keywords, $limit, $date);
+ }
+
+ print qq(</table>);
+ print qq(</td>\n);
+ print qq(</tr>);
+ print qq(</table>\n\n);
+
+ footer();
+ }
+
+$dbh->disconnect ();
+
+print "Index: " . &report_time() . "\n" if $timer;