Results 1 to 6 of 6

Thread: file/folder permissions [resolved]

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2003
    Location
    The United Kingdom
    Posts
    45

    file/folder permissions [resolved]

    Hi,
    I have written a PHP that saves its data into files contained in a subfolder of the directory of the script. I cant figure out what CHMOD permissions I need to give to the scripts to make this work how I want.

    Basically the script needs to be able to read and write to the files in the folder, occasionally it will also create new files and it will occasionally delete files that are no longer required.

    What file permissions do I need to set on the folder so that an internet user can not just type in the URL of this folder and read the files? Also if they know the full path and filename of the files they should not be able to read them either.

    Will I need to get my PHP script to set file permissions on the new files that it creates? if so, how?

    I would very much appreciate any help on this matter. (call me a unix n00b if you must)

    Regards,

    Tim
    Last edited by MixMaster; Jun 12th, 2004 at 05:40 AM.
    Please don't discourage me, I never hurt anyone.

    "You're watching FOX News channel, real journalism, fair and balanced." - Ha

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I think this might be more a matter for a .htaccess file if you want to disallow people viewing anything in the folder .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    The UNIX file permissions are quite easy to understand. The permissions for each file and directory are reperesented using a four digit octal number.

    The first digit represents the superuser,
    the second is the owner of the file,
    the third is the group owner of the file
    and the fouth is everyone else.

    On a secure UNIX system web server files should not be owned by the same user and group as the user and group the web server itself runs. Therefore to allow or dissalow access to directories and files hosted by your web server you set the permissions on the fouth octal.

    Heres some more info about UNIX file permissions:
    http://www.macosxhints.com/article.p...01231152532966

    You can also like Electroman said deny access through the .htaccess files - if your web hosts allows you to use them.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2003
    Location
    The United Kingdom
    Posts
    45
    Ok thanks, my web host only seems to allow me to do CHMOD with a three digit octal number. It does allow .htaccess but I dont know what to put in the file, I put a .htaccess file in the directory and it contains "username:scrambled_up_password" but whenever I visit the folder I get "500: Internal server error." I suppose this is working as it's not letting anyone see the files but i was expecting "403: Forbidden" or something similar. Is this correct?
    Please don't discourage me, I never hurt anyone.

    "You're watching FOX News channel, real journalism, fair and balanced." - Ha

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    To return a 403, you only need one line in the .htaccess file:
    Code:
    Deny From all
    If you want username and password authentication. Look here:
    http://httpd.apache.org/docs-2.0/howto/auth.html
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2003
    Location
    The United Kingdom
    Posts
    45
    Thankyou, I'll give it a try.
    Please don't discourage me, I never hurt anyone.

    "You're watching FOX News channel, real journalism, fair and balanced." - Ha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width