#!/usr/bin/perl

# Ultimate Bulletin Board (UBB), Version 6
# Official Release Date for UBB6: March 15, 2001

# First version of UBB created May 7, 1996 (by Ted O'Neill).
# This entire program is copyright Infopop Corporation, 2001.
# For more info on the Ultimate Bulletin Board and other Infopop
# Products/Services, visit: http://www.infopop.com

# Program Author: Ted O'Neill, with assistance from Michael Farris, Dave Dreezer
# Special Thanks to: Rosemary O'Neill, Mark Badolato, Charles Capps, Graeme, Jesus de la Garza, Joe Siegler, Hal, Brett Harris, Kristi Miller, Celeste Combs, everyone who beta-tested, and all of our support moderators!

# UBB6 is dedicated to Edward Kriz.

# You may not distribute this program in any manner, modified or otherwise, without the express, written written consent from Infopop Corporation.

# You may make modifications, but only for your own use and within the confines of the UBB License Agreement (see our website for that).

# You may not distribute "hacks" for the UBB without approval from Infopop.

# Note: if you modify ANY code within the UBB, we at Infopop Corporation cannot offer you support-- thus modify at your own peril :)

BEGIN {
	($0 =~ m!(.*)(\\|/)[^/\\]+!) && unshift(@INC, $1, "$1$2Modules");
}

use lib("./Modules", ".");	# in the event $0 is not set

use strict;
use Fcntl ':flock';
use UBBCGI qw(:cgi);
use UBBCGI::Carp qw(fatalsToBrowser set_message);
use vars qw(%vars_whos_online @Ell_cookie $invisible_pref @people);
use vars qw(%vars_wordlets_mods);

use vars qw(%vars_style_reference $trademark $trade $InfopopCopyright %weights $version $version_number $masterCharset $release_j %GotTime $template $vars_graemlins %template %vars_config %vars_misc %vars_registration %vars_forums %vars_styles %vars_display %vars_style %vars_email %vars_time %vars_search %vars_pm %vars_wordlets %vars_wordlets_err %vars_wordlets_email %vars_wordlets_img %vars_wordlets_date %template_match $username $password $last_login_dt $session_login_dt $last_login_j $session_login_j $days_prune $LastLoginTime $pubname $user_topic_view $user_number @ubber @login @session $ThisHTML $exact_path @memberslist %in $memlistopen $cache_cookie $forum_threads $summary @alltheforums @allthecategories @memberslist_array @memberslist_array %forum_thread_data %ProfileNumber %member_profile $CurrentTab $Hiddens $direct_to $Legend $LoginWording $MainButtonsLine $TableWidth2 $ContactLine $TBT $TBB $Header $Footer $EmailHeader $show_logout $show_logout_noreg $instant_jscript $title_wording);


##############################################################################
# NOTE TO USERS WHO ARE RUNNING UBB IN THE NON-WRITABLE CGI-BIN SITUATION:
# Modify the path in the following line to reflect the VariablesPath!
# There is NO NEED to modify this line unless you are using a different
# VariablesPath.  PLEASE use the UBB's CGI directory as the VariablesPath
# if at all possible.  Thanks.
##############################################################################

eval {
	do "/home/digicam/ceoinfo.ru/html/forum/variables/vars_config.cgi";
};

&CheckDollarAt($@);



# No need to touch this now that we have the VariablesPath!
foreach my $file (qw(display misc email time search pm registration template_match whos_online wordlets wordlets_err wordlets_img wordlets_date wordlets_mods)) {
	eval { do "$vars_config{VariablesPath}/vars_$file.cgi"; };
	&CheckDollarAt($@);
}

eval {	require "$vars_config{CGIPath}/ubb_lib.cgi";	}; &CheckDollarAt($@);

	&InitImportantStuff;	#ubb_lib

	&RequireCode("$vars_config{CGIPath}/ubb_lib_files.cgi");
	&RequireCode("$vars_config{CGIPath}/ubb_lib_time.cgi");
	&LoadTemplate("public_common");

