Hi, Does anyone know how to use the code below to protect clickbank products? They give you the code but don't tell you how to use it. Asking them isn't any use either. I understand that it has to work with the 'thank you' page but I dont know if it goes in a seperate file that the thankyou page calls, or if it needs embedding in the page itself (or visa versa). Is anyone able to help? Cheers, Derek PHP SOURCE: function cbValid() { $key='YOUR SECRET KEY'; $rcpt=$_REQUEST['cbreceipt']; $time=$_REQUEST['time']; $item=$_REQUEST['item']; $cbpop=$_REQUEST['cbpop']; $xxpop=sha1("$key|$rcpt|$time|$item"); $xxpop=strtoupper(substr($xxpop,0,8)); if ($cbpop==$xxpop) return 1; else return 0; }
What you have here is a function and you need to call that function by adding the following code to the top of your php page. What the code does is call the function and if the function returns 0 it sends you to an error page. If the function returns 1 your page will continue loading. $isvalid = cbValid(); if (!$isvalid) { header('Location: http://www.example.com/errorpage'); } function cbValid() { $key='YOUR SECRET KEY'; $rcpt=$_REQUEST['cbreceipt']; $time=$_REQUEST['time']; $item=$_REQUEST['item']; $cbpop=$_REQUEST['cbpop']; $xxpop=sha1("$key|$rcpt|$time|$item"); $xxpop=strtoupper(substr($xxpop,0,8)); if ($cbpop==$xxpop) return 1; else return 0; } PHP:
I normally dump this into a database so that I can keep the customer's name and e-mail address for list building. But you could also just dump the info into a text file.
Thanks for your reply. I have played arround with this alot and can't get it working. I have tried putting the code in without the <?php ?> tags but then the php code prints to the browser alonge with the page. What I have works below for re-routing a person in error, but when you pay for the product it still dosen't load the page - it still goes to the error page. Please take another look at it - hopefully you can tell me what's wrong otherwise I'll just have to use a html page. --------nothing before this---- <?php $isvalid = cbValid(); if (!$isvalid) { header('Location: http://www.1stacademy.net/index.html'); } function cbValid() { $key='YOUR SECRET KEY'; $rcpt=$_REQUEST['cbreceipt']; $time=$_REQUEST['time']; $item=$_REQUEST['item']; $cbpop=$_REQUEST['cbpop']; $xxpop=sha1("$key|$rcpt|$time|$item"); $xxpop=strtoupper(substr($xxpop,0,8)); if ($cbpop==$xxpop) return 1; else return 0; } ?> <html> <head> <meta http-equiv="Content-Language" content="en-gb"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <META name=â€robots†content=â€noindex, nofollowâ€> <title>1stAcademy ~ Downloads</title> </head> <body bgcolor="#4682B4" topmargin="5" bottommargin="30"> <div align="center"> <table border=0 width="730" id="table1" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#FFFFFF"> <table border="0" width="100%" id="table2" background="images/headerL.jpg" height="160" cellspacing="0" cellpadding="0"> <tr> html.........all the way to bottom of file.
Is your file named index.php or is it index.html? If it is not a .php file then it will not work and will print out the code instead of executing it. also, make sure that php is actually running on your server. To do that create a new file called test.php with the following <?php phpinfo(); ?> Code (markup): Upload it to your web server and then try to see it by going to www.yourdomain.com/test.php. What you should see is a list of configuration settings for php. If you don't see that, then php is not working on your server.
From your reply I still can't see what's wrong. The index file is called Index.html as it is the front page of the site (www.1stacademy.net), but the thank you page that clickbank calls after you pay is called 'gfh_prod.php'. So really I think this should work. PHP is certainly running on the server - that much I do know. Any other ideas? Thanks
If you are always sent to the error page, even on a correct purchase, then there isn't a correct match between the clickbank id and the reconstruction of it in your function. The only other thing I can think of that may cause this is that you haven't changed the value of $key = "YOUR SECRET KEY" to match the key value in your clickbank account. Go to your account settings, then pick "My Site" and scroll down to the Secret Key. Copy and paste it into the function to replace "YOUR SECRET KEY". If that doesn't work then you'll have to do some old fashion trouble shooting, or hire a php programmer to do it for you if you don't have a way to do it.
Yes that was the problem. It is working now! Clickbank really should give clear instructions with the code. Thank you Derek