Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 22nd, 2004, 09:43 PM
u3 u3 is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default can php protects my file ?

dear all,

i want to protect my file in my webserver, so anyone who want to download must login first (this is done using mysql)

but if anyone know the url, anyone can still download my file without login, then i use htaccess to protect, but by using htaccess i have to create every user which can access in my server (not in database), its usefull if i have a few user, what if i have many users ?

so, is it possible to protect file using php & mysql ?

rgrds
 
Old April 23rd, 2004, 03:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo
Default

hey

how's it going... i think the reasonable thing to do here is to specify file properties, for instance a file might be: readable, writable, etc...

when user is not logged in, make sure the file is not readable (i think you should be familiar with -r-w parameters meaning "r" for read, "w" for write, etc...), and when the user logs in just attach the read or write attribute to the file....

check functions: chmod() and chown() on php.net


:D


the genuine genius
 
Old April 23rd, 2004, 03:56 AM
u3 u3 is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the answer,

let say 2 users access my web, then the first one has login then my script changes the attribut.

and 2nd user no need to login, cause the file attribut already changed, so ?

because when user view my web they act as nobody:nobody

thanks
 
Old April 23rd, 2004, 03:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can store a list of authorized users in a database and make sure they log in to your site. There's a LOT of information out there on PHP authentication, so it's not worth repeating it all her
e.
  http://www.google.com/search?q=site:...authentication
  http://www.google.com/search?q=PHP%2...ion%20tutorial


Take care,

Nik
http://www.bigaction.org/
 
Old April 25th, 2004, 09:17 PM
u3 u3 is offline
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you all,

i've got the solution (from other forums), here:
- put the file that everybody want to download in directory that never published
- then copy it to the real directory when user click download
- after that delete that file
- so when people type in url directly, for example: http://www.a.com/download/file.zip, they will redirect to error page because file is not there :)

thanks for nikolai, but link that you've gave just talking about session and i've already knew and use that

thanks


 
Old May 15th, 2004, 08:45 PM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vsentinel
Default

Hey

I wasn't *entirely* sure what you were wanting, but copying files when people request them sounds slow to me!

You're much better to bun the files into a dir that is (as you put it) not published, then use php to read the contents of the file directly to the user, and change the HTTP headers as necassary.

Tell me if you need some sample code, and I'll paste it.

Cheers

Code:
+--------------------------------------------+
| Coldsteel - A dream, soon to be reality // |
|                                         \\ |
| www.vsentinel.net , coming soon         // |
+--------------------------------------------+
 
Old May 20th, 2004, 05:21 AM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another solution would be, to store the whole file in a database. It can be slower as the streaming method (descript from vsentinel), but you can build your own access rules for it (e.g. special groups or credit systems).

Ciao Alex...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP file reading XML file for output rydog65 Beginning PHP 0 March 26th, 2008 05:13 PM
how can i create file using php seco PHP How-To 1 April 11th, 2007 05:58 PM
php file mgnishan Beginning PHP 3 January 29th, 2007 07:02 AM
php file name zabsmarty General .NET 0 March 6th, 2006 02:06 AM
PHP file upload qazi_nomi PHP How-To 2 July 11th, 2004 10:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.