#out in the middle of nowhere, we have a subroutine!
sub CheckDollarAt {
	my $error = shift;
	return unless $error;

	$masterCharset = "ISO-8859-1" unless $masterCharset;
	print header(
		-charset => "$masterCharset",
		-type    => "text/html",
	);

	print "<p><br />There was a compilation error while loading the UBB libraries and data files: <pre>\n$error</pre><br />";    #, Dumper \%vars_registration;
	print "Please make sure that you uploaded the CGI and Variables files to the proper directory, permissions are set properly "
	. "on the files, and that paths in the control panel are set correctly.</p>";
	exit;
}


# We want to do this now rather than continue to make
# up to 1000 calls to UBBCGI routines per instance...
%in = map{$_ => param($_)} param();	#map is your friend!

my $templatefile;    #, $summary;
                     #if we've gotten this far, we have template_matches

if ((($in{ubb} =~ m/^(newtopic|submit_new_topic|get_topic|reply|submit_new_reply|get_ip|delete_topic|close_topic|open_topic|next_topic|transfer|transfer_topic|edit_post|submit_edit|forum)$/) && ($in{'f'})) && ($in{f} =~ m/^\d+$/)) {
	my $forumnumber = "forum_" . $in{f};
	$templatefile = $template_match{$forumnumber};

} elsif ($in{ubb} =~ m/^(recent_user_posts|get_daily|search|do_search)$/) {
	$templatefile = $template_match{search};

} elsif ($in{ubb} =~ m/^(get_pm|private_message|submit_private_message|pm_prune|pm_delete|pm_reply|submit_pm_reply|ignore_list|buddy_list|do_ignore|do_buddy|update_ignore|update_buddy)$/) {
	$templatefile = $template_match{private_message};

} elsif ($in{ubb} =~ m/^(faq)$/) {
	$templatefile = $template_match{faq};

} elsif ($in{ubb} =~ m/^(get_profile|edit_profile|my_profile|my_rating_list|edit_my_profile|rate_member)$/) {
	$templatefile = $template_match{profile};

} elsif ($in{ubb} =~ m/^(agree|coppa_agree|register_page|underage_register_page|show_coppa_form|submit_registration|login)$/) {
	$templatefile = $template_match{registration};

} elsif ($in{ubb} =~ m/^(ubb_code_page)$/) {
	$templatefile = $template_match{ubb_code};

} elsif ($in{ubb} =~ m/^(email|send_topic|lost_password|find_lost)$/) {
	$templatefile = $template_match{email};

} else {
	$templatefile = $template_match{summary_page};
	$summary      = 1;
}    #endelse

%vars_style = &LoadStyleTemplate($templatefile);

# If we grabed a template file, reassign the character set
# Otherwise, $masterCharset is called in from ubb_lib
$masterCharset = $vars_style{thisCharset} if $vars_style{thisCharset};

$cache_cookie = $vars_config{cache_pw};

$template = \%template;


# set main buttons options
$MainButtonsLine = &MainButtonOptions;    # in ubb_lib.pl

# set date/time
&GetDateTime;

# counter
&hit_me;

# for misc actions --
my %deadhash = &LoadStyleTemplate($template_match{transition}) if(($summary == 1) && ($template_match{transition} ne $template_match{summary}));
# intentional void context - just want to load it up

#now that we have our style template, we can do nice errors again!
set_message(\&StandardHTML2);

# check our Perl version
die "Perl reports version $]!\n\nUBB will not run under this version, it needs 5.004 or higher!\n"
	if $] < 5.004;


# standard argument
my $ubb = $in{ubb};
my $skip_cookie_check;
my $logoff;


# is forum closed?
if ($vars_misc{BBStatus} ne 'ON') {
	&set_page_elements;

	#print qq%Content-type: text/html\n\n%;
	print header(
		-charset => "$masterCharset",
		-type    => "text/html",
	);


	&StandardHTML("$vars_misc{BBClosedMessage}");
	exit(0);
}

if ($ubb eq 'clearcookies') {
	&RequireCode("$vars_config{CGIPath}/ubb_lib_misc.cgi");
	&clear_cookies;
	exit(0);
}    #end clearcookies

