#!/usr/bin/perl --
###############################################################################
# AdminIndex.pl #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.5.2 #
# Packaged: October 21, 2012 #
# Distributed by: http://www.yabbforum.nz #
# =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.nz) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
### Version Info ###
$YaBBversion = 'YaBB 2.5.2';
$adminindexplver = 'YaBB 2.5.2 $Revision: 1.3 $';
# use CGI::Carp qw(fatalsToBrowser); # used only for tests
# Make sure the module path is present
push(@INC, "./Modules");
if ($ENV{'SERVER_SOFTWARE'} =~ /IIS/) {
$yyIIS = 1;
$0 =~ m~(.*)(\\|/)~;
$yypath = $1;
$yypath =~ s~\\~/~g;
chdir($yypath);
push(@INC, $yypath);
}
$adminscreen = 1;
$yyexec = "YaBB";
$script_root = $ENV{'SCRIPT_FILENAME'};
if( ! $script_root ) {
$script_root = $ENV{'PATH_TRANSLATED'};
$script_root =~ s/\\/\//gxsm;
}
$script_root =~ s/\/AdminIndex\.(pl|cgi)//ig;
require "Paths.pl";
require "$vardir/Settings.pl";
# Check allways for Time::HiRes
eval { require Time::HiRes; import Time::HiRes qw(time); };
$START_TIME = time();
if ($settings_file_version ne $YaBBversion) { # If upgrading
require "$vardir/advsettings.txt" if -e "$vardir/advsettings.txt";
require "$vardir/secsettings.txt" if -e "$vardir/secsettings.txt";
require "$vardir/membergroups.txt" if -e "$vardir/membergroups.txt";
}
require "$sourcedir/Subs.pl";
require "$sourcedir/System.pl";
require "$sourcedir/DateTime.pl";
require "$sourcedir/Load.pl";
&LoadCookie; # Load the user's cookie (or set to guest)
&LoadUserSettings; # Load user settings
&WriteLog; # write into the logfile
&WhatTemplate; # Figure out which template to be using.
&WhatLanguage; # Figure out which language file we should be using!
if ($debug) { require "$sourcedir/Debug.pl"; }
if ($referersecurity) { &referer_check; } # Check if the action is allowed from an external domain
require "$sourcedir/Security.pl";
&banning; # Check for banned people
$maintenance = 2 if !$maintenance && -e "$vardir/maintenance.lock";
# some maintenance stuff will stop after $max_process_time
# in seconds, than the browser will call the script again
# until all is done. Don't put it too high or you will run
# into server or browser timeout.
$max_process_time = 20;
$action = $INFO{'action'};
$SIG{__WARN__} = sub { &admin_fatal_error("error_occurred","@_"); };
eval { &yymain; };
if ($@) { &admin_fatal_error("untrapped",": $@"); }
sub yymain {
# Choose what to do based on the form action
if ($maintenance && $action eq 'login2') { require "$sourcedir/LogInOut.pl"; &Login2; }
# Do Sessions Checking
if (!$iamguest && $sessions == 1 && $sessionvalid != 1) {
$yySetLocation = qq~$scripturl?action=revalidatesession~;
&redirectexit;
}
# Other users can do nothing here.
if (!$iamadmin && !$iamgmod) {
if ($maintenance) { require "$sourcedir/LogInOut.pl"; &InMaintenance; }
$yySetLocation = qq~$scripturl~;
&redirectexit;
}
if ($iamgmod) {
require "$vardir/gmodsettings.txt";
if (!$allow_gmod_admin) {
$yySetLocation = qq~$scripturl~;
&redirectexit;
}
}
if ($action ne "") {
if ($action eq $randaction) {
require "$sourcedir/Decoder.pl"; &convert;
} else {
require "$admindir/AdminSubList.pl";
if ($director{$action}) {
my @act = split(/&/, $director{$action});
if ($action =~ /^ext_/) {
require "$sourcedir/$act[0]";
} else {
require "$admindir/$act[0]";
}
&{$act[1]};
} else {
require "$admindir/Admin.pl";
&Admin;
}
}
} else {
&TrackAdminLogins;
require "$admindir/Admin.pl";
&Admin;
}
}
sub ParseNavArray {
foreach $element (@_) {
chomp $element;
($action_to_take, $vistext, $whatitdoes, $isheader) = split(/\|/, $element);
if ($action_area eq $action_to_take) {
$currentclass = "class=\"current\"";
} else {
$currentclass = "";
}
if ($isheader) {
$started_ul = 1;
$leftmenu .= qq~