If you want to restrict the download to once per user, the best is to use a
database (or a I guess a file) which keeps tracks of who can download it and
downloaded status, etc..

I haven't worked directly with this issue, but I would start by having a
table Permissions with columns username, articleID, downloaded, authKey (and
whatever else you may want). Then present the link to the user as
getFile.php?auth=$authKey.
where getFile.php is
<?php
$query = "select downloaded, articleID from Permissions Where authKey =
$_POST['auth']";
$result = mysql_query ($query);
if ($result) {
    $row = mysql_fetch_array ($result, MYSQL_ASSOC);
    if ($row ['downloaded'] == 'N') {
        # Update table and set downloaded = 'Y'
        # Select the text of article from Articles table or from disk and
store in variable $contents
        header ("content/type pdf"); # or text/plain, or whatever type you
need
        echo $contents;
        exit();
    }
}
?>

OK, I got tired of coding near the end (since I know you can do that), but I
think that this may be better. If you just pass the file name to the script
then you have to do checks that the user has access but how? Unless the user
already logged in to a members area I guess.

Anyways, there are problems to this script, for example if the download was
terminated half way through, it's already set that it has been downloaded
(maybe you can do the update query after the echo $contents, but I don't
think that will help).

That's my $0.02
Bobby


"Tristan Pretty" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
com...
> I read this article, and thought it was perfect for me... Just the same
> prob I'm having...
> http://forums.devshed.com/archive/5/2002/06/2/37330
>
> However, I don't understand how to get the file into an <A> tag where it
> can still find the file, AND make the URL useless if copied and pasted..
>
> Am I missing the point, or is it staring me in the face?
>
>
> *********************************************************************
> The information contained in this e-mail message is intended only for
> the personal and confidential use of the recipient(s) named above.
> If the reader of this message is not the intended recipient or an agent
> responsible for delivering it to the intended recipient, you are hereby
> notified that you have received this document in error and that any
> review, dissemination, distribution, or copying of this message is
> strictly prohibited. If you have received this communication in error,
> please notify us immediately by e-mail, and delete the original message.
> ***********************************************************************
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to