Jump to content

project help cheers...


redarrow

Recommended Posts

Advance thank you...

 

I need a way that users can download a file when the payment is accepted from paypal......

 

But in saying that the user will be sent to the web site page stright afther paying from ebay.......

 

Do i use ipn from pay pal....

 

Do i use a code that let the file download automaticly from only useing there ip once....

 

Do i let the user enter a code pre made and cheek there ip aginst database...

 

Do i let the user enter a code pre made and cheek there pay pal info from ipn aginst database...

 

What would you do...

 

Open to sugestions...........

 

oh ye admin will be posting code afther sugestions thank you sorry to do it this way cheers.......

Link to comment
Share on other sites

thank you but  if the file is valid i need the file to download

 

shall i add the force download code to it and thank you for the code.....

 

what force download code will i need for a .txt file cheers..

 

 

 

/* If there was a valid token in $token, output the secret file: */
if( $valid )
{
        readfile($secretfile);
}
else
{
        print "Invalid URL!";
}

Link to comment
Share on other sites

SOLVED thank you...

 

<?php
/*
* get_file.php
*
* Script for validating a request through a secret token, passing a file
* to the user, and ensuring the token can not be used again.
*
*/

/* Retrive the given token: */
$token = $_GET['q'];

if( strlen($token)<32 )
{
        die("Invalid token!");
}

/* Define the secret file: */
$secretfile = "tmp/secret_file.txt";

/* This variable is used to determine if the token is valid or not: */
$valid = 0;

/* Define what file holds the ids. */
$file = "tmp/urls.txt";

/* Read the whole token-file into the variable $lines: */
$lines = file($file);

/* Truncate the token-file, and open it for writing: */
if( !($fd = fopen("tmp/urls.txt","w")) )
        die("Could not open $file for writing!");

/* Aquire exclusive lock on $file. */
if( !(flock($fd,LOCK_EX)) )
        die("Could not equire exclusive lock on $file!");

/* Loop through all tokens in the token-file: */
for( $i = 0; $lines[$i]; $i++ )
{
        /* Is the current token the same as the one defined in $token? */
        if( $token == rtrim($lines[$i]) )
        {
                $valid = 1;
        }
        /* The code below will only get executed if $token does NOT match the
           current token in the token file. The result of this will be that
           a valid token will not be written to the token file, and will
           therefore only be valid once. */
        else
        {
                fwrite($fd,$lines[$i]);
        }
}

/* We're done writing to $file, so it's safe release the lock. */
if( !(flock($fd,LOCK_UN)) )
        die("Could not release lock on $file!");

/* Save and close the token file: */
if( !(fclose($fd)) )
        die("Could not close file pointer for $file!");

/* If there was a valid token in $token, output the secret file: */
if( $valid )
{

header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header ("Content-Type: application/octet-stream");
        header ("Content-Length: " . filesize($secretfile));
        header ("Content-Disposition: attachment; filename=$secretfile");
        readfile($secretfile);
}
else
{
        print "Invalid URL!";
}



?>
[/solved]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.