use Time::Local; require "reg_lib_v1_1.pm"; ############# V 1.1 ############################################################### ### Define any globals ############################################################### #$org_url = "teamdev2"; $method = "post"; #Use Post for production, it hides the parameters. #$page_url = "reg.html"; #$org_caps = "PSC"; #$default_state = "MI"; #$min_partial_pay = 300; ############################################################### ### Define email ############################################################### #$reply_to = "Reply-to: noreply\@hometeamz.com"; #$from = "noreply\@hometeamz.com "; #$org_full_name_for_email = "Plymouth Soccer Club"; ############################################################### ### Define message boxes ############################################################### #$season_text = "2008 Season"; #$welcome_text = "Welcome to the new on-line registration system for the Plymouth Soccer Club 2008 Season.
Reign On!"; #$pay_complete_message = "Thank-you for registering for the Plymouth Reign.\n

Your order is complete. If you require any assistance or if you have any questions contact registration\@plymouthsoccer.net
"; #$pay_by_check_message = "In order to complete registration by check…

  1. Please make the check payable to “Plymouth Soccer Club” for the above amount.
  2. Please mail the check to the following address…
      Plymouth Soccer Club
      PO Box 5343
      Plymouth, MI 48187

If you have any questions contact registration\@plymouthsoccer.net

