Ok I have a script PBcomplete.pl it outputs a link on a webpage that has a token for livechat minutes. I need to email that link to an email address that is in a log file.
##########################
#####this is the log file. The new lines start at authorized. ##########################
##########
AUTHORIZED QNPCYEYGOY 1061855480 zip=94611 username=user1@domain1.net
transaction_time=07:54:44 transaction_nmb=382927 transaction_date=08/25/200
3 transaction_amount=14.95 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=CA rebill=NO pon=1052920 payment_option_description
=10 minutes payment_method_code=VISA password=dan merchant_website_name=Live
Girl Love last_name=user1 user1 hash=QNPCYEYGOY first_name=user1 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailure.pl expiration_time=07:54:45 expiration_date=08/26/2003
email=user1@domain1.net country_name=United States country_code=US conversion=NO city=user1 address=90 user1 action=ADD
AUTHORIZED LKUTHPOAOJ 1061856993 zip=94611 username=user2@domain1.net
transaction_time=08:19:56 transaction_nmb=383017 transaction_date=08/25/200
3 transaction_amount=14.95 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=CA rebill=NO pon=1052920 payment_option_description
=10 minutes payment_method_code=VISA password=dan merchant_website_name=Live
Girl Love last_name=user2 user2 hash=LKUTHPOAOJ first_name=user2 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailure.pl expiration_time=08:19:57 expiration_date=08/26/2003
email=user2@domain1.net country_name=United States country_code=US conversion=NO city=user2 address=user2 action=ADD
AUTHORIZED 1061923013
AUTHORIZED DQRNKRDUEM 1061923931 zip=94611 username=user3@domain1.net
transaction_time=02:55:33 transaction_nmb=385038 transaction_date=08/26/200
3 transaction_amount=14.95 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=CA rebill=NO pon=1052920 payment_option_description
=10 minutes payment_method_code=VISA password=dan merchant_website_name=Live
Girl Love last_name=user3 user3 hash=DQRNKRDUEM first_name=user3 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailed.pl expiration_time=02:55:34 expiration_date=08/27/2003
email=user3@domain1.net country_name=United States country_code=US conversion=NO city=user3 address=user3 action=ADD
AUTHORIZED CGLSWGHUDG 1061925191 zip=94611 username=user4@domain1.net
transaction_time=03:16:33 transaction_nmb=385084 transaction_date=08/26/200
3 transaction_amount=14.95 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=CA rebill=NO pon=1052920 payment_option_description
=10 minutes payment_method_code=VISA password=dan merchant_website_name=Live
Girl Love last_name=user4 user4 hash=CGLSWGHUDG first_name=user4 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailed.pl expiration_time=03:16:34 expiration_date=08/27/2003
email=username=user4@domai
n1.net country_name=United States country_code=US conversion=NO city=user4 address=user4 action=ADD
AUTHORIZED RBUUYUOGYY 1061925392 zip=94611 username=user5@domain1.net
transaction_time=03:19:54 transaction_nmb=385098 transaction_date=08/26/200
3 transaction_amount=14.95 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=CA rebill=NO pon=1052920 payment_option_description
=10 minutes payment_method_code=VISA password=dan merchant_website_name=Live
Girl Love last_name=user5 user5 hash=RBUUYUOGYY first_name=user5 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailed.pl expiration_time=03:19:55 expiration_date=08/27/2003
email=user5@domain1.net country_name=United States country_code=US conversion=NO city=user5 address=user5 action=ADD
AUTHORIZED AHGLAYSWDS 1061925538 zip=94611 username=user6@domain1.net
transaction_time=03:22:20 transaction_nmb=385101 transaction_date=08/26/200
3 transaction_amount=14.95 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=CA rebill=NO pon=1052920 payment_option_description
=10 minutes payment_method_code=VISA password=dan merchant_website_name=Live
Girl Love last_name=user6 hash=AHGLAYSWDS first_name=user6 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailed.pl expiration_time=03:22:21 expiration_date=08/27/2003
email=user6@domain1.net country_name=United States country_code=US conversion=NO city=user6 address=user6 action=ADD
AUTHORIZED GWRVJAJLPK 1063478562 zip=27312 username=user7@domain2.net
transaction_time=04:00:49 transaction_nmb=429207 transaction_date=09/13/200
3 transaction_amount=14.95 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=NC rebill=NO pon=1052920 payment_option_description
=10 minutes payment_method_code=VISA password=asdf merchant_website_name=Live
Girl Love last_name=Lastname7 hash=GWRVJAJLPK first_name=Firstname7 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailed.pl expiration_time=04:00:50 expiration_date=09/14/2003
email=user7@domain2.net country_name=United States country_code=US conversion=NO city=city7 address=address7 action=ADD
AUTHORIZED BWITLUVDXH 1063509547 zip=27312 username=user8@domain2.net
transaction_time=12:37:10 transaction_nmb=430487 transaction_date=09/14/200
3 transaction_amount=60.00 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=NC rebill=NO pon=1055482 payment_option_description
=25 Minutes payment_method_code=VISA password=asdf merchant_website_name=Live
Girl Love last_name=Lastname8 hash=BWITLUVDXH first_name=Firstname8 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailed.pl expiration_time=12:37:11 expiration_date=09/15/2003
email=user8@domain2.net country_name=United States country_code=US conversion=NO city=city8 address=address8 action=ADD
AUTHORIZED PINQROLXNH 1063512701 zip=27312 username=user7@domain2.net
transaction_time=01:29:43 transaction_nmb=430564 transaction_date=09/14/200
3 transaction_amount=15.00 success_redirect=
http://www.livegirllove.com/cgi-bin/PBcompleted.pl status_code=PAID state=nc rebill=NO pon=1055481 payment_option_description
=5 Minutes payment_method_code=VISA password=asdf merchant_website_name=Live
Girl Love last_name=Lastname7 hash=PINQROLXNH first_name=Firstname7 failure_redirect=
http://www.livegirllove.com/cgi-bin/PBfailed.pl expiration_time=01:29:44 expiration_date=09/15/2003
email=user7@domain2.net country_name=United States country_code=US conversion=NO city=city7 address=address7 action=ADD
###################THIS IS, I BELIEVE, THE PERTINANT PART OF THE SCRIPT####################
#######
if($authorized && !$claimed) {
# set $allowance based on timecard purchase
my $allowance = $optionTime{$params{'pon'}
};
# retrieve a valid token from Sidekick
my $token = &retrieveToken($allowance)
;
#print "GOT $token !!!\n";
#
# append log line...
#
&log($fileClaimed, 'CLAIMED', $hash, $pairs, " token=$token");
# generate html page
&displayHtmlPage($token);
} else {
#
# append log line...
#
&log($fileFailed, 'REJECTED', $hash, $pairs);
# generate html page with Rejected!
&displayHtmlPageRejected()
;
}
#
# append line to log file
# - pass filename
# - pass action
# - pass any misc data to write...
#
sub log
{
my $file = shift(@_);
my $action = shift(@_);
my $hash = shift(@_);
my $t = time;
open(ASSIGNED, ">>$file");
print ASSIGNED "$action $hash $t ", join(' ', @_), "\n";
close(ASSIGNED);
}
#
# is hash in the log file?
# - pass filename
# - pass action
# - pass any misc data to write...
#
sub hashPresent
{
my $file = shift(@_);
my $action = shift(@_);
my $hash = shift(@_);
my $line;
my $found = 0;
open(FILE, $file);
while($line = <FILE>) {
if($line =~ /^$action $hash/) {
$found = 1;
last;
}
}
close(FILE);
return $found
}
#
# call out to Sidekick to retrieve a valid token
# - pass allowable time in seconds
#
sub retrieveToken
{
my $allowance = $_[0];
my $token = "0";
my $r = new
HTTP::Request 'GET', "$getTokenUrl?allowance=$a
llowance";
my $ua = new LWP::UserAgent;
my $res = $ua->request($r);
if($res->is_success) {
$token = $res->content;
}
return $token;
}
sub displayHtmlPage
{
my $token = $_[0];
print "Content-type:text/html\n\
n";
print <<END
<html>
<head>
<title>Payment Information Approved</title>
</head>
<body bgcolor="#5B81A8" text="#CCCCCC" link="#CCCCCC">
<body>
<p><p align="center">
<img src="
http://www.livegirllove.com/images/name.gif" width="750" height="113" align="top"></p>
<p><p align="center"><font color="#CCcccc" size="4" face="Comic Sans MS"><strong>Your Payment Information Was Approved!!<br>
You Are On Your Way To Chatting With The Hottest, Sluttiest Girls On The Net!!</strong></font></p>
<br>
<p align="center"><font color="#CCcccc" size="4" face="Comic Sans MS"><strong>
<a href="$whosLivePrivateUrl?
token=$tok
en">Click Here To See Who's Live</a></strong></font></
p>
</body>
</html>
#################Three lines up is the url that needs to be emailed.##################
####