FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » This is a total php newbie question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: This is a total php newbie question [message #175631 is a reply to message #175626] Fri, 14 October 2011 06:49 Go to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Thu, 13 Oct 2011 15:29:02 -0700, justaguy wrote:

> Here' what I intended to do with some php scripts. Business wise,
> b1: take the user to PayPal to make a payment. b2. take the user back
> from PayPal to download a program.

You need to look at the paypal api's. I believe they provide php code
examples.

> 1) how to create a php file on the fly?

You can create a php file on the fly by writing php commands to a file.

> With the content in the following 2)

The content will be whatever you write to the file.

------------------------------------------------

Describe the problem:

You wish a customer to be able to make a paypal payment, after which you
will provide a download link to some content for a period of x hours.

Is this correct?

So you have two issues to resolve:

a) Handling the paypal payment
b) Making the restricted content available for a time limited period

For (a)

Handling the paypal payment is fairly easy once you understand the paypal
apis, although the paypal apis are not always easy to work with. You
should read the paypal developer documentation.

For (b)

Maintain a database of identity / purchased_file_name / expiry time. I'd
set identity up as a non unique index, as a person may have purchased
multiple files at different times.

When someone logs in, access the database and use it to generate a list
of links for those files that they currently have download access to.

Keep the paid for content files outside of the webroot. When they click
on a file, use readfile to deliver it with the relevant content headers.
You should only need a single "delivery" script to handle this.

You may wish to periodically prune expired links from the database. If
the website is lightly used, you could do this every time the table is
accessed. For a more heavily used website, you might want to consider a
cron job for this.

Note that I haven't considered how you verify that someone visiting your
site 6 hours after paying for a file is the person that paid for it. You
didn't ask about that. Nor have I mentioned sessions ... but you will
probably want to use sessions to keep track of users.

Rgds

Denis McMahon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Mass Twitter Account Creator (PHP)
Next Topic: declaring private variable in class
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 03 13:28:18 GMT 2024

Total time taken to generate the page: 0.33127 seconds