if ($ubb eq 'markallread') {
	&RequireCode("$vars_config{CGIPath}/ubb_lib_misc.cgi");
	&mark_all_read;
	exit(0);
}    #end clearcookies


if ($ubb eq 'forum_pw_check') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_forum.cgi");
	&forum_pw_check;
	exit(0);
}    #end forum_pw_check

# perform user login?
if ($ubb eq 'do_login') {
	&GetOrPost("POST");
	my $ip_number = $ENV{'REMOTE_ADDR'};
	&check_ip_bans($ip_number);

	$skip_cookie_check = 'true';

	&RequireCode("$vars_config{CGIPath}/ubb_lib_2.cgi");

	my @user_info = &verify_id("$in{username}", "$in{password}");
	my $pubname   = $user_info[0];
	my $dp        = $user_info[1];
	my $profile_number = $user_info[2];
	my $mod_q          = $user_info[3];
	chomp(my $writeadmin     = (&OpenProfile($profile_number))[4]);
	chomp(my $this_un     = (&OpenProfile($profile_number))[0]);
	chomp(my $this_pw     = (&OpenProfile($profile_number))[1]);

	chomp($mod_q);

	#6.1.0 - now forbidding login without queue approval
	if ($mod_q eq 'Q') {

		# user is registered but not approved!
		print header(
			-charset => "$masterCharset",
			-type    => "text/html",
		);
		&StandardHTML("$vars_wordlets_err{awaiting_approval}");
		exit(0);
	}

	if ($writeadmin !~ /Write/) {

		#user has no write permissions -> can't login
		print header(
			-charset => "$masterCharset",
			-type    => "text/html",
		);
		&StandardHTML("$vars_wordlets_err{user_not_approved}");
		exit(0);
	}

	if ($dp eq '') { $dp = "$vars_display{DaysPruneDefault}"; }

	my $cookie = cookie(
		-name    => "ubber$vars_config{Cookie_Number}",
		-value   => [$this_un, $this_pw, $pubname, $dp, $profile_number],
		-path    => '/',
		-expires => '+2y'
	);
	$username = $in{username};
	$user_number = $profile_number;

	$in{whos_online_invisible} = ($in{whos_online_invisible} eq "yes") ? "hideme" : "";
	my $Ell_cookie = cookie(
		-name=> "Ell$vars_config{Cookie_Number}",
		-value=> [$in{whos_online_invisible}],
		-path=> '/',
		-expires=> '+2y'
	);

	#print header(-cookie=>[$cookie]);
	print header(
		-cookie  => [$cookie, $Ell_cookie],
		-charset => "$masterCharset"
	);

	# display refer page
	my $clean_cgi = quotemeta($vars_config{CGIURL});
	if (($in{refer} ne '') && ($in{refer} !~ /logoff$/) && ($in{refer} !~ /cookies$/) && ($in{refer} !~ /find_lost$/) && ($in{refer} !~ /password$/) && ($in{refer} =~ /^$clean_cgi/)) {

		# take viewer back to topic
		&set_page_elements;
		&Transition("$in{refer}", "$vars_wordlets{thanks_for_login}", "$in{refer}");
		exit(0);
	} else {
		$ubb = '';
	}
}    # end do login

# perform user logoff?
if ($ubb eq 'logoff') {
	$skip_cookie_check = 'true';
	my $cookieA = cookie(
		-name    => "ubber$vars_config{Cookie_Number}",
		-value   => ['', ''],
		-path    => '/',
		-expires => '-2y'
	);
	my $cookieB = cookie(
		-name    => "session$vars_config{Cookie_Number}",
		-value   => ['', ''],
		-path    => '/',
		-expires => '-2y'
	);
	my $cookieC = cookie(
		-name    => "forumpw$vars_config{Cookie_Number}",
		-value   => ['', ''],
		-path    => '/',
		-expires => '-2y'
	);
	my $cookieD = cookie(
		-name    => "Ell$vars_config{Cookie_Number}",
		-value   => ['', ''],
		-path    => '/',
		-expires => '-2y'
	);

	#print header(-cookie=>[$cookieA, $cookieB, $cookieC]);
	print header(
	-cookie=>[$cookieA, $cookieB, $cookieC, $cookieD],
		-charset => "$masterCharset",
	);



	# confirm logoff
	&set_page_elements;
	&StandardHTML($vars_wordlets{logged_off});
	exit(0);

}    # end logoff

