FW: [PHP] Protecting a file via PHP.
| From: | Steve Jackson | Date: | Tue, 16 Sep 2003 09:43:39 +0000 |
| Subject: | FW: [PHP] Protecting a file via PHP. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-162728@lists.php.net to get a copy of this message | ||
Steve Jackson
Web Development and Marketing Manager
Viola Systems Ltd.
http://www.violasystems.com
stephen.jackson@violasystems.com
Mobile +358 50 343 5159
-----Original Message-----
From: Steve Jackson [mailto:stephen.jackson@violasystems.com]
Sent: 16. syyskuuta 2003 12:15
To: 'copperwa11s@yahoo.co.jp'
Subject: RE: [PHP] Protecting a file via PHP.
> > What does this part mean in the serving the files part:
> > define('FILEDIR', '/mnt/dos/');
> >
> > Do I define the directory where the file is served from? Or do I
> > define a directory to which the file is served to (a temp) or what?
>
> It should be "from" and not "to".
OK. The thing is I wonder why in the zend article the directory here is
different. There are two scripts on the page: <?
define('FILEDIR', '/downloads/');
//display available files
$d = dir(FILEDIR);
while($f = $d->read())
{
//skip 'hidden' files
if($f{0} != '.')
{
print("<a href=\"get.php?file=$f\">$f</a><br>\n");
}
}
$d->close();
?>
This first one looks in the downloads directory (outside the root) and
grabs the filenames displaying them as a link. This works fine on my
server.
This second one starts with:
define('FILEDIR', '/mnt/dos/');
And I can't see an explanation why. Surely if it was meant to be the
same the writer would have had the same route defined?
>
> Could be a different problem...
>
Could be. But I'm trying to eliminate this one first. I've tried the
from directory and get the same error as I menioned previously. If I
can't get this to work are there any other ways I can protect a file
from being displayed. I need to be able to:
1) Display links to authenticated users (php session)
2) Let authenticated users download the files.
I don't want to use an htaccess file unless there is a way to
authenticate the user in htaccess by reading the session variable.