use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser set_message);
#set_message("We are having some trouble loading this web page for you, please contact support\@hometeamz.com for assistance.
Sorry for any inconvienece.
Thanks,
HomeTeamz Support Staff");
use Time::Local;
use DBI;
require "pyb_lib.pm";
require "new_event.pm";
sub set_globals{
my $org_id = shift;
%setup_info = get_setup_info($org_id);
$filename = $setup_info{"File_Name"};
$hometeamz_url = $setup_info{"HomeTeamz_URL"};
$base_url = $setup_info{"Base_URL"};
$hometeamz_dir = $setup_info{"HomeTeamz_Dir"};
$filename = $setup_info{"File_Name"};
$lib = $hometeamz_dir . '/lib';
$teamdata = $hometeamz_dir . '/teamdata';
$filename_wurl = $base_url . '/' . $filename;
$show_end_time = 0;
%site_info = get_site_info($org_id);
}
sub get_setup_info{
my $org_id = shift;
my %return_hash;
my $dbh = get_dbh();
# prepare and execute query
my $query = "SELECT * FROM `Setup_Info` WHERE `Org_ID` = $org_id";
#print "QUERY: $query
\n";
my $sth = $dbh->prepare($query);
$sth->execute();
# assign fields to variables
$sth->bind_columns(\$Org_ID, \$File_Name,
\$HomeTeamz_Dir, \$HomeTeamz_URL,
\$Base_URL);
while($sth->fetch()) {
$return_hash{"ORG_ID"} = $Org_ID;
$return_hash{"File_Name"} = $File_Name;
$return_hash{"HomeTeamz_Dir"} = $HomeTeamz_Dir;
$return_hash{"HomeTeamz_URL"} = $HomeTeamz_URL;
$return_hash{"Base_URL"} = $Base_URL;
}
$sth->finish();
# disconnect from database
$dbh->disconnect;
return %return_hash;
}
################################################################
### This is the Main Sub routing for the home page
################################################################
sub main_sub{
$failed_login = 0;
###############################################################
### Get paramters
###############################################################
$page = param('page');
$sub = param('sub');
$coach = param('coach');
$newnews = param('news');
$title = param('title');
$date = param('date');
$update = param('update');
$obj_id = param('obj_id');
$month = param('month');
$year = param('year');
$day = param('day');
#$org_id = param('org_id');
$league_id = param('league_id');
$user = param('user');
$pass = param('pass');
$filter = param('filter');
$admin = param('admin');
$info_id = param('info_id');
$login = param('login');
$personal = param('personal');
$action = param('action');
###############################################################
### Strip extra returns and replace with
(html) for
### the news parameter which may contain extra lines
###############################################################
if(defined($newnews)){
$newnews =~ s/\n/
/g;
$newnews =~ s/\r//g;
}
###############################################################
### Decide which web page to show based on the parameters
###############################################################
if(!(defined($admin))){ $admin = 0;}
#if(!(defined($league_id))){ $league_id = "HOME";}
if(!(defined($league_id))){ $league_id = 0;}
if(!(defined($page))){
if($admin == 0){
$page = "info";
($tmp_page_id, $page) = get_first_info_id($org_id);
if($page eq "info"){
$info_id = $tmp_page_id;
}else{
$league_id = $tmp_page_id;
}
#$info_id = get_first_info_id($org_id);
}else{
$page = "admin_home";
}
}
if(!(defined($sub))){ $sub = "news";}
if(!(defined($coach))){ $coach = 0;}
if(!(defined($update))){$update = 0;}
if(!(defined($user))){ $user = "";}
if(!(defined($pass))){ $pass = "";}
if(!(defined($filter))){$filter = 0;}
if(!(defined($login))){ $login = 0;}
if(!(defined($personal))){ $personal = 0;}
if(($page eq "info")||($page eq "field")){
$page_id = $info_id;
}else{
$page_id = $league_id;
}
%site_info = get_site_info($org_id);
$site_info{"site_banner_image"} =~ s/\/home\/homete3\/public_html//;
$site_info{"site_logo"} =~ s/\/home\/homete3\/public_html//;
#$site_info{"file_name"} = "barrington.pl";
#$site_info{"file_name_w_path"} = "http://www.hometeamz.com/cgi-bin/barrington.pl";
###############################################################
### Print Header
###############################################################
print header();
print_start_header_main();
print_style(0);
###############################################################
### Print Body of HTML doc
###############################################################
print <<__HTML__;