Quote
The danger of chmod 777 setting
chmod 777 [filename] will set your filename to be readable, writable, and executable for yourself, the groups users, and the rest of the world.

To demonstrate the security concern of this setting, imagine you have a index.php file in your /public_html, or /www web directory that is, in essence, your landing page for your website. Now imagine, on the server, there are many other users sharing the dedicated web server each having their own /public_html, or /www web directories. If you have your index.php file permission setting to be 777, any user on the machine can read, write (and delete it!), and execute (run your script) your index.php file if they know the right path to it (which can be easily obtained, since they are on the same server). And this can be done on shell, or even from the web!

In rare occasion you would want to set your files with chmod 777 permission. Most of the time, for web page files, the permission is 755, which means only the owner of the file can write to it, other users can only read and execute your files.