# retrieve cookies!
@ubber = cookie("ubber$vars_config{Cookie_Number}");
if ($ubber[0] ne '') { $username        = $ubber[0]; }
if ($ubber[1] ne '') { $password        = $ubber[1]; }
if ($ubber[2] ne '') { $pubname         = $ubber[2]; }
if ($ubber[3] ne '') { $user_topic_view = $ubber[3]; }
if ($ubber[4] ne '') { $user_number     = $ubber[4]; }
@Ell_cookie = cookie("Ell$vars_config{Cookie_Number}");
if ($Ell_cookie[0] ne '') { $invisible_pref = $Ell_cookie[0]; }

#make sure the user is not forging his cookie to get into a protected area
if (($vars_display{MembersOnlyAccess} eq 'YES') && (@ubber)) {
	my @checkTheProfile = &verify_id_num_2($username, $password, $user_number);
	unless ($checkTheProfile[4] =~ /Write/) {
		print header(
			-charset => "$masterCharset",
		);
		&StandardHTML($vars_wordlets_err{user_not_approved});
	}
}

@login = cookie("login$vars_config{Cookie_Number}");
if ($login[0] ne '') { $last_login_dt = $login[0]; }
if ($login[1] ne '') { $last_login_j  = $login[1]; }

@session = cookie("session$vars_config{Cookie_Number}");
if ($session[0] ne '') { $session_login_dt = $session[0]; }
if ($session[1] ne '') { $session_login_j  = $session[1]; }

# in case this is a new visitor!
if ($last_login_dt eq '') { $last_login_dt = 'NEW'; }

# set login cookie, if necessary

if ($skip_cookie_check ne 'true') {

	if ($session_login_dt eq '') {

		# set session cookie:
		# this is a temp cookie that stores previous last login

		my $cookie1 = cookie(
			-name  => "session$vars_config{Cookie_Number}",
			-value => [$last_login_dt, $last_login_j],
			-path  => '/'
		);

		# set new last login
		my $cookie2 = cookie(
			-name    => "login$vars_config{Cookie_Number}",
			-value   => [$GotTime{LastLoginDT}, $GotTime{LastLoginJulian}],
			-path    => '/',
			-expires => '+1y'
		);

		my $cookie3;

		# reconfirm user data- in case profile details were changed
		if ($username ne '') {
			my @this_profile = &verify_id_num_2($username, $password, $user_number);
			chomp($this_profile[1]);
			chomp($this_profile[0]);
			chomp($this_profile[21]);
			chomp($this_profile[15]);
			if ($this_profile[15] eq '') { $this_profile[15] = "$this_profile[0]"; }
			$cookie3 = cookie(
				-name    => "ubber$vars_config{Cookie_Number}",
				-value   => [$this_profile[0], $this_profile[1], $this_profile[15], $this_profile[21], $user_number],
				-path    => '/',
				-expires => '+2y'
			);
		}

		#print header(-cookie=>[$cookie1, $cookie2, $cookie3]);
		print header(
			-cookie  => [$cookie1,      $cookie2, $cookie3],
			-charset => "$masterCharset"
		);

	} else {

		unless ($ubb =~ m/^(submit_new_reply|submit_new_topic|submit_registration|edit_profile)$/) {

			#print qq%Content-type: text/html\n\n%;
			print header(
				-charset => "$masterCharset",
				-type    => "text/html",
			);

		}

	}
}    #if not do_login

# members only acess check
if ($vars_display{MembersOnlyAccess} eq 'YES') {
	if (($username eq '') || ($logoff eq 'true')) {
		unless ($ubb =~ m/^(agree|coppa_agree|show_coppa_form|register_page|underage_register_page|submit_registration|lost_password|find_lost)$/) {
			&set_page_elements;
			&LoadTemplate("public_login");
			exit(0);
		}
	}
}

# all ubb options:
$ubb = "" unless $ubb;



