Question
Security for PHP pages (not databases)
This is for discussion, not so much a question.
Here are a few methods I use to secure web pages. I'm not suggesting these are gold standard methods. You may find fault with some or have suggestions of your own (I hope so).
- I place an index.php file in every folder, even if not needed. This helps prevent viewing the folder contents.
- No files/folders ever have permissions of 777.
- Passwords, hashes and other high security items are stored in folders above the web root in php files beginning with "."
- No web files can be directly opened except the index.php file. All other files contain something like the following:
if ($open != "25qq3e4114") { die("If you are seeing this message, please notify the webmaster");}
The variable for $open is defined in the index file. - "Friendly" urls are used which have no correspondence to the file structure.
- URL parameters are exploded into an array then analyzed as follows: Is the value purely numeric or purely alphabetic? (must be one or the other) Does it have a match in an array of acceptable values? For example, take the url parameters /form/summercamp/214, "form" could be matched to a an array of allowed first parameters, then summercamp is allowed because it is only alpha (no high or low characters allowed), and 214 is allowed because it is purely an integer.