\n"; ############################################################### ### Paypal ############################################################### #my $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; #my $paypal_acc = "jeremyhlmclean\@yahoo.com"; #my $paypal_acc = "jeremy_1195331242_biz\@yahoo.com"; #$paypal_acc = "jeremymclean\@gmail.com"; #my $page_url = "devreg.html"; #$thanks_url = "https://www.hometeamzonline.com/$org_url/" . $page_url . "?action=pp"; #$ipn_url = "http://www.hometeamzonline.com/pp/ipn.php"; #$base_reg_url = "https://www.hometeamzonline.com/$org_url/" . $page_url; #my $paypal_acc = "jeremymclean\@gmail.com"; #$paypal_url = "https://www.paypal.com/cgi-bin/webscr"; #my $thanks_url = "https://www.hometeamzonline.com/$org_url/thanks.html?transaction="; $phone_example = "Format 847-999-9999"; ################################################################ ### This is the admin Sub routing for the home page ################################################################ sub main_thanks{ $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'); $newemail = param('newemail'); ############################################################### ### Print Header ############################################################### %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//; print header(); print_start_header_main(); print_style(); ############################################################### ### Print Body of HTML doc ############################################################### print <<__HTML__; __HTML__ $active_id{"login"} = ""; $active_id{"create"} = ""; $active_id{"register"} = ""; $active_id{"verify"} = ""; $active_id{"pay"} = ""; #ADDED this portion to show logout feature. my $email = param('email'); my $pw = param('pw'); my $session_id = check_reg_login($email, "$pw"); if($session_id ne ""){ $transaction_id = param("transaction"); $valid = check_transaction_user($session_id, $transaction_id); }else{ $valid = 0; } print_top($session_id); #print_right_border($org_id); #print_menu($org_id); print_reg_info(); print "VALID: $valid
\n"; $active_id{"complete"} = "id=current"; print_steps(); if($valid == 1){ print_thanks($transaction_id); }else{ print_show_purchase_invalid(); } } sub check_transaction_user{ my $session = shift; my $transaction_id = shift; my $valid = 0; my $session_user = get_user_by_session($session); my $txn_user = get_user_by_transaction($transaction_id); #print "SESSION USER: $session_user
\n"; #print "TXN_USER: $txn_user
\n"; if(($session_user != 0)&&($txn_user != 0)){ if($session_user == $txn_user){ $valid = 1; } } return $valid; } sub get_user_by_transaction{ my $transaction_id = shift; my $dbh = get_dbh(); my $return_key = 0; ################################################################ # Query DB for tranasctions ################################################################ my $query = "SELECT `Account_ID` FROM `Reg_Paypal` WHERE `Transaction_ID` = '$transaction_id'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key); while($sth->fetch()) { $return_key = $Key; } $sth->finish(); $dbh->disconnect; return $return_key; } sub get_user_by_session{ my $session = shift; my $dbh = get_dbh(); my $return_key = 0; ################################################################ # Query DB for tranasctions ################################################################ my $query = "SELECT `Key` FROM `Account_Info` WHERE `Last_Access_ID` = '$session'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key); while($sth->fetch()) { $return_key = $Key; } $sth->finish(); $dbh->disconnect; return $return_key; } sub get_transactions{ my $transaction_id = shift; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB for tranasctions ################################################################ my $query = "SELECT `Key`, `Player_ID`, `Amount`, `Processed` FROM `Reg_Paypal` WHERE `Transaction_ID` = '$transaction_id'"; #my $query = "SELECT `Key`, `Player_ID`, `Amount` FROM `Reg_Paypal` WHERE `Transaction_ID` = '$transaction_id' AND `Processed` = '1'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$Player_ID, \$Amount, \$Processed); while($sth->fetch()) { $return_hash{$Player_ID}{"AMOUNT"} = $Amount; $return_hash{$Player_ID}{"PROCESSED"} = $Processed; } $sth->finish(); $dbh->disconnect; return %return_hash; } sub print_show_purchase_invalid{ #my $transaction_id = shift; #my %transactions = get_transactions($transaction_id); #my %users = get_users_by_org($org_id); #my %user_info = get_account_info($user_key); #my %player_info = get_player_info($user_key); #my %mod_player_info = get_player_info_by_key($player_key); #print "

\n"; $html = "
"; $html .= "
Invalid Transaction
You have tried to view a transaction you do not have permissions for or have been logged out of your account.
Click HERE to return to the registration page.

\n"; $html .= "
\n"; print $html; } sub print_pay_partial_complete{ #print "

\n"; my $session_id = get_cookie(); my $user_key = get_login_from_session($session_id); $active_id{"complete"} = "id=current"; print_steps(); $html = "
"; $html .= "
Step 6 : Order Complete
\n"; $html .= $pay_complete_message . "


\n"; if($org_id == 167){ # Plymouth required forms $html .= "Print Registration Confirmation and Player Forms\n"; } $html .= "\n"; $html .= "
\n"; print $html; } sub print_show_purchase{ my $transaction_id = shift; my %transactions = get_transactions($transaction_id); #my %users = get_users_by_org($org_id); #my %user_info = get_account_info($user_key); #my %player_info = get_player_info($user_key); #my %mod_player_info = get_player_info_by_key($player_key); #print "

\n"; $html = "
"; $html .= "
Step 6: Order Complete

\n"; $html .= "\n"; $user_header = "date_header"; $player_header1 = "cal_events3"; $player_header2 = "cal_events2"; $currnet_header = 2; $html .= " \n"; my $total = 0; my $count = 0; foreach my $player_key (keys %transactions) { $count++; my %player_info = get_player_info_by_key($player_key); if($player_header eq $player_header1){ $player_header = $player_header2; }else{ $player_header = $player_header1; } if($transactions{"$player_key"}{"PROCESSED"} == 1){ $processed = "Complete"; }else{ $processed = "Pending"; } $html .= " \n"; $total = $total + $transactions{"$player_key"}{"AMOUNT"}; } if($count == 0){ $html .= " \n"; } $html .= " \n"; $html .= "
Receipt #$transaction_id
$player_info{\"LASTNAME\"}, $player_info{\"FIRSTNAME\"}\$$transactions{\"$player_key\"}{\"AMOUNT\"}$processed
No Transaction Found
Total \$$total 

\n"; $html .= "

\n"; print $html; } sub print_thanks{ $transaction_id = shift; print_show_purchase($transaction_id); print "
\n"; print <<__HTML__; __HTML__ print "\n"; } ################################################################ ### This is the Main Sub routing for the home page ################################################################ sub main_registration{ $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'); $newemail = param('newemail'); $payment_s = param('payment_status'); ############################################################### ### Print Header ############################################################### %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//; print header(); print_start_header_main(); print_style(); ############################################################### ### Print Body of HTML doc ############################################################### print <<__HTML__; __HTML__ $active_id{"login"} = ""; $active_id{"create"} = ""; $active_id{"register"} = ""; $active_id{"verify"} = ""; $active_id{"pay"} = ""; #ADDED this portion to show logout feature. my $email = param('email'); my $pw = param('pw'); my $session_id = check_reg_login($email, "$pw"); if($action eq "logout"){ $session_id = ""; } print_top($session_id); #print_right_border($org_id); #print_menu($org_id); print_reg_info(); print_step_choices(); } ################################################################ ### Prints the top title bar ################################################################ sub print_top{ $session_id = shift; if($session_id ne ""){ $access_level =1; } print <<__HTML__;
__HTML__ print "
\n"; if($access_level == 1){ #print "Welcome, $valid_user{\"FIRSTNAME\"}\n"; ################################# ## If Admin ################################# if($access_level >= 3){ print "   Control Panel\n"; } if($access_level >= 1){ #print "   My Hometeamz\n"; print "   Logout"; } }else{ #print "Login"; } print <<__HTML__;
 

$site_info{"site_banner_text"}


__HTML__ } sub print_steps{ print_reg_style(); print "
\n"; print <<__HTML__;
 
__HTML__ } sub print_step_choices{ if($action eq "step2"){ ##### Log in to verify USER Account information $email = param('email'); $pw = param('pw'); $session_id = check_reg_login($email, "$pw"); if($session_id eq ""){ print_reg_login("Your username or password was incorrect."); }else{ my $has_account_extra_info = verify_account_extra_info($email); my $has_account_org_reg_link = verify_account_org_reg_link($email, $org_id); #################################### # If the user was created for a different # reason then just this reg they may # need to add the org reg link #################################### if($has_account_org_reg_link == 0){ add_user_to_account_org_reg_link($email, $org_id); } #################################### # If the user did not get extra account # info, we need to get this. #################################### if($has_account_extra_info == 0){ add_blank_user_to_account_extra_info($email, $org_id); print_update_account($email); }else{ print_verify_account_info($email); } } }elsif($action eq "sendtmppass"){ if(check_for_account($newemail) == 0){ ##### Verify Email Account print_send_temp_pw(); }else{ print_create_new_account_duplicate_email(); } }elsif($action eq "tmppw"){ $email = param('email'); $pw = param('pw'); $x = param('x'); $newemail = $email; #print "tmp_string: $x
\n"; if(defined($email)){ $bad_user_pass = "Your username or password was incorrect $pw"; }else{ $bad_user_pass = ""; } $valid_tmp_pw = check_tmp_password($email, $pw, $x); if($valid_tmp_pw == 1){ print_create_account(); }else{ print_temp_pw_login($bad_user_pass); #print_send_temp_pw($bad_user_pass); } }elsif($action eq "newaccount"){ ##### Get information to create new USER Account if(check_for_account($newemail)== 0){ print_create_account(); }else{ print_create_new_account_duplicate_email(); } }elsif($action eq "createaccount"){ ##### Create New USER Account, Get information to create new PLAYER Account $email = get_param("email"); if(check_for_account($email)== 0){ ##### Verify Email Account $user_key = createaccount(); } print_verify_account_info($email); #print_register_programs($user_key); }elsif($action eq "register"){ ##### After a USER logs in, Get information to create new PLAYER Account $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ my $user_key = param('userkey'); if((!(defined($user_key))) || ($user_key eq "")){ $email = param('email'); my %user_info = get_account_info_by_email($email); $user_key = $user_info{"KEY"}; } print_register_programs($user_key); } }elsif($action eq "remove_player"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); remove_player($player_key); #verify_multiplayer_discounts_after_remove_player($user_key, $player_key); remove_all_multiplayer_discounts_after_remove_player($user_key); add_multi_player_discount_all_players($user_key); print_register_programs($user_key); } }elsif($action eq "modify"){ ##### Get Information to Update USER Account $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ $email = param('email'); print_update_account($email); } }elsif($action eq "modifyaccount"){ ##### Modify USER Account, Verify Information $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ $email = update_account(); print_verify_account_info($email); } }elsif($action eq "createaplayerccount"){ ##### Create PLAYER account, Verify Information $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ my $user_key = param('userkey'); my $new_player_id = create_new_player($org_id, $reg_year); #check_for_multiplayer_discounts($user_key, $new_player_id); remove_all_multiplayer_discounts_after_remove_player($user_key); add_multi_player_discount_all_players($user_key); print_verify_register_programs($new_player_id); } }elsif($action eq "updateplayerccount"){ ###### Modify PLAYER Account, Verify Information $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ my $player_id = param('playerkey'); my $user_key = param('userkey'); my $first_name = get_param("fname"); my $last_name = get_param("lname"); update_player_name($player_id, $first_name, $last_name); get_player_params_and_update_database($org_id, $reg_year, $player_id, $user_key); print_verify_register_programs($player_id); } }elsif($action eq "modify_player"){ #### Get Information to Modify PLAYER $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_modify_player(); } }elsif($action eq "pay"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_pay(); } }elsif($action eq "pay_by_check"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_pay_by_check(); } }elsif($action eq "partial"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_pay_partial(); } }elsif($action eq "verify_partial"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_verify_pay_partial(); } }elsif($action eq "forgot_pw"){ print_forgot_pw(); }elsif($action eq "send_pw"){ $found_email = send_pw(); if($found_email == 1){ print_reg_login("Your Password will be sent to you shortly"); }else{ print_forgot_pw("I'm sorry, we could not find that email,
if this problem continues, please
contact support\@hometeamz.com"); } }elsif($action eq "logout"){ print "\n"; print_reg_login("You have successfully logged out."); }elsif($action eq "pay_by_check_complete"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_pay_partial_complete(); } }elsif($action eq "pp"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_pay_partial_complete(); } }elsif($payment_s eq "Completed"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_pay_partial_complete(); } }else{ print_reg_login(); } print "
\n"; print <<__HTML__; __HTML__ print "\n"; } ############################################ # Step 1. login or create new account ############################################ sub print_forgot_pw{ my $msg = shift; if($msg ne ""){ $alert =<<__HTML__
$msg

__HTML__ } $active_id{"login"} = "id=current"; print_steps(); my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__; $alert
Step 1: User Login - Retrieve Password
Enter your email and click Get Password and we will email you your password.

Enter Email
Email
__HTML__ print $html; } ########################################### # Modify player info on main registration ########################################### sub print_modify_player{ my $user_key = param('userkey'); my $player_key = param('playerkey'); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my %mod_player_info = get_player_info_by_key($player_key); my $account_table = get_account_table($user_key); my ($user_table, $player_num) = get_player_table($user_key); $active_id{"register"} = "id=current"; print_steps(); my $phone_validation = get_phone_validation(); %reg_form = get_reg_update_form($org_id, "$reg_year","create_player_account_form", $player_key); my $auto_reg_form = ""; my $first_compare = 1; foreach $form_row (sort{$a <=> $b}keys %reg_form){ if(defined($reg_form{"$form_row"}{"JSCRIPT_VARS"})){ $jscript_vars .= $reg_form{"$form_row"}{"JSCRIPT_VARS"}; } if(defined($reg_form{"$form_row"}{"JSCRIPT_COMPARE"})){ my $or = ""; if($first_compare == 1){ $first_compare = 0; }else{ $or = "||" } $jscript_compare .= $or . $reg_form{"$form_row"}{"JSCRIPT_COMPARE"} ; } $auto_reg_form .= $reg_form{"$form_row"}{"HTML"}; } my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; if($user_info{"ADDRESS2"} ne ""){ $address2 = "$user_info{\"ADDRESS2\"}
"; }else{ $address2 = ""; } my $html = <<__HTML__;
$account_table $user_table

Step 3:Update Registration
Please complete the information listed below...
    * Required Fields
$auto_reg_form
Player Information
Player First Name*
Player Last Name*


* Required Fields
__HTML__ print $html; } sub print_pay_by_check{ $active_id{"pay"} = "id=current"; my $user_key = param('userkey'); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my ($user_table, $pay_pal) = get_checkout_table($user_key, 1); my $account_table = get_account_table($user_key); print_steps(); print "
\n"; print "
Step 5 : Pay by Check
Please verify your registration prior to sending the check.

\n"; print $account_table . "

" . $user_table, "
"; print "
\n"; } sub is_older_than_cutoff{ my $dob = shift; my $gender = shift; my $cost = 150; if($gender eq "male"){ ################################## # If born before this date add $25 ################################## my $cut_off = "1995-05-01"; my $league_start_date = "2008-05-01"; my $older_than_cut_off = 0; my ($year, $month, $day) = split(/-/, $dob); my ($cyear, $cmonth, $cday) = split(/-/, $cut_off); my ($syear, $smonth, $sday) = split(/-/, $league_start_date); my $hour = 0; my $sec = 0; my $min = 0; $year = $year - 1900; $cyear = $cyear - 1900; $syear = $syear - 1900; $month = $month -1; $cmonth = $cmonth -1; $smonth = $smonth -1; #if($month < 1){$month = 1;} #if($day < 1){$day =1;} my $dob_epoch = timelocal($sec,$min,$hour,$day,$month,$year); my $cdob_epoch = timelocal($sec,$min,$hour,$cday,$cmonth,$cyear); my $sdob_epoch = timelocal($sec,$min,$hour,$sday,$smonth,$syear); if($dob_epoch < $cdob_epoch){ $older_than_cut_off = 1; $cost = $cost + 25; } } return $cost; } sub convert_epoch_to_years{ my $age_epoch = shift; my $seconds_in_year = 60*60*24*365; my $age_in_years =sprintf("%.3f", $age_epoch/$seconds_in_year); return $age_in_years; } sub get_transaction_id{ my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Transaction_ID` FROM `TMP_TRANSACTION_ID` WHERE 1"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Transaction_ID); while($sth->fetch()) { $return_id = $Transaction_ID; } # disconnect from database $query = "UPDATE `TMP_TRANSACTION_ID` SET `Transaction_ID`=`Transaction_ID`+1 WHERE `Transaction_ID` = '$return_id'"; $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->finish(); $dbh->disconnect; return $return_id; } sub insert_tmp_paypal{ my $account_id = shift; my $player_id = shift; my $amount = shift; my $transaction_id = shift; my $date = get_date_time(); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "INSERT INTO `Reg_Paypal` (`Key`, `Account_ID`, `Player_ID`, `Amount`, `Transaction_ID`, `PP_Transaction_ID`, `Processed`, `Date`) VALUES ('', '$account_id', '$player_id', '$amount', '$transaction_id','0', '0', '$date')"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->finish(); $dbh->disconnect; } sub get_amount_to_deduct{ my $partial = shift; my $total_remaining_players = shift; my $total_running_cost = shift; my $max_deduction = shift; my $player_min = shift; my $partial_remaining = $partial - $total_running_cost; my $deduction = 0; my $amount_to_deduct = 0; if($total_remaining_players > 0){ $amount_to_deduct = sprintf("%.2f", ($partial_remaining/$total_remaining_players)); $rounded_total = $amount_to_deduct * $total_remaining_players; if($rounded_total > $partial_remaining){ $deduction = $amount_to_deduct - ($rounded_total - $partial_remaining); }elsif($rounded_total < $partial){ $deduction = $amount_to_deduct + ($partial_remaining - $rounded_total); }else{ $deduction = $amount_to_deduct; } }else{ $deduction = 0; } #print "ATD: $amount_to_deduct RT: $rounded_total PM: $partial_remaining - TMP: $total_remaining_players - D:$deduction - MAX:$max_deduction
\n"; ### If the deduction is greater than the max deduction set to max ### Also if the deduction is greater than max deduction, set it to max ### in order to lower the total. if(($deduction > $max_deduction)||($deduction >= $player_min)){ $deduction = $max_deduction; if($deduction > $partial_remaining){$deduction = $partial_remaining;} } if($deduction < 0){ $deduction = 0; } $deduction = sprintf("%.2f", $deduction); return $deduction; } sub get_num_players_and_total_cost{ my $user_key = shift; my %player_info = get_player_info($user_key); my $num_players = 0; my $total_cost = 0; my $player_min = 99999; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; my $player_total = 0; my %adjustment_info = (); my $player_key = $player_info{$user_number}{"KEY"}; my $amount_paid = $player_info{$user_number}{"PAID"}; ($player_total, %adjustment_info) = get_adjustment_info($player_key); $player_total = $player_total - $amount_paid; if($player_total < $player_min){if($player_total != 0){$player_min = $player_total;}} $total_cost = $player_total + $total_cost; } return $num_players, $total_cost, $player_min; } sub get_num_players_and_total_cost2{ my $user_key = shift; #my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my $num_players = 0; my $total_cost = 0; my $player_min = 180; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; my $base_cost = is_older_than_cutoff($player_info{$user_number}{"DOB"},$player_info{$user_number}{"GENDER"}); if($num_players > 2){$fundraiser_fee = 0; $fundraiser_string = "";}else{$fundraiser_fee = 30; $fundraiser_string = "+ \$30 Fundraiser";} if($num_players > 1){$discount = 15; $discount_string = "-\$15 multiplayer discount";}else{$discount = 0;$discount_string = "";} $amount_paid = $player_info{$user_number}{"PAID"}; $player_total = $base_cost + $fundraiser_fee - $discount - $amount_paid; if($player_total < $player_min){if($player_total != 0){$player_min = $player_total;}} $total_cost = $player_total + $total_cost; } return $num_players, $total_cost, $player_min; } sub print_verify_pay_partial{ $active_id{"pay"} = "id=current"; my $user_key = param('userkey'); my $partial = param('partial_amount'); my $min_pay_message = ""; #################################### # Check if the partial payment is less than he min partial pay # if it is, set the message and change the payment to the min # If the min is greater then the balance, this will be handled # in the get_partial_checkout_table function #################################### if($partial < $min_partial_pay){ $partial = $min_partial_pay; $min_pay_message = "
The minimum partial payment is \$$min_partial_pay

"; } my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my ($user_table, $pay_pal, $balance) = get_partial_checkout_table($user_key, 2, $partial); print_steps(); #################################### # Set the min_pay_message to blank if balance is less than # min_partial_pay #################################### if($balance < $min_partial_pay){ $min_pay_message = ""; } $verify_form = "
\n"; $verify_form .= ""; $verify_form .= "\n"; $verify_form .= "
\n"; $pay_by_check_form = "
\n"; $pay_by_check_form .= ""; $pay_by_check_form .= "\n"; $pay_by_check_form .= "
\n"; print "\n"; print "
Step 5:Verify Partial Payment
Please enter the partial payment amount you wish to pay below.$min_pay_message

\n"; print "
\n"; print $user_table, "
"; print $verify_form; print $pay_by_check_form; print $pay_pal; print "
\n"; } sub print_pay_partial{ $active_id{"pay"} = "id=current"; my $user_key = param('userkey'); my $partial = param('partial_amount'); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my ($user_table, $pay_pal, $balance) = get_partial_checkout_table($user_key, 0, $partial); print_steps(); $verify_form = "
\n"; $verify_form .= ""; $verify_form .= "\n"; $verify_form .= "
\n"; $pay_by_check_form = "
\n"; $pay_by_check_form .= ""; $pay_by_check_form .= "\n"; $pay_by_check_form .= "
\n"; print "\n"; print "
Step 5: Enter Partial Payment Amount
Please enter the partial payment amount you wish to pay below.

\n"; print "
\n"; print $user_table, "
"; print $verify_form; print $pay_by_check_form; print $pay_pal; print "
\n"; } sub print_pay{ $active_id{"pay"} = "id=current"; my $user_key = param('userkey'); my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my ($user_table, $pay_pal) = get_checkout_table($user_key, 0); print_steps(); $full_or_partial = <<__JSCRIPT__; __JSCRIPT__ $verify_form = "
\n"; $verify_form .= ""; $verify_form .= "\n"; $verify_form .= "
\n"; $exit_button = "\n"; $pay_by_check_form = "
\n"; $pay_by_check_form .= ""; $pay_by_check_form .= "\n"; $pay_by_check_form .= "
\n"; print "$full_or_partial
\n"; print "
Step 5:Verify Order
Please verify your registration prior to checkout.

\n"; ###################################### # Check if all players are confirmed # and Create confirmation table ###################################### my $all_players_confirmed = 1; my $player_count = 0; my %status_hash = get_status_hash($org_id, $reg_year); my $player_confirmed_table = ""; $player_confirmed_table .= ""; foreach my $this_user_key (keys %player_info){ my $this_player_confirmed_state = $player_info{$this_user_key}{'PLAYER_CONFIRMED'}; # Note that this is really a state my $this_player_confirmed = $status_hash{$this_player_confirmed_state}{"ACCEPTED_STATE"}; ###################################### # Track if all players are confirmed ###################################### if( $this_player_confirmed == 0){ $all_players_confirmed = 0; } ###################################### # Check if this player is confirmed ###################################### my $player_registered = "No"; if($this_player_confirmed == 1){ $player_registered = "Yes"; } $player_confirmed_table .= "\n"; #print "Player Confirmed?: $this_user_key: $player_info{$this_user_key}{'PLAYER_CONFIRMED'}
\n"; $player_count++; } $player_confirmed_table .= "
Name
Registration Confirmed
$player_info{$this_user_key}{'FIRSTNAME'} $player_info{$this_user_key}{'LASTNAME'}
$player_registered
"; if($player_count < 1){ $all_players_confirmed = 0; } ###################################### # Set revise order button, this is set somewhere else and also # requires that the verify_form is available ###################################### $revise_order_button = "\n"; $revise_order_button_league_confirm = "\n"; ###################################### # Check if there is at least 1 player ###################################### if($player_count < 1){ my $msg = "There are currently no Registered Players."; $msg = format_alert($msg); print $msg; #print "
$msg
\n"; print $verify_form; print $revise_order_button . "
\n"; }else{ ###################################### # Check if all players are confirmed ###################################### if(($require_confirmation == 1)&&($all_players_confirmed == 0)){ print "$require_confirmation_msg

\n"; print $player_confirmed_table . "
\n"; print $verify_form; print $revise_order_button_league_confirm . "    " . $exit_button . "
\n"; }else{ print $user_table, "
"; print $verify_form; print $pay_by_check_form; print $pay_pal; } } #print "
Require_Confirmation: $require_confirmation
\n"; #print "
All Players Confirmed: $all_players_confirmed
\n"; print "
\n"; } sub get_player_id_from_cookie{ my $session_id = get_cookie(); my $login = get_login_from_session($session_id); return $login; } ################################################################ ### Update adjustemnt ################################################################ sub insert_walkin_adjustment{ my $player_key = shift; my $amount = shift; my $check_notes = "Walk In"; my $update_account = get_player_id_from_cookie(); my $account_id = get_account_id_by_player_key($player_key); my $date = get_date_time(); my $query = "INSERT INTO Reg_All_Transaction ( `Key` , `Account_ID` , `Player_ID` , `Update_Account_ID`, `Amount`, `Check_ID`, `Date`) VALUES ('', '$account_id', '$player_key', '$update_account', '$amount', '$check_notes', '$date')"; #print "$query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $player_key; } sub check_for_first_player_for_user{ my $user_key = shift; my $dbh = get_dbh(); my $query = "SELECT `Key` FROM `Account_Player_Info` WHERE `Account_ID` = '$user_key'"; #print "$query
\n"; my $sth = $dbh->prepare($query); my $first_player = 1; $sth->execute(); $sth->bind_columns(\$Key); ################################################################ # Loop through what the db returned, if there is somthing there # it assumes success. ################################################################ while($sth->fetch()) { $first_player = 0; } return $first_player; } ################################################################ ### Update user info in db ################################################################ sub update_account{ $lname = get_param("lname"); $fname = get_param("fname"); $email = param("email"); $ad1 = get_param("ad1"); $ad2 = get_param("ad2"); $city = get_param("city"); $state = param("state"); $zip = param("zip"); $phone = get_param("phone"); $mphone = get_param("mphone"); my $dbh = get_dbh(); my $query = "UPDATE `Account_Info` a, `Account_Extra_Info` b SET a.`Firstname`='$fname', a.`Lastname`='$lname', a.`Home_Phone`='$phone', a.`Mobile_Phone`='$mphone', a.`Zip_Code`='$zip', b.`Address1`='$ad1' , b.`Address2`='$ad2' , b.`City`='$city', b.`State`='$state' WHERE a.`email`='$email' AND a.`Key` = b.`Account_ID`;"; #print "Q: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $email; } ################################################################ ### Print verify user registration ################################################################ sub print_verify_account_info{ my $email = shift; my %user_info = get_account_info_by_email($email); $active_id{"create"} = "id=current"; print_steps(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 2: Verify Account Owner Information
Please verify your account information for the primary person responsible for payment and under whom the participants will be listed.