# who's online
if ($ubb eq 'whos_online') {
	&RequireCode("$vars_config{CGIPath}/ubb_whos_online.cgi");
	&WriteUserSession("$vars_wordlets_mods{whos_online_viewing} <a href=\"$vars_config{CGIURL}/ultimatebb.cgi?ubb=whos_online\">$vars_wordlets_mods{whos_online_whos_online}</a>", $user_number, $invisible_pref);
	&whos_online($user_number, $invisible_pref); exit(0);
}

# forum summary
if ($ubb eq '') {
	&RequireCode("$vars_config{CGIPath}/ubb_whos_online.cgi");
	if (exists $in{category}) {
		my $whos_online_cat_name = &GetCatName($in{category});
		&WriteUserSession("$vars_wordlets_mods{whos_online_browsing} <A HREF=\"$vars_config{CGIURL}/ultimatebb.cgi?category=$in{category}\">$whos_online_cat_name</a>", $user_number, $invisible_pref);
	} else {
		&WriteUserSession("$vars_wordlets_mods{whos_online_viewing} <A HREF=\"$vars_config{CGIURL}/ultimatebb.cgi\">$vars_wordlets_mods{whos_online_main_page}</a>", $user_number, $invisible_pref);
	}
	&RequireCode("$vars_config{CGIPath}/ubb_forum_summary.cgi");
	&forum_summary;
	exit(0);
}

if ($ubb eq 'login') {
	&set_page_elements;
	&LoadTemplate("public_login");
	exit(0);
}

if ($ubb eq 'agree') {
	&RequireCode("$vars_config{CGIPath}/ubb_registration.cgi");
	&do_agree;
	exit(0);
}    #end agree

if ($ubb eq 'coppa_agree') {
	&RequireCode("$vars_config{CGIPath}/ubb_registration.cgi");
	&coppa_agree;
	exit(0);
}    #end coppa_agree

if ($ubb eq 'register_page') {
	&RequireCode("$vars_config{CGIPath}/ubb_registration.cgi");
	&register_page;
	exit(0);
}    #end register_page

if ($ubb eq 'underage_register_page') {
	&GetOrPost("POST");
	if ($vars_registration{COPPAType} eq 'COPPADenied') {
		&StandardHTML("$vars_wordlets_err{age_deny}");
	} elsif ($vars_registration{COPPACheck} ne 'ON') {
		&StandardHTML("$vars_wordlets_err{coppa_turned_off}");
	} else {
		&RequireCode("$vars_config{CGIPath}/ubb_registration.cgi");
		&underage_register_page;
	}
	exit(0);
}    #end underage_register_page

if ($ubb eq 'show_coppa_form') {
	&RequireCode("$vars_config{CGIPath}/ubb_registration.cgi");
	if ($vars_registration{COPPAType} eq 'COPPADenied') {
		&StandardHTML("$vars_wordlets_err{age_deny}");
	} elsif ($vars_registration{COPPACheck} ne 'ON') {
		&StandardHTML("$vars_wordlets_err{coppa_turned_off}");
	} else {
		%vars_style = &LoadStyleTemplate($template_match{registration});

		&set_page_elements;

		my $COPPAInstructions = &ConvertReturns($vars_registration{COPPAInstructions});
		&LoadTemplate("public_reg_confirm_kid");
	}

	exit(0);
}    #end show_coppa_form

if ($ubb eq 'submit_registration') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_registration.cgi");
	&submit_registration;
	exit(0);
}    #end submit_reg

if ($ubb eq 'forum') {

	if ($in{f} =~ /CAT:/) {
		my ($j, $cat_number);
		($j, $cat_number) = split (/:/, $in{f});
		$in{category} = $cat_number;
		my $whos_online_cat_name = &GetCatName($cat_number);
		&RequireCode("$vars_config{CGIPath}/ubb_whos_online.cgi");
		&WriteUserSession("$vars_wordlets_mods{whos_online_browsing} <A HREF=\"$vars_config{CGIURL}/ultimatebb.cgi?category=$cat_number\">$whos_online_cat_name</a>", $user_number, $invisible_pref);
		&RequireCode("$vars_config{CGIPath}/ubb_forum_summary.cgi");
		&forum_summary;
	} else {
		&RequireCode("$vars_config{CGIPath}/ubb_forum.cgi");
		&get_forum;
	}
	exit(0);
}    # end forum

