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__; __HTML__ ################################## # Check to see if user is logging out ################################## unless($page eq "logout"){ ################################## # Check if the user is logged in and valid ################################## %valid_user = check_valid_user($user,$pass,$org_id,$league_id,$info_id,$page); if($valid_user{"LOGIN_SUCCESS"} == 1){ ################################## # Check valid user access ################################## $access_level = check_permissions($valid_user{"LOGIN_ID"}, $org_id, $league_id, $info_id, $page); $login = 0; ################################## # if they are trying for a coach # or admin page, check verify permssions. ################################## if($admin == 1){ if(!($access_level >=3)){ print "\n"; $admin = 0; } } if($coach==1){ if(!($access_level >=2)){ print "\n"; $coach = 0; }else{ #print "\n"; } }else{ #print "\n"; } }elsif($valid_user{"LOGIN_SUCCESS"} == -1){ $failed_login = 1; $login = 1; }else{ ################################## # if not valid user (ie. not logged in) # check if it was attempting a admin # or coach ################################## if(($coach == 1)||($admin == 1)){ #print "\n"; #$coach = 0; #$admin = 0; $login = 1; } } }else{ $valid_user{"LOGIN_SUCCESS"} = 0; $coach = 0; $admin = 0; } ############################################################### ### Print the menu, right margin and top title bar ############################################################### print_top(); if($login ==1){ print_right_border($org_id); print_menu($org_id); print_login_header(); if($failed_login){ print "

Invalid ID or Password.
Please try again.
\n"; } print "\n"; print_login_block($org_id,$page,$page_id,$admin, $coach); }elsif($page eq 'logout'){ print_right_border($org_id); print_menu($org_id); print_logout($org_id); }elsif($admin == 1){ if($action eq 'moveup'){ move_left_menu($org_id,$info_id,"up"); $sub = 2; }elsif($action eq 'movedown'){ move_left_menu($org_id,$info_id,"down"); $sub = 2; }elsif($action eq 'moveup_g'){ move_gallery($org_id,$info_id,"up"); $sub = 3; }elsif($action eq 'movedown_g'){ move_gallery($org_id,$info_id,"down"); $sub = 3; } print_right_border($org_id); print_menu($org_id); print_admin($org_id, $admin, $user, $pass, $sub); }elsif($personal == 1){ print_personal($valid_user{"LOGIN_ID"}); }elsif($coach == 1){ print_right_border($org_id); $temp_info_id = print_menu($org_id); if($page eq 'league'){ if($sub eq "news"){ if($action eq 'movedown_i'){ move_info($org_id,$obj_id,"down",$info_id); }elsif($action eq 'moveup_i'){ move_info($org_id,$obj_id,"up",$info_id); } } print_coach($page, $sub, $org_id, $league_id, $user, $pass, $filter); }elsif($page eq 'field'){ print_field($month, $year, $sub, $coach, $info_id); }else{#Assume Page is info ($page eq 'info') - Info is default ### If Info ID is not defined set it to the first menu item of type info. if((!(defined($info_id)))||($info_id eq "")){ $info_id = $temp_info_id; }else{ ############################################################### ### Check if user is moving a news section ############################################################### if($action eq 'movedown_i'){ move_info($org_id,$obj_id,"down",$info_id); }elsif($action eq 'moveup_i'){ move_info($org_id,$obj_id,"up",$info_id); } } print_info($info_id, $coach); } }else{ # Normal user (ie not coach admin or personal page) print_right_border($org_id); $temp_info_id = print_menu($org_id); ### If Info ID is not defined set it to the first menu item of type info. if((!(defined($info_id)))||($info_id eq "")){ $info_id = $temp_info_id; } if($page eq 'league'){ print_league($page, $month, $year, $org_id, $league_id, $coach, $filter); }elsif($page eq 'field'){ print_field($month, $year, $sub, $coach, $info_id); }else{ #Assume Page is info ($page eq 'info') - Info is default print_info($info_id, $coach); } } ############################################################### ### not sure, may be old? ############################################################### print <<__HTML__; __HTML__ } ############################################################### ### Sub to print the Header ############################################################### sub print_start_header_main{ print <<__HTML__; $site_info{"org_full"} __HTML__ } ################################################################ ### Get DB Connection String ################################################################ sub get_dbh{ my $dbh = DBI->connect("DBI:mysql:hometeam_hometeamzpro:localhost","hometeam_hometea","123hometeamz") or die "Unable to connect: $DBI::errstr\n"; #my $dbh = DBI->connect("DBI:mysql:hometeam_hometeamzdev:localhost","hometeam_hometea","123hometeamz"); return $dbh; } sub print_login{ print "

\n"; print <<__HTML__;
Sign in
ID:
Password:
__HTML__ } ################################################################ ### This is the Main Sub routing for the home page ################################################################ sub main_sub_league_only{ ############################################################### ### Get paramters ############################################################### $coach = 0; $month = param('month'); $year = param('year'); $page = param('page'); $league_id = param('league_id'); $filter = param('filter'); $sub = param('sub'); if(!(defined($league_id))){ $league_id = 0;} if(!(defined($sub))){ $sub = "news";} if(!(defined($filter))){$filter = 0;} print header(); print_start_header_main(); print_style(1); print_league_only($page, $month, $year, $org_id, $league_id, $coach, $filter); } 1;