GetDotted Domains

Viewing Thread:
"PHP and Creating Files/File Permissions"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Tue 11/07/06 at 17:39
Regular
"Peace Respect Punk"
Posts: 8,069
Hey, just wondering what permissions I should set for files I create given the following details...

I'll be writing a PHP script to create a file, so the owner is going to be whatever user the PHP runs as on the server... The PHP needs read and write access to the file, but so do I (I'll probably be accessing the files via FTP). So I was thinking the easiest thing to do would be simply set the permissions to 666 (ie. Read and Write access for all users).

However, does this open the files up to anyone who can access the server? Because obviosuly it's hosting a bunch of websites on it, so by having Read and Write access for all, does that mean anyone who can access the server can also access the files?

Just curious and wondering how I should best proceed.

Cheers.
Thu 13/07/06 at 03:29
Regular
"Peace Respect Punk"
Posts: 8,069
Yeah, I've pretty much gone too far down the route of .txt files to bother changing it back now, and it's not like it was essential anyway, just a thing I wanted to do for no good reason really...
Thu 13/07/06 at 03:01
Regular
"Devil in disguise"
Posts: 3,151
Well go with what works. :)

However, PHP has no interest in file extensions so theres some other force at work there.
Wed 12/07/06 at 19:06
Regular
"Peace Respect Punk"
Posts: 8,069
Okay, cheers for the help, got file creation working fine and dandy now. However, one small niggle, I made the files .txt at first, everythings okay, then decided to change it just for fun to have no extension, eg. the file would be called ".(filename)"

Problem with this (and other random file extensions I tried experimenting with) is that the file doesn't seem to make use of the newlines I put in...

When using a .txt all the newlines show up nicely, however, everything else they don't... The "\n" characters don't show up either though, which was a little odd I thought.

Anyway, should I just stop messing about and use .txt or is there something I can do (or something I'm doing wrong) so the newlines show up okay?


Cheers again for the help!
Tue 11/07/06 at 20:12
Regular
"Devil in disguise"
Posts: 3,151
Hmmm... wrote:
> If you're going to use FTP to access the site then you'll be able
> to change whatever files you like (assuming you login with the
> correct user/password) so this won't be dependant on the file
> permissions.

Sure it will. FTP has to obey file permissions like everything else. Its perfectly possible to create files that you wont be able to touch under FTP.

Sibs,
Theres no simple answer to your question. In theory yes somebody else could access your files. However its dependent upon how the hosting is set up, what type of access you have to the server etc.. In most cases its unlikely and the result of poor security/configuration if they can. For instance, most hosts like to run PHP in safe mode these days so a script cant access anything outside the document root of the host (apart from a few defined directories like /tmp). Even if they get around that theres still no guarantees all the permissions of the directory tree will allow them access to the file.
Theres some risk, but its implicit in shared hosting really. In short, if you have a decent host, I wouldnt worry about it.
Tue 11/07/06 at 17:59
Moderator
"Are you sure?"
Posts: 5,000
If you're going to use FTP to access the site then you'll be able to change whatever files you like (assuming you login with the correct user/password) so this won't be dependant on the file permissions.

[URL]http://www.evolt.org/article/A_quick_and_dirty_chmod_Tutorial/18/541/[/URL] this may help...
Tue 11/07/06 at 17:39
Regular
"Peace Respect Punk"
Posts: 8,069
Hey, just wondering what permissions I should set for files I create given the following details...

I'll be writing a PHP script to create a file, so the owner is going to be whatever user the PHP runs as on the server... The PHP needs read and write access to the file, but so do I (I'll probably be accessing the files via FTP). So I was thinking the easiest thing to do would be simply set the permissions to 666 (ie. Read and Write access for all users).

However, does this open the files up to anyone who can access the server? Because obviosuly it's hosting a bunch of websites on it, so by having Read and Write access for all, does that mean anyone who can access the server can also access the files?

Just curious and wondering how I should best proceed.

Cheers.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Brilliant service.
Love it, love it, love it!
Christopher
Many thanks!!
Registered my website with Freeola Sites on Tuesday. Now have full and comprehensive Google coverage for my site. Great stuff!!
John Shepherd

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.