#!/usr/bin/perl # $|=1; ############################################################# #Set Location of Files here my $path_cgi = "k.cgi"; my $path_html = "kiosk.html"; ############## ######### Begin procedures: BEGIN { ### Production push @INC, "/usr/local/ahacb/utility/perl-lib"; push @INC, "/usr/local/ahacb/billing/perl-lib"; # TEST #push @INC, "/usr/local/systemtest/utility/perl-lib"; #push @INC, "/usr/local/systemtest/billing/perl-lib"; $ENV{ORACLE_HOME}="/local/oracle/product/8.1.5"; $ENV{DEBUG} = 0; }; ### USE Modules use DBI; use util; require "ahalib.pl"; ############################################################################ local $dbh=&dbhconnect; my %input; my %urlstring; $input{'whattodo'}=''; $input{'acct_code'}=''; $input{'card_lname'}=''; $input{'card_fname'}=''; $input{'card_address1'}=''; $input{'card_address2'}=''; $input{'card_city'}=''; $input{'card_zip'}=''; $input{'card_number'}=''; $input{'email'}=''; $input{'phone'}=''; $input{'fax'}=''; $input{'mem_number'}=''; my $replace_string=''; print "Content-type: text/html\n\n"; if (($ENV{'REQUEST_METHOD'} eq "GET") && ($ENV{'QUERY_STRING'} ne '')) { $_ = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$_, $ENV{'CONTENT_LENGTH'}); } foreach my $pair (split('&')) { if ($pair =~ /(.*)=(.*)/) { #found key=value;# (my $key,my $value) = ($1,$2); #get key, value $_ = $value; s/%(..)/pack('c',hex($1))/eg; $value = $_; $value =~ s/\+/ /g; #substitue spaces for + sign $input{$key} = $value; #Create Associative Array } } if ($ENV{'QUERY_STRING'} ne'') { $_ = $ENV{'QUERY_STRING'}; foreach my $pair (split('&')) { if ($pair =~ /(.*)=(.*)/) { #found key=value;# (my $key,my $value) = ($1,$2); #get key, value $_ = $value; s/%(..)/pack('c',hex($1))/eg; $value = $_; $value =~ s/\+/ /g; #substitue spaces for + sign $urlstring{$key} = $value; #Create Associative Array } } if($input{acct_code}) { my($ret_val,$err_str) = &update_visitor_count($input{acct_code}); $ENV{DEBUG} && print "
update_visitor_count returned $ret_val,$err_str
\n"; } foreach my $key1(sort(keys (%urlstring))) { if ($key1 ne '' && ($key1 !~/[Aa][Cc][Cc][Tt]_[Cc][Oo][Dd][Ee]/ || $key1 ne 'p')) { $replace_string .= "\n"; } } if($input{'mem_number'} != null) { my ($ret_code,$fname,$lname,$address1,$address2,$city,$state,$zip,$email,$phone,$fax); my $member_id = $input{'mem_number'}; $member_id =~ s/\/$//g; $input{'mem_number'} = $member_id; ($ret_code,$fname,$lname,$address1,$address2,$city,$state,$zip,$email,$phone,$fax) = &pre_pop_data($member_id); if($ret_code != 0) { print "Invalid account or account is already active..$ret_code\n"; $dbh->disconnect; exit; } $input{'card_lname'}=$lname; $input{'card_fname'}=$fname; $input{'card_address1'}=$address1; $input{'card_address2'}=$address2; $input{'card_city'}=$city; $input{'card_zip'}=$zip; $input{'email'}=$email; $input{'phone'}=$phone; $input{'fax'}=$fax; } } if ($input{'p'} ne '') { $path_html="$input{'p'}.html"; } else { $path_html="kiosk.html"; } if (($input{'card_zip'} ne '') && ($input{'whattodo'} ne 'cancel')) { ### get the state and city ($input{'card_city'},$input{'card_state'})=getCityState($input{'card_zip'}); if (! defined $input{'card_city'}) { $input{'card_city'}="
City not found
" } if (! defined $input{'card_state'}) { $input{'card_state'}="
State not found
"; } } if ($input{'card_city'} eq '
City not found
') { $path_html="kiosk_back.html"; } else { if ($input{'whattodo'} eq 'proceed') { $path_html="kiosk_confirm.html"; } if ($input{'whattodo'} eq 'cancel') { if ($input{'p'} ne '') { $path_html="$input{'p'}.html"; } else { $path_html="kiosk.html"; } } } open(templatefile,"$path_html") || die "Can't open $path_html\n"; while () { s/\[ACCT_CODE\]/$input{'acct_code'}/g; s/\[PAGE-ID\]/$input{'p'}/g; s/\[MEM-NUMBER\]/$input{'mem_number'}/g; s/\[CARD-LNAME\]/$input{'card_lname'}/g; s/\[CARD-FNAME\]/$input{'card_fname'}/g; s/\[CARD-ADDRESS1\]/$input{'card_address1'}/g; s/\[CARD-ADDRESS2\]/$input{'card_address2'}/g; s/\[CARD-CITY\]/$input{'card_city'}/g; s/\[CARD-ZIP\]/$input{'card_zip'}/g; s/\[CARD-NUMBER\]/$input{'card_number'}/g; s/\[EMAIL\]/$input{'email'}/g; s/\[PHONE\]/$input{'phone'}/g; s/\[FAX\]/$input{'fax'}/g; s/\[CARD-STATE\]/$input{'card_state'}/g; s/\[CARD-COUNTRY\]/$input{'card_country'}/g; s/\[CARD-TYPE\]/$input{'card_type'}/g; s/\[MONTH-EXP\]/$input{'month_exp'}/g; s/\[YEAR-EXP\]/$input{'year_exp'}/g; #### Be careful here !!!!!!!!! s/= \"$input{'month_exp'}\"/= \"$input{'month_exp'}\" selected/g; s/\="$input{'year_exp'}\"/\="$input{'year_exp'}\" selected/g; s/\[PATHBACK\]/$ENV{'SERVER_URL'}$ENV{'SCRIPT_NAME'}/g; print $_; } $dbh->disconnect; exit; sub update_visitor_count { my $acct_code = $_[0]; $ENV{DEBUG} && print "Start update_visitor_count, parameters: $acct_code
\n"; my $cur_count=&check_vistor_acct_code($acct_code); my $ret_str; $ENV{DEBUG} && print "check_vistor_acct_code returned $cur_count
\n"; if($cur_count > 0 ) { $cur_count++; my $acct_code_new = substr($acct_code,0,5); my $sql_str = "update visitor_count set hit_count=$cur_count ". "where acct_code='$acct_code_new'"; my $sth=$dbh->prepare($sql_str); if (!$sth) { $ret_str = "Unable to prepare statement: $sql_str | "; return (1,$ret_str); } my $rcode = $sth->execute(); if (!$rcode) { $ret_str .= "Unable to execute statement: $sql_str | "; return (1,$ret_str); } } else { my $today = &to_db_date(); my $acct_code_new = substr($acct_code,0,5); my $sql_str = "insert into visitor_count ". "values('$acct_code_new','$today',1)"; $ENV{DEBUG} && print "About to execute $sql_str
\n"; my $sth=$dbh->prepare($sql_str); if (!$sth) { $ret_str = "Unable to prepare statement: $sql_str | "; return (1,$ret_str); } my $rcode = $sth->execute(); if (!$rcode) { $ret_str .= "Unable to execute statement: $sql_str | "; return (1,$ret_str); } } return(0,$ret_str); }