if ($ubb eq 'rate_member') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_profile.cgi");
	&rate_member;
	exit(0);
}    #end rate_member

if ($ubb eq 'email') {
	&RequireCode("$vars_config{CGIPath}/ubb_profile.cgi");
	&email_user;
	exit(0);
}    #end email

if ($ubb eq 'edit_my_profile') {
	&RequireCode( "$vars_config{CGIPath}/ubb_profile.cgi");
	&edit_my_profile;
	exit(0);
}    #end edit_my_profile

if ($ubb eq 'my_profile') {
	&RequireCode("$vars_config{CGIPath}/ubb_profile.cgi");
	&my_profile;
	exit(0);
}    #end my_profile

if ($ubb eq 'my_rating_list') {
	&RequireCode("$vars_config{CGIPath}/ubb_profile.cgi");
	&my_rating_list;
	exit(0);
}    #end my_rating_list

if ($ubb eq "recent_user_posts") {
	&RequireCode("$vars_config{CGIPath}/ubb_profile.cgi");
	&recent_user_posts;
	exit(0);
}    #end recent_user_posts

if ($ubb eq 'get_profile') {
	&RequireCode("$vars_config{CGIPath}/ubb_profile.cgi");
	&get_profile;
	exit(0);
}    #end get_profile

if ($ubb eq 'edit_profile') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_profile.cgi");
	&edit_profile;
	exit(0);
}    #end edit_profile



if ($ubb eq 'newtopic') {
	&RequireCode("$vars_config{CGIPath}/ubb_new_topic.cgi");
	&new_topic_page;
	exit(0);
}    #end newtopic

if ($ubb eq 'submit_new_topic') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_new_topic.cgi");
	&submit_new_topic;
	exit(0);
}    #end submit_new_topic

if ($ubb eq 'get_topic') {
	&RequireCode("$vars_config{CGIPath}/ubb_get_topic.cgi");
	&get_topic($in{f}, $in{t});
	exit(0);
}    #end get_topic

if ($ubb eq 'reply') {
	&RequireCode("$vars_config{CGIPath}/ubb_new_reply.cgi");
	&reply_page;
	exit(0);
}    #end reply

if ($ubb eq 'submit_new_reply') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_new_reply.cgi");
	&submit_new_reply;
	exit(0);
}    #end submit_new_reply

if ($ubb eq 'get_pm') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&get_pm;
	exit(0);
}    #end get_pm

if ($ubb eq 'sent_pms') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&sent_pm_box;
	exit(0);
}    #end get_pm


if ($ubb eq 'private_message') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&private_message;
	exit(0);
}    #end private_message

if ($ubb eq 'submit_private_message') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&submit_pm;
	exit(0);
}    #end submit_pm

if ($ubb eq 'pm_prune') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_prune;
	exit(0);
}    #end pm_prune

if ($ubb eq 'pm_delete') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_delete;
	exit(0);
}    #end pm_delete

if ($ubb eq 'pm_reply') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_reply;
	exit(0);
}    # end pm_reply

if ($ubb eq 'submit_pm_reply') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&submit_pm_reply;
	exit(0);
}    #end submit_pm_reply

if ($ubb eq 'ignore_list') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_list('ignore');
	exit(0);
}    #end ignore_list

if ($ubb eq 'buddy_list') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_list('buddy');
	exit(0);
}    #end buddy_list

if ($ubb eq 'do_ignore') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_do_list('ignore');
	exit(0);
}    #end do_ignore

if ($ubb eq 'do_buddy') {
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_do_list('buddy');
	exit(0);
}    #end do_buddy

if ($ubb eq 'update_ignore') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_update_list('ignore');
	exit(0);
}    #end update_ignore

if ($ubb eq 'update_buddy') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_pm.cgi");
	&pm_update_list('buddy');
	exit(0);
}    #end update_buddy

if ($ubb eq 'get_ip') {
	&RequireCode("$vars_config{CGIPath}/ubb_get_topic.cgi");
	&get_ip;
	exit(0);
}    #end get_ip

