use Time::Local;
#require "dev_reg_lib_admin_v1_1.pm";
require "reg_lib_admin_v1_1.pm";
############# V 1.1
###############################################################
### Define any globals
###############################################################
#my $org_url = "teamdev2";
$method = "post"; #Use Post for production, it hides the parameters.
#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";
#my $paypal_acc = "jeremymclean\@gmail.com";
#my $paypal_acc = "lyaaball\@comcast.net";
#my $admin_url = "regadmin.html";
#my $admin_reg_url = "reg.html";
#my $thanks_url = "https://www.hometeamzonline.com/$org_url/$admin_reg_url?action=pp";
#my $ipn_url = "http://www.hometeamzonline.com/pp/ipn.php";
#my $base_reg_url = "https://www.hometeamzonline.com/$org_url/$admin_reg_url";
#my $paypal_acc = "jeremymclean\@gmail.com";
#my $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";
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;
}
################################################################
### This is the admin Sub routing for the home page
################################################################
sub admin_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');
if(!(defined($action))){$action = "";}
###############################################################
### 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 '';
print_start_header_main();
print_style2();
###############################################################
### Print Body of HTML doc
###############################################################
print <<__HTML__;