#!/usr/bin/perl
$discus_conf = '/home/member/d/doc/priv/discus_admin/discus.conf';
$pro_fileid = '31286741984066320';
#Discus board administration (menu only) script
#-------------------------------------------------------------------------------
# DISCUS VERSION 3.10 COPYRIGHT NOTICE
#
# Discus 3.10 is copyright (c) 2000 by DiscusWare, LLC, all rights reserved.
# The use of Discus is governed by the Discus License Agreement which is
# available from the Discus WWW site at:
#    http://www.discusware.com/discus/license
#
# Pursuant to the Discus License Agreement, this copyright notice may not be
# removed or altered in any way.
#-------------------------------------------------------------------------------
if (open (FILE, "$discus_conf")) {
	@file = <FILE>;
	close (FILE);
	foreach $line (@file) {
		if ($line =~ /^(\w+)=(.*)/) {
			$varname = $1;
			$value = $2;
			$value =~ s/\r//g;
			${$varname} = $value;
		}
	}
	require "$admin_dir/source/src-board-subs-common";
} else {
	print "Content-type: text/html\n\n";
	print "<HTML><HEAD><TITLE>Script Execution Error</TITLE></HEAD>\n";
	print "<BODY BGCOLOR=#ffffff TEXT=#000000>\n";
	print "<H1>Script Execution Error</H1>\n";
	print "Discus scripts could not execute because the discus.conf file\n";
	print "could not be opened.";
	print "<P>Reason: <FONT COLOR=#ff0000><B>$!</B></FONT>" if $!;
	print "<P>This generally indicates a setup error of some kind.\n";
	print "Consult the <A HREF=\"http://www.discusware.com/support\">Discus ";
	print "Resource Center</A> for troubleshooting information.</BODY></HTML>\n";
	exit(0);
}
&parse_form;
&read_cookie;
require "$admin_dir/source/src-board-subs-admin";
if ($FORM{'action'} eq "version") {
	&check_passwd;
	&error_message("Upgrade Error", "This board has not properly been updated to the version 3.10 file structure.  Contact the board administrator and have that individual log into the administration program to complete the upgrade.") if $FORM{'username'} ne $superuser;
	&ex('v3_00_to_3_10_upgrade', "");
}
if ($FORM{'action'} eq 'mgr_1') {
	&check_passwd;
	&ex('page_mgr_1', $FORM{"username"});
}
if ($FORM{'action'} eq "perl") {
	&check_passwd;
	&ex('perl_warn', $FORM{"username"});
}
if ($FORM{'cmd'} eq "backup_mgr") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this functionality") if $FORM{'username'} ne $superuser;
	&ex('backup_mgr', 1);
}
if ($FORM{'cmd'} eq "importexport") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this functionality") if $FORM{'username'} ne $superuser;
	&ex('import_export_utility', 1);
}
if ($FORM{'cmd'} eq "export") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this functionality") if $FORM{'username'} ne $superuser;
	&ex('exporter', $FORM{'format'});
}
if ($FORM{'action'} eq 'access_mgr_1') {
	&check_passwd;
	&ex('page_mgr_1', $FORM{"username"}, 2);
}
if ($FORM{'cmd'} eq 'log_analy') {
	&check_passwd;
	&ex('log_analysis_1', $FORM{"username"});
}
if ($FORM{'cmd'} eq 'archive_mgr') {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this functionality") if $FORM{'username'} ne $superuser;
	&ex('archive_mgr', 1);
}
if ($FORM{'cmd'} eq 'options_mgr') {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this functionality") if $FORM{'username'} ne $superuser;
	&ex('options_mgr', 1);
}
if ($FORM{'cmd'} eq 'template_mgr') {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this functionality") if $FORM{'username'} ne $superuser;
	&ex('template_mgr_1', 1);
}
if ($FORM{'cmd'} eq 'profanity_editor') {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this functionality") if $FORM{'username'} ne $superuser;
	&ex('profanity_editor', 1);
}
if ($FORM{'cmd'} eq 'email_configurator') {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this functionality") if $FORM{'username'} ne $superuser;
	&ex('email_configurator', 1);
}
if ($FORM{'action'} eq 'queue_mgr_1') {
	&check_passwd;
	&ex('queue_mgr_1', $FORM{'username'}) if $pro;
}
if ($FORM{'action'} eq 'queue_mgr_disp') {
	&check_passwd;
	&ex('queue_mgr_disp', $FORM{'username'}, $FORM{'number'}) if $pro;
}
if ($FORM{'action'} eq 'queue_frames') {
	&check_passwd;
	&ex('queue_frames', $FORM{'username'}) if $pro;
}
if ($FORM{'action'} eq 'access_mgr_2') {
	&check_passwd;
	&extract($FORM{'HTTP_REFERER'});
	&verify_owner($owner,$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit the selected topic!");
	&ex('access_mgr_2', $topic_number, $FORM{'username'}) if !$pro;
	&ex('access_mgr_2_pro', $topic_number, $FORM{'username'}) if $pro;
}
if ($FORM{'action'} eq "page_editor") {
	&check_passwd;
	&extract($FORM{'HTTP_REFERER'});
	&verify_owner($owner,$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit the selected topic!");
	$refer = "//$FORM{'HTTP_REFERER'}";
	&ex("page_mgr_2", $refer,$FORM{"username"});
}
if ($FORM{'action'} eq "graphic_browser") {
	&check_passwd;
	if ($FORM{'HTTP_REFERER'} !~ m|\.$ext$|) {
		$FORM{'HTTP_REFERER'} .= ".$ext";
	}
	&extract ("//$FORM{'HTTP_REFERER'}");
	&ex('graphic_browser_select', $topic_number, $me_number, $FORM{'username'});
}
if ($FORM{'cmd'} eq "board_mgr") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access the board manager!") if $FORM{'username'} ne $superuser;
	&ex('take_to_maintenance', 0) if $FORM{'maintainflag'} eq "1";
	&ex('board_manager', $FORM{"username"});
}
if ($FORM{'cmd'} eq "data_recovery") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access the data recovery utility!") if $FORM{'username'} ne $superuser;
	&ex('data_recovery', $FORM{"username"});
}
if ($FORM{'cmd'} eq "moderator_mgr") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access the moderator manager!") if $FORM{'username'} ne $superuser;
	&ex('moderator_mgr', $FORM{"username"});
}
if ($FORM{'action'} eq "viewmessage") {
	&check_passwd;
	&extract ($FORM{'HTTP_REFERER'});
	&verify_owner($owner,$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to view messages in this topic!");
	$file = "$message_dir/$topic_number/$me_number.$ext";
	$post = $FORM{'num'};
	&ex('viewmessage', $topic_number, $me_number, $post);
}
if ($FORM{'action'} eq 'menu' || $FORM{'cmd'} eq 'menu') {
	$COOKIE{'pass' . $COOKIE_ID} = "" if $FORM{'startfrom'} eq "";
	$pass = &check_passwd(1,1) if $FORM{'startfrom'} eq "";
	$pass = &check_passwd(0,0) if $FORM{'startfrom'} ne "";
	$flag = 1 if $pass eq "* BLANK *";
	if ($GLOBAL_OPTIONS{'admin'} == 0 && $GLOBAL_OPTIONS{'options_used'} == 1) {
		&error_message("Administration Disabled", "Administration has been disabled on this board for all moderators except the superuser.") if $FORM{'username'} ne $superuser;
	}
	if ($DO_NOT_WRITE_FILES_FLAG) {
		&error_message("Administration Disabled", "Administration has been disabled on this board for all moderators except the superuser.") if $FORM{'username'} ne $superuser;
	}
	$flagger = 0;
	$flagger = 1 if $FORM{'autologin'} == 1;
	&ex('admin_main_menu', $FORM{"username"}, $pass, $flag, $flagger);
}
if ($FORM{'action'} eq 'first_pass') {
	$pass = &check_passwd(0,1);
	&error_message("Permissions Error", "Only the superuser may access this!") if $FORM{'username'} ne $superuser;
	&ex('first_pass', $FORM{"username"});
}
if ($FORM{'action'} eq 'quota_helper') {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access this!") if $FORM{'username'} ne $superuser;
	&ex('quota_admin', $FORM{"username"});
}
if ($FORM{'cmd'} eq "group_mgr") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access the group manager!") if $FORM{'username'} ne $superuser;
	&ex('group_mgr', $FORM{"username"});
}
if ($FORM{'cmd'} eq "user_mgr") {
	&check_passwd;
	&ex('user_mgr_1', $FORM{"username"});
}
if ($FORM{'cmd'} eq "user_mgr_2") {
	&check_passwd;
	&verify_owner($FORM{'group'},$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit users in this group!");
	&ex('user_mgr_2', $FORM{"username"}, $FORM{"group"});
}
if ($FORM{'cmd'} eq "version_mgr") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access the version manager!") if $FORM{'username'} ne $superuser;
	&ex('version_manager', 1);
}
if ($FORM{'cmd'} eq "reg_configurator") {
	&check_passwd;
	&error_message("Permissions Error", "Only the superuser may access the version manager!") if $FORM{'username'} ne $superuser;
	&ex('reg_configurator', 1);
}
if ($FORM{'cmd'} eq "start") {
	&ex('admin_from_here', 1);
}
if ($FORM{'cmd'} eq "" && $FORM{'action'} eq "") {
	&ex("front_page", 1);
}
$fa = "<UL>";
foreach $key (keys(%FORM)) {
	$fa .= "<LI><FONT COLOR=#0000ff>$key</FONT>=<FONT COLOR=#ff0000><B>$FORM{$key}</B></FONT>\n";
}
$fa .= "</UL>\n";
&error_message("Invalid Query", "You should never see this error message.  Contact DiscusWare if this problem persists with the following information:<P>board-admin-menuonly.cgi<BR><FONT COLOR=#00ff00>$ENV{'HTTP_REFERER'}</FONT><BR><FONT COLOR=#00aaaa>$ENV{'QUERY_STRING'}</FONT><BR>$fa", 0, 1);
# END - FILE IS CORRECTLY UPLOADED #
