diff options
| author | Jules Laplace <carbon@melanarchy.org> | 2013-08-02 17:14:41 -0500 |
|---|---|---|
| committer | Jules Laplace <carbon@melanarchy.org> | 2013-08-02 17:14:41 -0500 |
| commit | e9192b3d42660a5781101df4357d276318151e8a (patch) | |
| tree | 059eb6ace6147cf9559af74ed1ab5e221c80e280 /cgi-bin/index | |
| parent | 79670053c7247d3a49b607960efd284e93f057e5 (diff) | |
cgi-bin & lib
Diffstat (limited to 'cgi-bin/index')
| -rwxr-xr-x | cgi-bin/index | 293 |
1 files changed, 293 insertions, 0 deletions
diff --git a/cgi-bin/index b/cgi-bin/index new file mode 100755 index 0000000..8ddacb4 --- /dev/null +++ b/cgi-bin/index @@ -0,0 +1,293 @@ +#!/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}) : $BUCKY_INDEX_LIMIT; + my $date = exists($input->{start}) ? int($input->{start}) : "now"; + + header({ title => get_random_line("titles"), sticky => $input->{keyword}, color => get_color_from_time() }); + 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 style="width: 100px">\n); + print qq(<div class="bluebox" width="100"><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" width="100"><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" width="100"><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 MAIN PANE + print qq(<td align=left valign=top>\n); + +# index_photostream($keyword,$tag); + +# print qq(<table border=0 cellpadding=0 cellspacing=0 class="threadmain" width="580">); +# print qq(<table border=0 cellpadding=0 cellspacing=0 class="threadmain">); + print qq(<table border=0 cellpadding=0 cellspacing=0 class="threadmain" width="100%">); + + 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 SIDEBAR + print qq(<td width="300" align=left valign=top>\n); + alerts(); + if ($USER == -1) + { + bPod_box(); + } + else + { + welcome_box(); # if (check_key($USER->{boxes}, "welcome")); + search_box(); +# radio_box() ; # if (check_key($USER->{boxes}, "radio")); +# bPod_box() if (check_key($USER->{boxes}, "bPod")); + hoot_box() if (check_key($USER->{boxes}, "hootbox")); +# svn_box();# if $USER->{'ulevel'} == 3; +# upload_form($keyword) if (check_key($USER->{boxes}, "postform")); + } + print qq(</td>); + +############################### + + print qq(</tr>); + print qq(</table>\n\n); + + footer(); + } + +$dbh->disconnect (); + +print "Index: " . &report_time() . "\n" if $timer; |