Account Holder Information
First Name  $user_info{"FIRSTNAME"}
Last Name  $user_info{"LASTNAME"}
Email  $user_info{"EMAIL"}
Address 1  $user_info{"ADDRESS1"}
Address 2  $user_info{"ADDRESS2"}
City  $user_info{"CITY"}
State  $user_info{"STATE"}
Zip  $user_info{"ZIP_CODE"}
Phone  $user_info{"HOMEPHONE"}
Mobile Phone  $user_info{"MOBILE_PHONE"}

The above information is correct...

The above information is not correct...
__HTML__ print $html; } ################################################################ ### Get the HTML player table show in upper right corner ################################################################ sub get_player_table{ my $user_key = shift; my %player_info = get_player_info($user_key); my $user_table = "\n"; #$user_table .= "\n"; $user_table .= "\n"; my $player_number = 1; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $player_number++; $division_id = $player_info{$user_number}{"DIVISION"}; $player_key = $player_info{$user_number}{"KEY"}; $amount_paid = $player_info{$user_number}{"PAID"}; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; #$user_table .= "\n"; $last_user = $user_number; } $user_table .= "
Registered Players
NameDivisioneditremovePaid
NameEditRemove
$player_info{$user_number}{\"FIRSTNAME\"} $player_info{$user_number}{\"LASTNAME\"}\$$amount_paid
\n"; return $user_table, $player_number; } ################################################################ ### Print Player registration form ################################################################ sub print_register_programs{ my $user_key = shift; my %user_info = get_account_info($user_key); my %player_info = get_player_info($user_key); my $account_table = get_account_table($user_key); my ($user_table, $player_number) = get_player_table($user_key); $active_id{"register"} = "id=current"; print_steps(); %reg_form = get_reg_form($org_id, "$reg_year","create_player_account_form", $user_key); my $auto_reg_form = ""; my $first_compare = 1; foreach $form_row (sort{$a <=> $b}keys %reg_form){ if(defined($reg_form{"$form_row"}{"JSCRIPT_VARS"})){ $jscript_vars .= $reg_form{"$form_row"}{"JSCRIPT_VARS"}; } if(defined($reg_form{"$form_row"}{"JSCRIPT_COMPARE"})){ my $or = ""; if($first_compare == 1){ $first_compare = 0; }else{ $or = "||" } $jscript_compare .= $or . $reg_form{"$form_row"}{"JSCRIPT_COMPARE"} ; } $auto_reg_form .= $reg_form{"$form_row"}{"HTML"}; } #print "
\n"; my $phone_validation = get_phone_validation(); $jscript_compare .= '||(lname.value == "")||(fname.value == "")'; $submit_to_pay = get_submit_to_pay($user_key); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; if($user_info{"ADDRESS2"} ne ""){ $address2 = "$user_info{\"ADDRESS2\"}
"; }else{ $address2 = ""; } my $player_header = "Player #$player_number"; my $form_first_name = "Player First Name*"; my $form_last_name = "Player Last Name*"; my $html = <<__HTML__;
$account_table $user_table
$submit_to_pay

Step 3:Register for Programs
Please complete the information listed below...
    * Required Fields
$player_header $form_first_name $form_last_name $auto_reg_form __HTML__ $html .= <<__HTML__;


* Required Fields
__HTML__ print $html; } ################################################################ ### Print verify Player registration ################################################################ sub print_verify_register_programs{ my $player_key = shift; my $user_key = param("userkey"); my $checkout_button_value = get_submit_to_pay_button_value($user_key); #my %user_info = get_account_info($user_key); my %player_info = get_player_info_by_key($player_key); $active_id{"verify"} = "id=current"; %reg_form = get_read_only_reg_form($org_id, "$reg_year","create_player_account_form", $player_key); my $auto_reg_form = ""; my $first_compare = 1; foreach $form_row (sort{$a <=> $b}keys %reg_form){ if(defined($reg_form{"$form_row"}{"JSCRIPT_VARS"})){ $jscript_vars .= $reg_form{"$form_row"}{"JSCRIPT_VARS"}; } if(defined($reg_form{"$form_row"}{"JSCRIPT_COMPARE"})){ my $or = ""; if($first_compare == 1){ $first_compare = 0; }else{ $or = "||" } $jscript_compare .= $or . $reg_form{"$form_row"}{"JSCRIPT_COMPARE"} ; } $auto_reg_form .= $reg_form{"$form_row"}{"HTML"}; } print_steps(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;

Step 4:Verify Program Registration
Please verify the player information listed below.

$auto_reg_form __HTML__ print $html; } sub get_submit_to_pay_button_value{ my $user_key = shift; my $button_value = ""; if($require_confirmation == 1){ if(check_if_all_users_are_confirmed($user_key) == 1){ $button_value = "Continue to Checkout"; }else{ $button_value = "Complete Pre-Registration"; } }else{ $button_value = "Continue to Checkout"; } return $button_value; } sub get_submit_to_pay{ my $user_key = shift; my $button_value = get_submit_to_pay_button_value($user_key); my $return_val = <<__HTML__;
Register additional players below or
proceed to
__HTML__ return $return_val; } ################################################################ ### Creates new user account in db ################################################################ sub createaccount{ $lname = get_param("lname"); $fname = get_param("fname"); $email = get_param("email"); $ad1 = get_param("ad1"); $ad2 = get_param("ad2"); $city = get_param("city"); $state = param("state"); $zip = get_param("zip"); $phone = get_param("phone"); $mphone = get_param("mphone"); $pw1 = get_param("pw1"); $pw2 = get_param("pw2"); my $dbh = get_dbh(); my $query = "INSERT INTO `Account_Info` ( `Key` , `Login` , `Password` , `email` , `League_ID`, `Last_Access`, `Last_Access_ID`, `Firstname`, `Lastname`, `Title`, `Home_Phone`, `Work_Phone`, `Mobile_Phone`, `Zip_Code`) VALUES ('', '$email', '$pw1', '$email', '', '', '', '$fname', '$lname', 'USER', '$phone', '', '$mphone', '$zip');"; #print "$query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; my $new_key = check_for_account($email); ########################################### # Add extra Info ########################################### $dbh = get_dbh(); my $query2 = "INSERT INTO `Account_Extra_Info` ( `Key` , `Account_ID` , `Address1` , `Address2` , `City`, `State`)VALUES ('', '$new_key', '$ad1', '$ad2', '$city', '$state');"; #print "Q2:$query2
\n"; $sth = $dbh->prepare($query2); $sth->execute(); $sth->finish(); ########################################### # Link Account to Org ########################################### $dbh = get_dbh(); my $query3 = "INSERT INTO `Account_Org_Reg_Link` ( `Key` , `Account_ID` , `Org_ID`)VALUES ('', '$new_key', '$org_id');"; #print "Q2:$query2
\n"; $sth = $dbh->prepare($query3); $sth->execute(); $sth->finish(); $dbh->disconnect; check_reg_login($email, "$pw1"); remove_temp_password($email); return $new_key; } ################################################################ ### Remove Temp Password from db ################################################################ sub remove_temp_password{ my $email = shift; ########################################### # Link Account to Org ########################################### my $dbh = get_dbh(); my $query = "DELETE FROM `Account_TMP_Password` WHERE `EMAIL`='$email' LIMIT 1;"; #print "Q2:$query2
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; } ################################################################ ### Check to see if the user is logged in ################################################################ sub check_reg_login{ my $user = shift; my $pass = shift; my $league_id = shift; my $success = 0; my $session = ""; my $session_id = get_cookie(); if(($user ne "") && ($pass ne "")){ $session_id = ""; } my $dbh = get_dbh(); ################################################################ # Check to see if there is a valid cookie ################################################################ if($session_id eq ""){ ################################################################ # If not a valid cookie, check the to see if the user/pass # combination is correct ################################################################ if(($user ne "") && ($pass ne "")){ print "\n"; $session_id = ""; my $query = "SELECT * FROM `Account_Info` WHERE (`Login` = '$user' OR `email` = '$user') AND `Password` = '$pass'"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key, \$Login, \$Password, \$email, \$League_ID, \$Last_Access, \$Last_Access_ID, \$Firstname, \$Lastname, \$Title, \$Home_Phone, \$Work_Phone, \$Mobile_Phone, \$Zip_Code); ################################################################ # Loop through what the db returned, if there is somthing there # it assumes success. ################################################################ while($sth->fetch()) { $success = 1; } ################################################################ # Login failed because incorrect Login or password ################################################################ if($success == 0){ print "

