diff options
Diffstat (limited to 'cgi-bin/adminz')
| -rwxr-xr-x | cgi-bin/adminz | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/cgi-bin/adminz b/cgi-bin/adminz new file mode 100755 index 0000000..4a71e38 --- /dev/null +++ b/cgi-bin/adminz @@ -0,0 +1,207 @@ +#!/usr/bin/perl +######################################### +# administration of threads, keywords, +# privacy, etc. + +use localbucky; + +our $id; +our $files; + +$dbh = DBI->connect ($dsn); + +our ($USER, $lastlog) = checkin(); +logout() unless ($USER != -1); + +if ($USER->{ulevel} != 3) + { redirect("/"); } +else + { + header( { title => "bucky administrauma", color => "red" } ); + menu(); + if (exists($input->{c})) + { + if ($input->{c} eq "s") + { + update_thread_title($id, $input->{title}); + $t->{title} = $input->{title}; + print "Changed thread $id title to: <b>$t->{title}</b><br>\n"; + } + elsif ($input->{c} eq "pass") + { + do_password_reset(); + } + elsif ($input->{c} eq "p") + { + if ($input->{private} == 1) + { + print "Thread is now <b>private</b>.<br>"; + switch_thread_privacy($id, 1); + $t->{allowed} = update_whitelist(); + $t->{private} = 1; + } + else + { + print "Thread is now <b>public</b>.<br>"; + switch_thread_privacy($id, 0); + $t->{private} = 0; + } + } + elsif ($input->{c} eq "f") + { + my @flagged = corral($input, "file"); + if ($DEBUG) + { + print "<br>\nfiles flagged: "; + foreach (@flagged) + { print; print " "; } + print "<br>\n"; + } + if ($input->{verb} eq "flag") + { + print "Flagged file $flagged[0]<br>"; + update_flagged($id, $flagged[0]); + $t->{flagged} = $flagged[0]; + admin_form($id, $t, $files, $k); + } + elsif ($input->{verb} eq "move") + { + print "When this works it will be like this:!<br>\n"; + print "Where do you want to move these files here<br>\n"; + print "Moving files...<br>\n"; + # system("mv", $data_path/$oldpid/$filenamea ..., "$data_path/$newpid/"); + print "Moving ids...<br>\n"; + print "Recalculating thread sizes...<br>\n"; + } + elsif ($input->{verb} eq "rm") + { + if (!$input->{ok}) + { + print qq!<center><p><div class="bluebox" style="width: 320px; padding: 10px;"><big><b>Are you sure you want to delete these files?</b></big><hr noshade color="$BUCKY_COLOR_HR"><p>\n!; + print qq!<form action="$BUCKY/maintain" method="post" enctype="multipart/form-data">!; + print qq{<input type=hidden name="c" value="f">\n}; + print qq{<input type=hidden name="id" value="$id">\n}; + print qq{<input type=hidden name="debug" value="1">\n} if ($DEBUG); + print qq{<input type=hidden name="verb" value="rm">\n}; + print qq{<input type=hidden name="ok" value="1">\n}; + + my $i = 0; + my $fid = shift(@flagged); + foreach my $fh (sort_by_id(@$files)) + { + next if ($fid != $$fh{id}); + $i++; + print qq{<input type=hidden name="file$i" value="$fid">\n}; + print $$fh{filename}."<br>\n"; + $fid = shift(@flagged); + } + + print qq{<br><input type="submit" value="YES YES DELETE THE FILES" class="clicky"></form></div></center>}; + } + else + { + my $i = 0; + my $fid = shift(@flagged); + foreach my $fh (sort_by_id(@$files)) + { + next if ($fid != $$fh{id}); + $i++; + delete_file_record($fid); + system("rm", "-f", qq!$data_path/$id/$$fh{filename}!); + print qq!deleted $$fh{filename}<br>\n!; + $fid = shift(@flagged); + } + + print "Recalculating thread size...<br>\n"; + update_thread_size($id); + $files = get_files($id); + } + } + } + adminster_form(); + } + else + { + adminster_form(); + } + footer(); + } + +sub sort_by_username { sort { lc($a->{username}) cmp lc($b->{username}) } @_; } +sub sort_by_id { sort { $a->{id} <=> $b->{id} } @_; } + +sub adminster_form + { + print qq{<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td align=left valign=top>\n\n}; + +# my $reqs = get_user_requests(); +# if ($reqs != -1) +# { +# my $s = (@$reqs != 1) ? "s" : ""; +# alert_box("$BUCKY/approve", @$reqs." account request$s pending!"); +# } + + print <<end; +<div class="message" style="float: right;"> +<b>password reset form</b> +<hr color="$BUCKY_COLOR_HR"> +end + password_reset_form(); + print "</div>"; + +# "flush" zips button +# recalculcate thread sizes +# links to approval etc (alert!) + print qq{</td></tr></table>\n\n}; + } + +sub password_reset_form + { + my $users = get_all_users(); + + print qq!<form action="$BUCKY/adminz" method="post" enctype="multipart/form-data">!; + print qq{<input type=hidden name="c" value="pass">\n}; + print qq{<input type=hidden name="debug" value="1">\n} if ($DEBUG); + print qq!<table cellpadding=2 cellspacing=0 border=0>!; + print qq!<tr><td align="right">user:</td><td align="left">!; + print qq!<select name="user">!; + foreach $c (sort_by_username(@$users)) + { + print qq!<option value="$c->{username}"!; + print qq!>$c->{username}</option>!; + } + print qq!</select>\n!; + print <<pws; +</td></tr> +<tr><td align="right"> +password?<br> +</td><td align="left"> +<input type="password" name="pw1" value="" size=13 maxlength=20><br> +</td></tr> +<tr><td align="right" valign="top"> +<small>again!</small> +</td><td align="left"> +<input type="password" name="pw2" value="" size=13 maxlength=20><br> +<input type="submit" value="RESET PASSWORD" class="clicky"> +</td></tr> +</table> +pws + print qq!</form>\n!; + } + +sub do_password_reset + { + if (exists($input->{pw1}) && exists($input->{pw2}) && $input->{pw1} && $input->{pw2}) + { + if ($input->{pw1} eq $input->{pw2}) + { + update_password($input->{user}, crypt($input->{pw1},lc($input->{user}))); + print qq(password changed for $input->{user}<br>\n); + } + else + { + print "passwords don't match!<br>\n"; + } + } + } + |
