Hi
I have a site that uses paypal to collect payments for electronically displayed data. Variables can't be passed with the URL through paypal (or I can't get them to work) so I have used cookies to pass the item number. However, a crafty user could, after the cookie writing part, enter the paypal redirect URL directly into the address bar and get the e-data for free. Bypassing paypal. How can I get around this?
Here is some of the code. You will see I have tried to make it difficult for the user by passing straight through the cookie writing (pre_contact.php) and the paypal redirect URL (step.php).
//pre_contact.php
<?PHP
global $id;
setcookie("property", $id, time()+1800);
echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=contact.php\">";
?>
//contact.php - paypal pay button
echo "<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
echo "<input type='hidden' name='cmd' value='_s-xclick'>";
echo "<input type='hidden' name='hosted_button_id' value='156320'>";
echo "<input type='image'
src='https://www.paypal.com/en_GB/i/btn/btn_paynowCC_LG.gif' border='0' name='submit'
alt='Click to pay'>";
echo "<img alt='' border='0' src='https://www.paypal.com/en_GB/i/scr/pixel.gif' width='1' height='1'>";
echo "</form>";
//step.php - paypal redirect on successful payment
<?PHP
require("generate_url.php");
?>
//generate_url.php - This generates a unique URL so the info can only be accessed once
<?PHP
if (eregi("generate_url.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: index.php"); die();
}
$token = md5(uniqid(rand(),1));
setcookie("token", $token, time()+4);
$cwd = substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],"/"));
Header("Location: $cwd/get_file.php?q=$token"); die();
?>
//get_file.php - displays the file after payment
$qtoken = $_GET['q'];
if ($qtoken===$_COOKIE["token"]){
$id=$_COOKIE["property"];
DISPLAY FILE HERE!!
Thanks in advance