Invalid ID or Password.
Please try again.
\n"; $session_id = ""; #print "\n"; }else{ $current_date = get_date_time(); $session_id = generate_random_string(15); $update = "UPDATE `Account_Info` SET `Last_Access`='$current_date', `Last_Access_ID`='$session_id' WHERE `Key` = $Key;"; ##print "QUERY: $update
\n"; $sth = $dbh->prepare($update); $sth->execute(); print <<__HTML__; __HTML__ } }else{ ################################################################ # Login failed because no Login or password # Could be first time loggin in. ################################################################ $session_id = ""; } }else{ #print "\n"; ################################################################ # Query DB to verify Session ################################################################ $query = "SELECT * FROM `Account_Info` WHERE `Last_Access_ID` = '$session_id'"; $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key, \$Login, \$Password, \$email, \$League_ID, \$Last_Access, \$Last_Access_ID, \$Firstname, \$Lastname, \$Title, \$Home_Phone, \$Work_Phone, \$Mobile_Phone, \$Zip_Code); ################################################################ # Loop through what the db returned, if there is somthing there # it assumes success. ################################################################ while($sth->fetch()) { $success = 1; } ################################################################ # If we get to this point. The cookie is invalid at least for # this league. ################################################################ if($success == 0){ #print "

Your Session has expired,
Please login again.
\n"; print "\n"; $session_id = ""; }else{ ################################################################ # Update DB to keep session active ################################################################ $current_date = get_date_time(); $update = "UPDATE `Account_Info` SET `Last_Access`='$current_date' WHERE `Key` = $Key;"; ##print "QUERY: $update
\n"; $sth = $dbh->prepare($update); $sth->execute(); ################################################################ # Update Cookie to keep session active ################################################################ print <<__HTML__; __HTML__ } } ################################################################ # Close DB connection ################################################################ $sth->finish(); # disconnect from database $dbh->disconnect; return $session_id; } sub print_update_account{ my $email = shift; my %user_info = get_account_info_by_email($email); $active_id{"create"} = "id=current"; print_steps(); my $email_validation = get_email_validation(); my $phone_validation = get_phone_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Player Information
Player First Name:$player_info{"FIRSTNAME"}
Player Last Name:$player_info{"LASTNAME"}