if ($ubb eq 'delete_topic') {
	&RequireCode("$vars_config{CGIPath}/ubb_topic_maint.cgi");
	&delete_topic;
	exit(0);
}    #end delete_topic

if (($ubb eq 'close_topic') || ($ubb eq 'open_topic')) {
	&RequireCode("$vars_config{CGIPath}/ubb_topic_maint.cgi");
	&topic_open_close;
	exit(0);
}    #end close_topic/open_topic

if ($ubb eq 'next_topic') {
	&RequireCode("$vars_config{CGIPath}/ubb_get_topic.cgi");
	&next_topic;
	exit(0);
}    #end next_topic

if (($ubb eq 'transfer') || ($ubb eq 'transfer_topic')) {
	&RequireCode("$vars_config{CGIPath}/ubb_topic_maint.cgi");
	&transfer_topic;
	exit(0);
}    #end transfer

if ($ubb eq 'edit_post') {
	&RequireCode("$vars_config{CGIPath}/ubb_edit_post.cgi");
	&edit_post;
	exit(0);
}    #end edit_post

if ($ubb eq 'submit_edit') {
	&GetOrPost("POST");
	&RequireCode("$vars_config{CGIPath}/ubb_edit_post.cgi");
	&submit_edit;
	exit(0);
}    #end submit_edit

if ($ubb eq 'get_daily') {
	&RequireCode("$vars_config{CGIPath}/ubb_whos_online.cgi");
	&WriteUserSession("$vars_wordlets_mods{whos_online_checking} <A HREF=\"$vars_config{CGIURL}/ultimatebb.cgi?ubb=get_daily\">$vars_wordlets_mods{whos_online_daily_topics}</a>", $user_number, $invisible_pref);
	&RequireCode("$vars_config{CGIPath}/ubb_search.cgi");
	&get_daily;
	exit(0);
}    #end get_daily

unless($vars_search{AllowSearch} ne "TRUE") {
	if ($ubb eq 'search') {
	&RequireCode("$vars_config{CGIPath}/ubb_whos_online.cgi");
	&WriteUserSession("<A HREF=\"$vars_config{CGIURL}/ultimatebb.cgi?ubb=search\">$vars_wordlets_mods{whos_online_searching}</a>", $user_number, $invisible_pref);
		&RequireCode("$vars_config{CGIPath}/ubb_search.cgi");
		&search;
		exit(0);
	}    #end search

	if ($ubb eq 'do_search') {
		&GetOrPost("POST") unless exists $in{StartPoint};
		&RequireCode("$vars_config{CGIPath}/ubb_search.cgi");
		if (($vars_search{IndexMethod} eq 'PERFORUM') && ($in{search_forum} eq 'ALL')) {
			&do_search_2;
		} else {
			&do_search;
		}
		exit(0);
	}    #end do_search
} #end check for search disabled

if ($ubb eq 'send_topic') {
	&GetOrPost("POST") if $in{send_it};
	&RequireCode("$vars_config{CGIPath}/ubb_friend.cgi");
	&send_topic;
	exit(0);
}    #end send_topic

if ($ubb eq 'faq') {
	&RequireCode("$vars_config{CGIPath}/ubb_lib_misc.cgi");
	&faq;
	exit(0);
}    #end faq

if ($ubb eq 'ubb_code_page') {
	&RequireCode("$vars_config{CGIPath}/ubb_lib_misc.cgi");
	&ubb_code_page;
	exit(0);
}    #end ubb_code_page

if ($ubb eq 'lost_password') {
	&RequireCode("$vars_config{CGIPath}/ubb_lib_misc.cgi");
	&lost_password;
	exit(0);
}    #end lost_password

if ($ubb eq 'find_lost') {
	&GetOrPost("POST") unless $in{cp} eq "cp";
	&RequireCode("$vars_config{CGIPath}/ubb_lib_misc.cgi");
	&find_lost;
	exit(0);
}    #end find_lost

# default error-- obviously they do not know where they are going
&StandardHTML("$vars_wordlets_err{dead_end}");

exit(0);    # comply with SafePerl