#!revolution --| PayPal PDT CGI --| (c)Thomas McCarthy --| speakup at mac --| March 1, 2006 --| Used to present a web page to customers on startup --StartCGI --read info put $QUERY_STRING into theBuffer put theBuffer into theTermsArray --keep the original info. put "myLibUrl.rev" into theStack start using stack theStack put the result into tresult split theTermsArray by "&" and "=" put theTermsArray["tx"] into tvalue put "cmd=_notify-synch" into tnotify put "&tx=" & tvalue into tToken ---NEED YOUR IDENTITY TOKEN--- put "&at=YOUR IDENTITY TOKEN" into myID put tnotify & tToken & myID into x post x to url "http://www.sandbox.paypal.com/cgi-bin/webscr" -->TAKE OUT "SANDBOX" LATER put the result into postbackresult if "success" is not in it then put "some problem was encountered..." & line 1 of it into tresult ----Keep a log if you have problems-------------- -- & cr & theBuffer & cr & "I posted this: " & x & cr & "postback result: " & postbackresult into tresult put "Content-Type: text/html" & cr & cr put tresult exit startup --end it here end if put it into theTermsArray2 put it into backUpStore --keep a copy! put cr& "=============="& the date && the time & "==============" & cr & "PDT reply to my post:" & backUpStore & cr after url "file:PDT_log.txt" split theTermsArray2 by return and "=" put theTermsArray2["custom"] into _custom put theTermsArray2["payment_status"] into _status put urldecode(theTermsArray2["receiver_email"]) into _myemail put theTermsArray2["payment_gross"] into _payment put theTermsArray2["mc_currency"] into _currency ----FRAUD CHECKING--- --NEED TO HAVE A TEXT FILE WITH SOME OF THIS INFO TO CHECK AGAINST put "true" into checks_out -----EMAIL CHECK: THIS IS WHO WILL RECEIVE THE FUNDS!--- if _myemail is not "YOURNAME@SOMEWHERE.com" then put "false" into checks_out put "email doesn't match. PayPal wants this: " & _myemail & cr after tresult2 end if -------------------GET THE KEY_LOG INFO-------------------- put url "file:../reg/key_log.txt" into t_base put itemoffset("FirstName",t_base) into fname_item put itemoffset("LastName",t_base) into lname_item put itemoffset("email",t_base) into mail_item put itemoffset("price",t_base) into price_item put itemoffset("key",t_base) into key_item put itemoffset("FirstName",t_base) into name_item put itemoffset("status",t_base) into status_item put itemoffset("type",t_base) into type_item put lineoffset(_custom,t_base) into tlinenum put line tlinenum of t_base into tline2 --------PRICE CHECK------------ if _currency is not "USD" then put "false" into checks_out put "currency doesn't match: from PayPal:" & _currency & cr after tresult2 end if put item price_item of tline2 into _payment2 put item type_item of tline2 into _type replace "$" with "" in _payment2 if _payment <> _payment2 then put "false" into checks_out put "payment doesn't match: from PayPal:" & _payment && "from my records: " &_payment2 & cr after tresult2 end if --------------CHECKS OUT------------ if checks_out then put url "file:../reg/success.html" into t_html --> Set up the page to display put item key_item of tline2 into _rawkey put urldecode(_rawkey) into _key ---- do what you need to do to make the page look nice!----- put "
Your License" before _key put "

" after _key put theTermsArray2["first_name"] into customerf_name put theTermsArray2["last_name"] into customerl_name put theTermsArray2["payer_email"] into payer_email --UPDATE KEY DATABASE-- put customerf_name into item fname_item of tline2 put customerl_name into item lname_item of tline2 put urldecode(payer_email) into item mail_item of tline2 put _status into item status_item of tline2 put tline2 into line tlinenum of url "file:../reg/key_log.txt" replace "customer_email" with urldecode(payer_email) in t_html replace "customerf_name" with customerf_name in t_html replace "customerl_name" with customerl_name in t_html if _status is not "completed" then put "Your key will be emailed to you when your payment clears." into _key replace "_key" with _key in t_html put t_html into tresult else ----DOESN'T CHECK OUT------ put "

WARNING

There was a problem with this order.
We cannot process this transaction at this time.

Please contact Focus Publishing as soon as possible. The web master has been alerted.

" into tresult --need to email me about problems put "******@******.com" into tmail put urlencode(tmail) into tmail put "Trouble at PDT" into tsubject put backUpStore & cr & tresult2 into pMessage get mailout(tmail,tsubject,pMessage) end if --put theBuffer & cr & x into tresult put "Content-Type: text/html" & cr & cr put tresult end startup function mailout toWhom,tSubject,pMessage put "/usr/sbin/sendmail -t" into mprocess open process mprocess for write write "From:" && "orders@pullins.com" & cr to process mprocess write "To:" && urldecode(toWhom) & cr to process mprocess write "Subject:" && tSubject & cr & cr to process mprocess write pMessage & cr to process mprocess close process mprocess wait until the openProcesses is empty end mailout