The above information is correct...

The above information is not correct...
Step 2 : Modify Account
Please enter account information for the primary person responsible for payment and under whom the participants will be listed.

Modify Account Owner Information
*First Name
*Last Name
*Email
*Address 1
Address 2
*City
*State
*Zip
*Phone $phone_example
Mobile Phone $phone_example


* Required Fields
__HTML__ print $html; } sub print_create_account{ $active_id{"create"} = "id=current"; my @states = get_states(); print_steps(); my $email_validation = get_email_validation(); my $phone_validation = get_phone_validation(); my $zip_validation = get_zip_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 2 : Create Account
Please enter account information for the primary person responsible for payment and under whom the participants will be listed.

Enter Account Owner Information
*First Name
*Last Name
*Email
*Address 1
Address 2
*City
*State
*Zip
*Phone $phone_example
Mobile Phone $phone_example
*Create New Password
*Re-type Password


* Required Fields
__HTML__ print $html; } ############################################ # Step 1. login or create new account ############################################ sub print_admin_login{ my $msg = shift; if($msg ne ""){ $alert =<<__HTML__
$msg

__HTML__ } $active_id{"login"} = "id=current"; print "
\n"; #print_steps(); print_reg_style(); my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
$alert
Registration Admin Login

Admin Account
Email
Password
__HTML__ print $html; } sub format_alert{ $msg = shift; if($msg ne ""){ $alert =<<__HTML__;
$msg

__HTML__ }else{ $alert = ""; } return $alert; } sub print_send_temp_pw{ #### Send Emails my $alert = shift; my $found_email = ""; my $tmp_string = ""; $active_id{"login"} = "id=current"; $alert = format_alert($alert); ($found_email, $tmp_string) = send_tmppw($newemail); print_steps(); my $html = <<__HTML__; $alert
Step 1: Validate Your New Account
IMPORTANT!! A temporary password has been emailed to you from $org_caps . Please enter this temporary password below to validate your new account. You will be able to change your password at a later time.

Verify New Account
Email:

Enter the temporary password emailed to you:
 
__HTML__ print $html; } sub get_email_by_x{ my $x = shift; my $return_email = ""; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Email` FROM `Account_TMP_Password` WHERE `Tmp_String` = '$x';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Email); while($sth->fetch()) { $return_email = $Email; } # disconnect from database $sth->finish(); $dbh->disconnect; return $return_email; } sub print_temp_pw_login{ #### Does not send email my $alert = shift; $active_id{"login"} = "id=current"; my $x = param('x'); my $show_login = 0; if(!(defined($x))){ $x = ""; } #my $alert = ""; if(!(defined($newemail))){ $newemail = get_email_by_x($x); if($newemail eq ""){ $alert = "Your temporary password is no longer active, please try again."; $show_login = 1; } } if($show_login == 0){ $alert = format_alert($alert); print_steps(); my $html = <<__HTML__; $alert
Step 1: Verify Email
Please use your temporary password to log in.

Existing Account
Email
Temp Password
 
__HTML__ print $html; }else{ print_reg_login($alert); } } ############################################ # Step 1. login or create new account ############################################ sub print_reg_login{ my $msg = shift; if($msg ne ""){ $alert =<<__HTML__
$msg

__HTML__ } $active_id{"login"} = "id=current"; print_steps(); my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__; $alert
Step 1: User Login
Please login or create a new account. Your account is used to register your children for programs as well as tracking the status of your registration.

New Account
Email

Existing Account
Email
Password
Forget Password? Click Here
__HTML__ print $html; } ############################################ # This is for when the account already # exist, prompt for a new account ############################################ sub print_create_new_account_duplicate_email{ $active_id{"login"} = "id=current"; print_steps(); my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 1: User Login
There is already an account created for that email, please login or try a different account name.

New Account
Email

Existing Account
Email
Password
Forget Password? Click Here
__HTML__ print $html; } ############################################ # Get player info ############################################ sub get_states{ my @states=("AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"); return @states; } ############################################ # Get player info2, this one returns the # Key as the main index ############################################ sub get_player_info2{ my $user_key = shift; my $return_hash = 0; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT * FROM `Account_Player_Info` WHERE `Account_ID` = '$user_key' AND `Active` = '1' ORDER BY `Key`"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$Account_ID, \$Firstname, \$Lastname, \$Division_Pref, \$Shirt_Size, \$Pant_Size, \$Hat_Size, \$Shoe_Size, \$Jersey_Pref, \$DOB, \$Gender, \$School_Name, \$Grade, \$Age, \$Height, \$Weight, \$E_Contact_Name, \$E_Contact_Phone, \$E_Contact_SPhone, \$E_Contact_Relationship, \$G_Contact_Phone, \$G_Contact_SPhone, \$G_Contact_Name, \$G_Contact_Relationship, \$OG_Contact_Phone, \$OG_Contact_SPhone, \$OG_Contact_Name, \$OG_Contact_Relationship, \$Preferred_Doc_Name, \$Preferred_Doc_Number, \$Preferred_Dentist_Name, \$Preferred_Dentist_Number, \$Preferred_Hospital, \$Insurance_Carrier, \$Policy_Number, \$Medical_History, \$Returning_Player, \$Paid, \$Active, \$Consent, \$Consent_Actions, \$Play_Up); $user_number = 1; while($sth->fetch()) { $return_hash{$Key}{"KEY"} = $Key; $return_hash{$Key}{"FIRSTNAME"} = $Firstname; $return_hash{$Key}{"LASTNAME"} = $Lastname; $return_hash{$Key}{"DIVISION"} = $Division_Pref; $return_hash{$Key}{"SHIRT_SIZE"} = $Shirt_Size; $return_hash{$Key}{"PANT_SIZE"} = $Pant_Size; $return_hash{$Key}{"HAT_SIZE"} = $Hat_Size; $return_hash{$Key}{"SHOE_SIZE"} = $Shoe_Size; $return_hash{$Key}{"JERSEY_PREF"} = $Jersey_Pref; $return_hash{$Key}{"DOB"} = $DOB; $return_hash{$Key}{"GENDER"} = $Gender; $return_hash{$Key}{"SNAME"} = $School_Name; $return_hash{$Key}{"GRADE"} = $Grade; $return_hash{$Key}{"AGE"} = $Age; $return_hash{$Key}{"HEIGHT"} = $Height; $return_hash{$Key}{"WEIGHT"} = $Weight; $return_hash{$Key}{"E_CONTACT_PHONE"} = $E_Contact_Phone; $return_hash{$Key}{"E_CONTACT_SPHONE"} = $E_Contact_SPhone; $return_hash{$Key}{"E_CONTACT_NAME"} = $E_Contact_Name; $return_hash{$Key}{"E_CONTACT_REL"} = $E_Contact_Relationship; $return_hash{$Key}{"G_CONTACT_PHONE"} = $G_Contact_Phone; $return_hash{$Key}{"G_CONTACT_SPHONE"} = $G_Contact_SPhone; $return_hash{$Key}{"G_CONTACT_NAME"} = $G_Contact_Name; $return_hash{$Key}{"G_CONTACT_REL"} = $G_Contact_Relationship; $return_hash{$Key}{"OG_CONTACT_PHONE"} = $OG_Contact_Phone; $return_hash{$Key}{"OG_CONTACT_SPHONE"}= $OG_Contact_SPhone; $return_hash{$Key}{"OG_CONTACT_NAME"} = $OG_Contact_Name; $return_hash{$Key}{"OG_CONTACT_REL"} = $OG_Contact_Relationship; $return_hash{$Key}{"PREF_DOC_NAME"} = $Preferred_Doc_Name; $return_hash{$Key}{"PREF_DOC_NUMB"} = $Preferred_Doc_Number; $return_hash{$Key}{"PREF_DENT_NAME"} = $Preferred_Dentist_Name; $return_hash{$Key}{"PREF_DENT_NUMB"} = $Preferred_Dentist_Number; $return_hash{$Key}{"PREF_HOSPITAL"} = $Preferred_Hospital; $return_hash{$Key}{"INSURANCE"} = $Insurance_Carrier; $return_hash{$Key}{"POLICY"} = $Policy_Number; $return_hash{$Key}{"MEDICAL"} = $Medical_History; $return_hash{$Key}{"RETURNING"} = $Returning_Player; $return_hash{$Key}{"PAID"} = $Paid; $return_hash{$Key}{"ACTIVE"} = $Active; $return_hash{$Key}{"CONSENT"} = $Consent; $return_hash{$Key}{"ACTIONSTO"} = $Consent_Actions; $return_hash{$Key}{"PLAY_UP"} = $Play_Up; $user_number++; } # disconnect from database $dbh->disconnect; $sth->finish(); return %return_hash; } ############################################ # Get pw info by email ############################################ sub get_pw_by_email{ my $email = shift; my $return_password = ""; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Password` FROM `Account_Info` WHERE `email` = '$email';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Password); while($sth->fetch()) { $return_password = $Password; #print "SETTING: $Password
\n"; } # disconnect from database $sth->finish(); $dbh->disconnect; #print "RP: $return_password
\n"; return $return_password; } ############################################ # Get account info by email ############################################ sub get_users_by_org{ my $org_id = shift; my $return_hash = 0; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT a.`Key`, a.`email`, a.`Firstname`, a.`Lastname`, a.`Home_Phone`, a.`Work_Phone`, a.`Mobile_Phone`, a.`Zip_Code`, b.`Address1`, b.`Address2`, b.`City`, b.`State` FROM `Account_Info` a, `Account_Extra_Info` b, `Account_Org_Reg_Link` c WHERE c.`Org_ID` = '$org_id' AND c.`Account_ID` = a.`Key` AND c.`Account_ID` = b.`Account_ID`"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$email, \$Firstname, \$Lastname, \$Home_Phone, \$Work_Phone,\$Mobile_Phone, \$Zip_Code, \$Address1, \$Address2, \$City, \$State); while($sth->fetch()) { $return_hash{$Key}{"EMAIL"} = $email; $return_hash{$Key}{"FIRSTNAME"} = $Firstname; $return_hash{$Key}{"LASTNAME"} = $Lastname; $return_hash{$Key}{"HOMEPHONE"} = $Home_Phone; $return_hash{$Key}{"WORK_PHONE"} = $Work_Phone; $return_hash{$Key}{"MOBILE_PHONE"} = $Mobile_Phone; $return_hash{$Key}{"ZIP_CODE"} = $Zip_Code; $return_hash{$Key}{"ADDRESS1"} = $Address1; $return_hash{$Key}{"ADDRESS2"} = $Address2; $return_hash{$Key}{"CITY"} = $City; $return_hash{$Key}{"STATE"} = $State; } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ############################################ # Get account info by email -- I think this is outdate ############################################ sub get_account_id_by_player_key{ my $player_key = shift; my $return_id = 0; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Account_ID` FROM `Account_Player_Info` WHERE `Key` = '$player_key'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Account_ID); while($sth->fetch()) { $return_id = $Account_ID; } # disconnect from database $sth->finish(); $dbh->disconnect; return $return_id; } ############################################ # Get account info by email ############################################ sub get_user_id_by_player_key{ my $player_key = shift; my $return_id = 0; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Account_ID` FROM `Reg_Player_Link` WHERE `Key` = '$player_key'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Account_ID); while($sth->fetch()) { $return_id = $Account_ID; } # disconnect from database $sth->finish(); $dbh->disconnect; return $return_id; } ############################################ # Get account info by email ############################################ sub verify_account_org_reg_link{ my $email = shift; my $org_id = shift; my $return_value = 0; my $dbh = get_dbh(); ################################################################ # Query DB to verify account extra info ################################################################ my $query = "SELECT a.`Key` FROM `Account_Info` a, `Account_Org_Reg_Link` b WHERE b.`Org_ID` = '$org_id' AND (a.`email` = '$email' OR a.`Login` = '$email') AND b.`Account_ID` = a.`Key`"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key); while($sth->fetch()) { $return_value = $Key; } # disconnect from database $sth->finish(); $dbh->disconnect; return $return_value; } ########################################### # Add org reg link for user that hass account # but no org reg link ########################################### sub add_user_to_account_org_reg_link{ my $email = shift; my $org_id = shift; my $user_id = check_for_account($email); ########################################### # Link Account to Org ########################################### $dbh = get_dbh(); my $query3 = "INSERT INTO `Account_Org_Reg_Link` ( `Key` , `Account_ID` , `Org_ID`)VALUES ('', '$user_id', '$org_id');"; #print "Q2:$query2
\n"; $sth = $dbh->prepare($query3); $sth->execute(); $sth->finish(); $dbh->disconnect; } ########################################### # Add Blank extra info for user that has # account but no extra info ########################################### sub add_blank_user_to_account_extra_info{ my $email = shift; my $org_id = shift; my $user_id = check_for_account($email); ########################################### # Add extra Info ########################################### $dbh = get_dbh(); my $query2 = "INSERT INTO `Account_Extra_Info` ( `Key` , `Account_ID` , `Address1` , `Address2` , `City`, `State`)VALUES ('', '$user_id', '', '', '', '');"; #print "Q2:$query2
\n"; $sth = $dbh->prepare($query2); $sth->execute(); $sth->finish(); } ############################################ # Get account info by email ############################################ sub verify_account_extra_info{ my $email = shift; my $return_value = 0; my $dbh = get_dbh(); ################################################################ # Query DB to verify account extra info ################################################################ my $query = "SELECT a.`Key` FROM `Account_Info` a, `Account_Extra_Info` b WHERE b.`Account_ID` = a.`Key` and (a.`email` = '$email' OR a.`Login` = '$email')"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key); while($sth->fetch()) { $return_value = $Key; } # disconnect from database $sth->finish(); $dbh->disconnect; return $return_value; } ############################################ # Get account info by email ############################################ sub get_account_info_by_email{ my $email = shift; my $return_hash = 0; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT a.`Key`, a.`email`, a.`Firstname`, a.`Lastname`, a.`Home_Phone`, a.`Work_Phone`, a.`Mobile_Phone`, a.`Zip_Code`, b.`Address1`, b.`Address2`, b.`City`, b.`State` FROM `Account_Info` a, `Account_Extra_Info` b WHERE b.`Account_ID` = a.`Key` and (a.`email` = '$email' OR a.`Login` = '$email')"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$email, \$Firstname, \$Lastname, \$Home_Phone, \$Work_Phone,\$Mobile_Phone, \$Zip_Code, \$Address1, \$Address2, \$City, \$State); while($sth->fetch()) { $return_hash{"KEY"} = $Key; $return_hash{"EMAIL"} = $email; $return_hash{"FIRSTNAME"} = $Firstname; $return_hash{"LASTNAME"} = $Lastname; $return_hash{"HOMEPHONE"} = $Home_Phone; $return_hash{"WORK_PHONE"} = $Work_Phone; $return_hash{"MOBILE_PHONE"} = $Mobile_Phone; $return_hash{"ZIP_CODE"} = $Zip_Code; $return_hash{"ADDRESS1"} = $Address1; $return_hash{"ADDRESS2"} = $Address2; $return_hash{"CITY"} = $City; $return_hash{"STATE"} = $State; } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ############################################ # Get account info ############################################ sub get_account_info{ my $user_key = shift; my $return_hash = 0; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT a.`Key`, a.`email`, a.`Firstname`, a.`Lastname`, a.`Home_Phone`, a.`Work_Phone`, a.`Mobile_Phone`, a.`Zip_Code`, b.`Address1`, b.`Address2`, b.`City`, b.`State` FROM `Account_Info` a, `Account_Extra_Info` b WHERE b.`Account_ID` = a.`Key` and a.`Key` = '$user_key'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$email, \$Firstname, \$Lastname, \$Home_Phone, \$Work_Phone,\$Mobile_Phone, \$Zip_Code, \$Address1, \$Address2, \$City, \$State); while($sth->fetch()) { $return_hash{"KEY"} = $Key; $return_hash{"EMAIL"} = $email; $return_hash{"FIRSTNAME"} = $Firstname; $return_hash{"LASTNAME"} = $Lastname; $return_hash{"HOMEPHONE"} = $Home_Phone; $return_hash{"WORK_PHONE"} = $Work_Phone; $return_hash{"MOBILE_PHONE"} = $Mobile_Phone; $return_hash{"ZIP_CODE"} = $Zip_Code; $return_hash{"ADDRESS1"} = $Address1; $return_hash{"ADDRESS2"} = $Address2; $return_hash{"CITY"} = $City; $return_hash{"STATE"} = $State; } # disconnect from database $dbh->disconnect; $sth->finish(); return %return_hash; } ############################################ # Check to see if the account exists # given the email. If it does reutrn the # key ID, otherwise return 0 ############################################ sub check_for_account{ my $new_email = shift; my $return_value = 0; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key` FROM `Account_Info` WHERE `email` = '$new_email'"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key); while($sth->fetch()) { $return_value = $Key; } # disconnect from database $dbh->disconnect; $sth->finish(); return $return_value; } ############################################ # return email validation javascript code ############################################ sub get_email_validation{ my $html = <<__HTML__; function validate_email(emailToValidate){ if(emailToValidate.value != ""){ atposition = emailToValidate.indexOf("@"); dotposition = emailToValidate.lastIndexOf("."); if((atposition < 1)||(dotposition - atposition <2)){ return 0; } } return 1; } __HTML__ return $html; } ############################################ # return zip validation javascript code ############################################ sub get_zip_validation{ my $html = <<__HTML__; function validate_zip(zip){ var valid = 1; len=zip.length digits="0123456789" if(len != 5){ valid = 0; } for(i=0; i<5; i++){ if (digits.indexOf(zip.charAt(i))<0){ valid = 0; } } return valid; } __HTML__ return $html; } ############################################ # return phone validation javascript code ############################################ sub get_phone_validation{ my $html = <<__HTML__; __HTML__ return $html; } ################################################################ ### Check to see if the user is logged in ### This is updated to only check if cookie is there. ################################################################ ################################################################ ### Check to see if the user is logged in ################################################################ sub remote_window_check_reg_login{ #### league could be a league or an org my $league_id = shift; my $login_fail_url = shift; my $return_string = 0; my $success = 0; my $session_id = get_cookie(); my $page = "admin"; # force admin for level 3 access #my $org_id = get_org($league_id); #print "SESSION ID: $session_id
\n"; my $dbh = get_dbh(); ################################################################ # Check to see if there is a valid cookie ################################################################ #print "SESSION = $session_id
\n"; if($session_id eq ""){ #print "SUCCESS: $success
\n"; $success = 0; }else{ my $login = get_login_from_session($session_id); #print "\n"; $access_level = check_permissions($login, $org_id, $league_id, $info_id, $page); #print "\n"; if(($page eq "admin")&&($access_level >=3)){ $success = 1; }elsif(($page eq "league")||($page eq "info")){ if($access_level >=2){ $success = 1; } } $success =1; } #print "SUCCESS: $success
\n"; if($success == 0){ #print "\n"; print <<__HTML__; __HTML__ exit(1); return 0; }else{ print "\n"; #print "\n"; return $session_id; } } 1;