Forum Moderators: coopster
I've got a little question. I was reading some tutorials about CHMOD, but I didn't understand many things, even after I read them.
- Who can normally read the code of the PHP files?
- Can regular users download PHP files from my server and watch the code on with their favorite text editor?
- How can I prevent users from viewing the actual code of the PHP files?
- How can I prevent users from listing the files I have in certain directory, say [site.com...]
All of the questions regard for normal http browser use, not through FTP or something like that.
I want to start programming using PHP and MySQL, and I'm afraid to put the DB user and pass in a file.
Thanks in advance,
Roy
actual code, only people with ftp/ssh/telnet access. Since php is a server side language any requests through http/https are processed before they are served. The browser only receives the html output from the script requested.
- Can regular users download PHP files from my server and watch the code on with their favorite text editor?
not unless something is misconfigured.
- How can I prevent users from viewing the actual code of the PHP files?
only put php code in files with extensions that are parsed by php. Anyone requesting these files will only receive the output not the script. Avoid the common mistake of using .inc or .lib when they are not run through the parser. Calling these files will display them in plain text in a browser. Three options
1. use .inc.php and .lib.php
2. use the AddType directive in apache to make these extensions parsed by php
3. put the distinction in the name section1_lib.php global_inc.php
- How can I prevent users from listing the files I have in certain directory, say [site.com...]
This is an apache configuration issue. I it is the DirectoryIndex directive in apache conf.
As far as where to put your passwords. I always store them in a .php file and usually put them above the root of the site. That way they can't be requested through a browser.
How can I prevent users from listing the files I have in certain directory, say [site.com...]Many webservers will look for an index.php or index.html file by default in any directory. You could put one in your directory, redirecting the user to the main site.